documentation.d.ts 3.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Update the current vector from an array
  2097. * @param array defines the destination array
  2098. * @param index defines the offset in the destination array
  2099. * @returns the current Vector3
  2100. */
  2101. fromArray(array: FloatArray, index?: number): Vector2;
  2102. /**
  2103. * Copy the current vector to an array
  2104. * @returns a new array with 2 elements: the Vector2 coordinates.
  2105. */
  2106. asArray(): number[];
  2107. /**
  2108. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2109. * @param source defines the source Vector2
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. copyFromFloats(x: number, y: number): Vector2;
  2120. /**
  2121. * Sets the Vector2 coordinates with the given floats
  2122. * @param x defines the first coordinate
  2123. * @param y defines the second coordinate
  2124. * @returns the current updated Vector2
  2125. */
  2126. set(x: number, y: number): Vector2;
  2127. /**
  2128. * Add another vector with the current one
  2129. * @param otherVector defines the other vector
  2130. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2131. */
  2132. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2133. /**
  2134. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2135. * @param otherVector defines the other vector
  2136. * @param result defines the target vector
  2137. * @returns the unmodified current Vector2
  2138. */
  2139. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2140. /**
  2141. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2142. * @param otherVector defines the other vector
  2143. * @returns the current updated Vector2
  2144. */
  2145. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2146. /**
  2147. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2
  2150. */
  2151. addVector3(otherVector: Vector3): Vector2;
  2152. /**
  2153. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2154. * @param otherVector defines the other vector
  2155. * @returns a new Vector2
  2156. */
  2157. subtract(otherVector: Vector2): Vector2;
  2158. /**
  2159. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2160. * @param otherVector defines the other vector
  2161. * @param result defines the target vector
  2162. * @returns the unmodified current Vector2
  2163. */
  2164. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2165. /**
  2166. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns the current updated Vector2
  2169. */
  2170. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2171. /**
  2172. * Multiplies in place the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2185. * @param otherVector defines the other vector
  2186. * @param result defines the target vector
  2187. * @returns the unmodified current Vector2
  2188. */
  2189. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2192. * @param x defines the first coordinate
  2193. * @param y defines the second coordinate
  2194. * @returns a new Vector2
  2195. */
  2196. multiplyByFloats(x: number, y: number): Vector2;
  2197. /**
  2198. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2199. * @param otherVector defines the other vector
  2200. * @returns a new Vector2
  2201. */
  2202. divide(otherVector: Vector2): Vector2;
  2203. /**
  2204. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2205. * @param otherVector defines the other vector
  2206. * @param result defines the target vector
  2207. * @returns the unmodified current Vector2
  2208. */
  2209. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2210. /**
  2211. * Divides the current Vector2 coordinates by the given ones
  2212. * @param otherVector defines the other vector
  2213. * @returns the current updated Vector2
  2214. */
  2215. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 with current Vector2 negated coordinates
  2218. * @returns a new Vector2
  2219. */
  2220. negate(): Vector2;
  2221. /**
  2222. * Negate this vector in place
  2223. * @returns this
  2224. */
  2225. negateInPlace(): Vector2;
  2226. /**
  2227. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2228. * @param result defines the Vector3 object where to store the result
  2229. * @returns the current Vector2
  2230. */
  2231. negateToRef(result: Vector2): Vector2;
  2232. /**
  2233. * Multiply the Vector2 coordinates by scale
  2234. * @param scale defines the scaling factor
  2235. * @returns the current updated Vector2
  2236. */
  2237. scaleInPlace(scale: number): Vector2;
  2238. /**
  2239. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2240. * @param scale defines the scaling factor
  2241. * @returns a new Vector2
  2242. */
  2243. scale(scale: number): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2253. * @param scale defines the scale factor
  2254. * @param result defines the Vector2 object where to store the result
  2255. * @returns the unmodified current Vector2
  2256. */
  2257. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2258. /**
  2259. * Gets a boolean if two vectors are equals
  2260. * @param otherVector defines the other vector
  2261. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2262. */
  2263. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2264. /**
  2265. * Gets a boolean if two vectors are equals (using an epsilon value)
  2266. * @param otherVector defines the other vector
  2267. * @param epsilon defines the minimal distance to consider equality
  2268. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2269. */
  2270. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2271. /**
  2272. * Gets a new Vector2 from current Vector2 floored values
  2273. * @returns a new Vector2
  2274. */
  2275. floor(): Vector2;
  2276. /**
  2277. * Gets a new Vector2 from current Vector2 floored values
  2278. * @returns a new Vector2
  2279. */
  2280. fract(): Vector2;
  2281. /**
  2282. * Gets the length of the vector
  2283. * @returns the vector length (float)
  2284. */
  2285. length(): number;
  2286. /**
  2287. * Gets the vector squared length
  2288. * @returns the vector squared length (float)
  2289. */
  2290. lengthSquared(): number;
  2291. /**
  2292. * Normalize the vector
  2293. * @returns the current updated Vector2
  2294. */
  2295. normalize(): Vector2;
  2296. /**
  2297. * Gets a new Vector2 copied from the Vector2
  2298. * @returns a new Vector2
  2299. */
  2300. clone(): Vector2;
  2301. /**
  2302. * Gets a new Vector2(0, 0)
  2303. * @returns a new Vector2
  2304. */
  2305. static Zero(): Vector2;
  2306. /**
  2307. * Gets a new Vector2(1, 1)
  2308. * @returns a new Vector2
  2309. */
  2310. static One(): Vector2;
  2311. /**
  2312. * Gets a new Vector2 set from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @returns a new Vector2
  2316. */
  2317. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2318. /**
  2319. * Sets "result" from the given index element of the given array
  2320. * @param array defines the data source
  2321. * @param offset defines the offset in the data source
  2322. * @param result defines the target vector
  2323. */
  2324. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2325. /**
  2326. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2327. * @param value1 defines 1st point of control
  2328. * @param value2 defines 2nd point of control
  2329. * @param value3 defines 3rd point of control
  2330. * @param value4 defines 4th point of control
  2331. * @param amount defines the interpolation factor
  2332. * @returns a new Vector2
  2333. */
  2334. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2335. /**
  2336. * 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".
  2337. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2338. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2339. * @param value defines the value to clamp
  2340. * @param min defines the lower limit
  2341. * @param max defines the upper limit
  2342. * @returns a new Vector2
  2343. */
  2344. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2345. /**
  2346. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2347. * @param value1 defines the 1st control point
  2348. * @param tangent1 defines the outgoing tangent
  2349. * @param value2 defines the 2nd control point
  2350. * @param tangent2 defines the incoming tangent
  2351. * @param amount defines the interpolation factor
  2352. * @returns a new Vector2
  2353. */
  2354. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2355. /**
  2356. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2357. * @param start defines the start vector
  2358. * @param end defines the end vector
  2359. * @param amount defines the interpolation factor
  2360. * @returns a new Vector2
  2361. */
  2362. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2363. /**
  2364. * Gets the dot product of the vector "left" and the vector "right"
  2365. * @param left defines first vector
  2366. * @param right defines second vector
  2367. * @returns the dot product (float)
  2368. */
  2369. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2370. /**
  2371. * Returns a new Vector2 equal to the normalized given vector
  2372. * @param vector defines the vector to normalize
  2373. * @returns a new Vector2
  2374. */
  2375. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2385. * @param left defines 1st vector
  2386. * @param right defines 2nd vector
  2387. * @returns a new Vector2
  2388. */
  2389. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2390. /**
  2391. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @returns a new Vector2
  2395. */
  2396. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2397. /**
  2398. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2399. * @param vector defines the vector to transform
  2400. * @param transformation defines the matrix to apply
  2401. * @param result defines the target vector
  2402. */
  2403. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2404. /**
  2405. * Determines if a given vector is included in a triangle
  2406. * @param p defines the vector to test
  2407. * @param p0 defines 1st triangle point
  2408. * @param p1 defines 2nd triangle point
  2409. * @param p2 defines 3rd triangle point
  2410. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2411. */
  2412. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2413. /**
  2414. * Gets the distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the distance between vectors
  2418. */
  2419. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Returns the squared distance between the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns the squared distance between vectors
  2425. */
  2426. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2427. /**
  2428. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2429. * @param value1 defines first vector
  2430. * @param value2 defines second vector
  2431. * @returns a new Vector2
  2432. */
  2433. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2434. /**
  2435. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2436. * @param p defines the middle point
  2437. * @param segA defines one point of the segment
  2438. * @param segB defines the other point of the segment
  2439. * @returns the shortest distance
  2440. */
  2441. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2442. }
  2443. /**
  2444. * Class used to store (x,y,z) vector representation
  2445. * A Vector3 is the main object used in 3D geometry
  2446. * It can represent etiher the coordinates of a point the space, either a direction
  2447. * Reminder: js uses a left handed forward facing system
  2448. */
  2449. export class Vector3 {
  2450. private static _UpReadOnly;
  2451. private static _ZeroReadOnly;
  2452. /** @hidden */
  2453. _x: number;
  2454. /** @hidden */
  2455. _y: number;
  2456. /** @hidden */
  2457. _z: number;
  2458. /** @hidden */
  2459. _isDirty: boolean;
  2460. /** Gets or sets the x coordinate */
  2461. get x(): number;
  2462. set x(value: number);
  2463. /** Gets or sets the y coordinate */
  2464. get y(): number;
  2465. set y(value: number);
  2466. /** Gets or sets the z coordinate */
  2467. get z(): number;
  2468. set z(value: number);
  2469. /**
  2470. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2471. * @param x defines the first coordinates (on X axis)
  2472. * @param y defines the second coordinates (on Y axis)
  2473. * @param z defines the third coordinates (on Z axis)
  2474. */
  2475. constructor(x?: number, y?: number, z?: number);
  2476. /**
  2477. * Creates a string representation of the Vector3
  2478. * @returns a string with the Vector3 coordinates.
  2479. */
  2480. toString(): string;
  2481. /**
  2482. * Gets the class name
  2483. * @returns the string "Vector3"
  2484. */
  2485. getClassName(): string;
  2486. /**
  2487. * Creates the Vector3 hash code
  2488. * @returns a number which tends to be unique between Vector3 instances
  2489. */
  2490. getHashCode(): number;
  2491. /**
  2492. * Creates an array containing three elements : the coordinates of the Vector3
  2493. * @returns a new array of numbers
  2494. */
  2495. asArray(): number[];
  2496. /**
  2497. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2498. * @param array defines the destination array
  2499. * @param index defines the offset in the destination array
  2500. * @returns the current Vector3
  2501. */
  2502. toArray(array: FloatArray, index?: number): Vector3;
  2503. /**
  2504. * Update the current vector from an array
  2505. * @param array defines the destination array
  2506. * @param index defines the offset in the destination array
  2507. * @returns the current Vector3
  2508. */
  2509. fromArray(array: FloatArray, index?: number): Vector3;
  2510. /**
  2511. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2512. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2513. */
  2514. toQuaternion(): Quaternion;
  2515. /**
  2516. * Adds the given vector to the current Vector3
  2517. * @param otherVector defines the second operand
  2518. * @returns the current updated Vector3
  2519. */
  2520. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the given coordinates to the current Vector3
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2529. /**
  2530. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2531. * @param otherVector defines the second operand
  2532. * @returns the resulting Vector3
  2533. */
  2534. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2537. * @param otherVector defines the second operand
  2538. * @param result defines the Vector3 object where to store the result
  2539. * @returns the current Vector3
  2540. */
  2541. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2542. /**
  2543. * Subtract the given vector from the current Vector3
  2544. * @param otherVector defines the second operand
  2545. * @returns the current updated Vector3
  2546. */
  2547. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2548. /**
  2549. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Subtracts the given vector from the current Vector3 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. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the resulting Vector3
  2567. */
  2568. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2578. /**
  2579. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2580. * @returns a new Vector3
  2581. */
  2582. negate(): Vector3;
  2583. /**
  2584. * Negate this vector in place
  2585. * @returns this
  2586. */
  2587. negateInPlace(): Vector3;
  2588. /**
  2589. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2590. * @param result defines the Vector3 object where to store the result
  2591. * @returns the current Vector3
  2592. */
  2593. negateToRef(result: Vector3): Vector3;
  2594. /**
  2595. * Multiplies the Vector3 coordinates by the float "scale"
  2596. * @param scale defines the multiplier factor
  2597. * @returns the current updated Vector3
  2598. */
  2599. scaleInPlace(scale: number): Vector3;
  2600. /**
  2601. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2602. * @param scale defines the multiplier factor
  2603. * @returns a new Vector3
  2604. */
  2605. scale(scale: number): Vector3;
  2606. /**
  2607. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2608. * @param scale defines the multiplier factor
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. scaleToRef(scale: number, result: Vector3): Vector3;
  2613. /**
  2614. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the unmodified current Vector3
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2620. /**
  2621. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2622. * @param origin defines the origin of the projection ray
  2623. * @param plane defines the plane to project to
  2624. * @returns the projected vector3
  2625. */
  2626. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2627. /**
  2628. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2629. * @param origin defines the origin of the projection ray
  2630. * @param plane defines the plane to project to
  2631. * @param result defines the Vector3 where to store the result
  2632. */
  2633. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2634. /**
  2635. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2636. * @param otherVector defines the second operand
  2637. * @returns true if both vectors are equals
  2638. */
  2639. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2640. /**
  2641. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2642. * @param otherVector defines the second operand
  2643. * @param epsilon defines the minimal distance to define values as equals
  2644. * @returns true if both vectors are distant less than epsilon
  2645. */
  2646. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2647. /**
  2648. * Returns true if the current Vector3 coordinates equals the given floats
  2649. * @param x defines the x coordinate of the operand
  2650. * @param y defines the y coordinate of the operand
  2651. * @param z defines the z coordinate of the operand
  2652. * @returns true if both vectors are equals
  2653. */
  2654. equalsToFloats(x: number, y: number, z: number): boolean;
  2655. /**
  2656. * Multiplies the current Vector3 coordinates by the given ones
  2657. * @param otherVector defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2663. * @param otherVector defines the second operand
  2664. * @returns the new Vector3
  2665. */
  2666. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2669. * @param otherVector defines the second operand
  2670. * @param result defines the Vector3 object where to store the result
  2671. * @returns the current Vector3
  2672. */
  2673. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the new Vector3
  2680. */
  2681. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2684. * @param otherVector defines the second operand
  2685. * @returns the new Vector3
  2686. */
  2687. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2690. * @param otherVector defines the second operand
  2691. * @param result defines the Vector3 object where to store the result
  2692. * @returns the current Vector3
  2693. */
  2694. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones.
  2697. * @param otherVector defines the second operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. divideInPlace(otherVector: Vector3): Vector3;
  2701. /**
  2702. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2713. /**
  2714. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2715. * @param x defines the x coordinate of the operand
  2716. * @param y defines the y coordinate of the operand
  2717. * @param z defines the z coordinate of the operand
  2718. * @returns the current updated Vector3
  2719. */
  2720. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2721. /**
  2722. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2723. * @param x defines the x coordinate of the operand
  2724. * @param y defines the y coordinate of the operand
  2725. * @param z defines the z coordinate of the operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2729. /**
  2730. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2731. * Check if is non uniform within a certain amount of decimal places to account for this
  2732. * @param epsilon the amount the values can differ
  2733. * @returns if the the vector is non uniform to a certain number of decimal places
  2734. */
  2735. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2736. /**
  2737. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2738. */
  2739. get isNonUniform(): boolean;
  2740. /**
  2741. * Gets a new Vector3 from current Vector3 floored values
  2742. * @returns a new Vector3
  2743. */
  2744. floor(): Vector3;
  2745. /**
  2746. * Gets a new Vector3 from current Vector3 floored values
  2747. * @returns a new Vector3
  2748. */
  2749. fract(): Vector3;
  2750. /**
  2751. * Gets the length of the Vector3
  2752. * @returns the length of the Vector3
  2753. */
  2754. length(): number;
  2755. /**
  2756. * Gets the squared length of the Vector3
  2757. * @returns squared length of the Vector3
  2758. */
  2759. lengthSquared(): number;
  2760. /**
  2761. * Normalize the current Vector3.
  2762. * Please note that this is an in place operation.
  2763. * @returns the current updated Vector3
  2764. */
  2765. normalize(): Vector3;
  2766. /**
  2767. * Reorders the x y z properties of the vector in place
  2768. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2769. * @returns the current updated vector
  2770. */
  2771. reorderInPlace(order: string): this;
  2772. /**
  2773. * Rotates the vector around 0,0,0 by a quaternion
  2774. * @param quaternion the rotation quaternion
  2775. * @param result vector to store the result
  2776. * @returns the resulting vector
  2777. */
  2778. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2779. /**
  2780. * Rotates a vector around a given point
  2781. * @param quaternion the rotation quaternion
  2782. * @param point the point to rotate around
  2783. * @param result vector to store the result
  2784. * @returns the resulting vector
  2785. */
  2786. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2787. /**
  2788. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2789. * The cross product is then orthogonal to both current and "other"
  2790. * @param other defines the right operand
  2791. * @returns the cross product
  2792. */
  2793. cross(other: Vector3): Vector3;
  2794. /**
  2795. * Normalize the current Vector3 with the given input length.
  2796. * Please note that this is an in place operation.
  2797. * @param len the length of the vector
  2798. * @returns the current updated Vector3
  2799. */
  2800. normalizeFromLength(len: number): Vector3;
  2801. /**
  2802. * Normalize the current Vector3 to a new vector
  2803. * @returns the new Vector3
  2804. */
  2805. normalizeToNew(): Vector3;
  2806. /**
  2807. * Normalize the current Vector3 to the reference
  2808. * @param reference define the Vector3 to update
  2809. * @returns the updated Vector3
  2810. */
  2811. normalizeToRef(reference: Vector3): Vector3;
  2812. /**
  2813. * Creates a new Vector3 copied from the current Vector3
  2814. * @returns the new Vector3
  2815. */
  2816. clone(): Vector3;
  2817. /**
  2818. * Copies the given vector coordinates to the current Vector3 ones
  2819. * @param source defines the source Vector3
  2820. * @returns the current updated Vector3
  2821. */
  2822. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2823. /**
  2824. * Copies the given floats to the current Vector3 coordinates
  2825. * @param x defines the x coordinate of the operand
  2826. * @param y defines the y coordinate of the operand
  2827. * @param z defines the z coordinate of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. copyFromFloats(x: number, y: number, z: number): Vector3;
  2831. /**
  2832. * Copies the given floats to the current Vector3 coordinates
  2833. * @param x defines the x coordinate of the operand
  2834. * @param y defines the y coordinate of the operand
  2835. * @param z defines the z coordinate of the operand
  2836. * @returns the current updated Vector3
  2837. */
  2838. set(x: number, y: number, z: number): Vector3;
  2839. /**
  2840. * Copies the given float to the current Vector3 coordinates
  2841. * @param v defines the x, y and z coordinates of the operand
  2842. * @returns the current updated Vector3
  2843. */
  2844. setAll(v: number): Vector3;
  2845. /**
  2846. * Get the clip factor between two vectors
  2847. * @param vector0 defines the first operand
  2848. * @param vector1 defines the second operand
  2849. * @param axis defines the axis to use
  2850. * @param size defines the size along the axis
  2851. * @returns the clip factor
  2852. */
  2853. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2854. /**
  2855. * Get angle between two vectors
  2856. * @param vector0 angle between vector0 and vector1
  2857. * @param vector1 angle between vector0 and vector1
  2858. * @param normal direction of the normal
  2859. * @return the angle between vector0 and vector1
  2860. */
  2861. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2862. /**
  2863. * Returns a new Vector3 set from the index "offset" of the given array
  2864. * @param array defines the source array
  2865. * @param offset defines the offset in the source array
  2866. * @returns the new Vector3
  2867. */
  2868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2871. * @param array defines the source array
  2872. * @param offset defines the offset in the source array
  2873. * @returns the new Vector3
  2874. * @deprecated Please use FromArray instead.
  2875. */
  2876. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2879. * @param array defines the source array
  2880. * @param offset defines the offset in the source array
  2881. * @param result defines the Vector3 where to store the result
  2882. */
  2883. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2884. /**
  2885. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @param result defines the Vector3 where to store the result
  2889. * @deprecated Please use FromArrayToRef instead.
  2890. */
  2891. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2892. /**
  2893. * Sets the given vector "result" with the given floats.
  2894. * @param x defines the x coordinate of the source
  2895. * @param y defines the y coordinate of the source
  2896. * @param z defines the z coordinate of the source
  2897. * @param result defines the Vector3 where to store the result
  2898. */
  2899. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2902. * @returns a new empty Vector3
  2903. */
  2904. static Zero(): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2907. * @returns a new unit Vector3
  2908. */
  2909. static One(): Vector3;
  2910. /**
  2911. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2912. * @returns a new up Vector3
  2913. */
  2914. static Up(): Vector3;
  2915. /**
  2916. * Gets a up Vector3 that must not be updated
  2917. */
  2918. static get UpReadOnly(): DeepImmutable<Vector3>;
  2919. /**
  2920. * Gets a zero Vector3 that must not be updated
  2921. */
  2922. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2925. * @returns a new down Vector3
  2926. */
  2927. static Down(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2930. * @param rightHandedSystem is the scene right-handed (negative z)
  2931. * @returns a new forward Vector3
  2932. */
  2933. static Forward(rightHandedSystem?: boolean): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2936. * @param rightHandedSystem is the scene right-handed (negative-z)
  2937. * @returns a new forward Vector3
  2938. */
  2939. static Backward(rightHandedSystem?: boolean): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2942. * @returns a new right Vector3
  2943. */
  2944. static Right(): Vector3;
  2945. /**
  2946. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2947. * @returns a new left Vector3
  2948. */
  2949. static Left(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2952. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2953. * @param vector defines the Vector3 to transform
  2954. * @param transformation defines the transformation matrix
  2955. * @returns the transformed Vector3
  2956. */
  2957. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2958. /**
  2959. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2961. * @param vector defines the Vector3 to transform
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2968. * This method computes tranformed coordinates only, not transformed direction vectors
  2969. * @param x define the x coordinate of the source vector
  2970. * @param y define the y coordinate of the source vector
  2971. * @param z define the z coordinate of the source vector
  2972. * @param transformation defines the transformation matrix
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2978. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2979. * @param vector defines the Vector3 to transform
  2980. * @param transformation defines the transformation matrix
  2981. * @returns the new Vector3
  2982. */
  2983. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2984. /**
  2985. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2987. * @param vector defines the Vector3 to transform
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2995. * @param x define the x coordinate of the source vector
  2996. * @param y define the y coordinate of the source vector
  2997. * @param z define the z coordinate of the source vector
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3004. * @param value1 defines the first control point
  3005. * @param value2 defines the second control point
  3006. * @param value3 defines the third control point
  3007. * @param value4 defines the fourth control point
  3008. * @param amount defines the amount on the spline to use
  3009. * @returns the new Vector3
  3010. */
  3011. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3012. /**
  3013. * 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"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @returns the new Vector3
  3020. */
  3021. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * 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"
  3024. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3025. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3026. * @param value defines the current value
  3027. * @param min defines the lower range value
  3028. * @param max defines the upper range value
  3029. * @param result defines the Vector3 where to store the result
  3030. */
  3031. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3032. /**
  3033. * Checks if a given vector is inside a specific range
  3034. * @param v defines the vector to test
  3035. * @param min defines the minimum range
  3036. * @param max defines the maximum range
  3037. */
  3038. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3041. * @param value1 defines the first control point
  3042. * @param tangent1 defines the first tangent vector
  3043. * @param value2 defines the second control point
  3044. * @param tangent2 defines the second tangent vector
  3045. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3046. * @returns the new Vector3
  3047. */
  3048. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3049. /**
  3050. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3051. * @param start defines the start value
  3052. * @param end defines the end value
  3053. * @param amount max defines amount between both (between 0 and 1)
  3054. * @returns the new Vector3
  3055. */
  3056. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3057. /**
  3058. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3059. * @param start defines the start value
  3060. * @param end defines the end value
  3061. * @param amount max defines amount between both (between 0 and 1)
  3062. * @param result defines the Vector3 where to store the result
  3063. */
  3064. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3065. /**
  3066. * Returns the dot product (float) between the vectors "left" and "right"
  3067. * @param left defines the left operand
  3068. * @param right defines the right operand
  3069. * @returns the dot product
  3070. */
  3071. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3072. /**
  3073. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3074. * The cross product is then orthogonal to both "left" and "right"
  3075. * @param left defines the left operand
  3076. * @param right defines the right operand
  3077. * @returns the cross product
  3078. */
  3079. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the cross product of "left" and "right"
  3082. * The cross product is then orthogonal to both "left" and "right"
  3083. * @param left defines the left operand
  3084. * @param right defines the right operand
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3088. /**
  3089. * Returns a new Vector3 as the normalization of the given vector
  3090. * @param vector defines the Vector3 to normalize
  3091. * @returns the new Vector3
  3092. */
  3093. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3094. /**
  3095. * Sets the given vector "result" with the normalization of the given first vector
  3096. * @param vector defines the Vector3 to normalize
  3097. * @param result defines the Vector3 where to store the result
  3098. */
  3099. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3100. /**
  3101. * Project a Vector3 onto screen space
  3102. * @param vector defines the Vector3 to project
  3103. * @param world defines the world matrix to use
  3104. * @param transform defines the transform (view x projection) matrix to use
  3105. * @param viewport defines the screen viewport to use
  3106. * @returns the new Vector3
  3107. */
  3108. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3109. /** @hidden */
  3110. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param transform defines the transform (view x projection) matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param source defines the screen space Vector3 to use
  3135. * @param viewportWidth defines the current width of the viewport
  3136. * @param viewportHeight defines the current height of the viewport
  3137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3138. * @param view defines the view matrix to use
  3139. * @param projection defines the projection matrix to use
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param sourceX defines the screen space x coordinate to use
  3146. * @param sourceY defines the screen space y coordinate to use
  3147. * @param sourceZ defines the screen space z coordinate to use
  3148. * @param viewportWidth defines the current width of the viewport
  3149. * @param viewportHeight defines the current height of the viewport
  3150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3151. * @param view defines the view matrix to use
  3152. * @param projection defines the projection matrix to use
  3153. * @param result defines the Vector3 where to store the result
  3154. */
  3155. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3156. /**
  3157. * Gets the minimal coordinate values between two Vector3
  3158. * @param left defines the first operand
  3159. * @param right defines the second operand
  3160. * @returns the new Vector3
  3161. */
  3162. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Gets the maximal coordinate values between two Vector3
  3165. * @param left defines the first operand
  3166. * @param right defines the second operand
  3167. * @returns the new Vector3
  3168. */
  3169. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3170. /**
  3171. * Returns the distance between the vectors "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the distance
  3175. */
  3176. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3177. /**
  3178. * Returns the squared distance between the vectors "value1" and "value2"
  3179. * @param value1 defines the first operand
  3180. * @param value2 defines the second operand
  3181. * @returns the squared distance
  3182. */
  3183. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3184. /**
  3185. * Returns a new Vector3 located at the center between "value1" and "value2"
  3186. * @param value1 defines the first operand
  3187. * @param value2 defines the second operand
  3188. * @returns the new Vector3
  3189. */
  3190. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3193. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3194. * to something in order to rotate it from its local system to the given target system
  3195. * Note: axis1, axis2 and axis3 are normalized during this operation
  3196. * @param axis1 defines the first axis
  3197. * @param axis2 defines the second axis
  3198. * @param axis3 defines the third axis
  3199. * @returns a new Vector3
  3200. */
  3201. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3204. * @param axis1 defines the first axis
  3205. * @param axis2 defines the second axis
  3206. * @param axis3 defines the third axis
  3207. * @param ref defines the Vector3 where to store the result
  3208. */
  3209. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3210. }
  3211. /**
  3212. * Vector4 class created for EulerAngle class conversion to Quaternion
  3213. */
  3214. export class Vector4 {
  3215. /** x value of the vector */
  3216. x: number;
  3217. /** y value of the vector */
  3218. y: number;
  3219. /** z value of the vector */
  3220. z: number;
  3221. /** w value of the vector */
  3222. w: number;
  3223. /**
  3224. * Creates a Vector4 object from the given floats.
  3225. * @param x x value of the vector
  3226. * @param y y value of the vector
  3227. * @param z z value of the vector
  3228. * @param w w value of the vector
  3229. */
  3230. constructor(
  3231. /** x value of the vector */
  3232. x: number,
  3233. /** y value of the vector */
  3234. y: number,
  3235. /** z value of the vector */
  3236. z: number,
  3237. /** w value of the vector */
  3238. w: number);
  3239. /**
  3240. * Returns the string with the Vector4 coordinates.
  3241. * @returns a string containing all the vector values
  3242. */
  3243. toString(): string;
  3244. /**
  3245. * Returns the string "Vector4".
  3246. * @returns "Vector4"
  3247. */
  3248. getClassName(): string;
  3249. /**
  3250. * Returns the Vector4 hash code.
  3251. * @returns a unique hash code
  3252. */
  3253. getHashCode(): number;
  3254. /**
  3255. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3256. * @returns the resulting array
  3257. */
  3258. asArray(): number[];
  3259. /**
  3260. * Populates the given array from the given index with the Vector4 coordinates.
  3261. * @param array array to populate
  3262. * @param index index of the array to start at (default: 0)
  3263. * @returns the Vector4.
  3264. */
  3265. toArray(array: FloatArray, index?: number): Vector4;
  3266. /**
  3267. * Update the current vector from an array
  3268. * @param array defines the destination array
  3269. * @param index defines the offset in the destination array
  3270. * @returns the current Vector3
  3271. */
  3272. fromArray(array: FloatArray, index?: number): Vector4;
  3273. /**
  3274. * Adds the given vector to the current Vector4.
  3275. * @param otherVector the vector to add
  3276. * @returns the updated Vector4.
  3277. */
  3278. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3281. * @param otherVector the vector to add
  3282. * @returns the resulting vector
  3283. */
  3284. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3287. * @param otherVector the vector to add
  3288. * @param result the vector to store the result
  3289. * @returns the current Vector4.
  3290. */
  3291. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3292. /**
  3293. * Subtract in place the given vector from the current Vector4.
  3294. * @param otherVector the vector to subtract
  3295. * @returns the updated Vector4.
  3296. */
  3297. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3300. * @param otherVector the vector to add
  3301. * @returns the new vector with the result
  3302. */
  3303. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3306. * @param otherVector the vector to subtract
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3313. */
  3314. /**
  3315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3316. * @param x value to subtract
  3317. * @param y value to subtract
  3318. * @param z value to subtract
  3319. * @param w value to subtract
  3320. * @returns new vector containing the result
  3321. */
  3322. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3325. * @param x value to subtract
  3326. * @param y value to subtract
  3327. * @param z value to subtract
  3328. * @param w value to subtract
  3329. * @param result the vector to store the result in
  3330. * @returns the current Vector4.
  3331. */
  3332. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3333. /**
  3334. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3335. * @returns a new vector with the negated values
  3336. */
  3337. negate(): Vector4;
  3338. /**
  3339. * Negate this vector in place
  3340. * @returns this
  3341. */
  3342. negateInPlace(): Vector4;
  3343. /**
  3344. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3345. * @param result defines the Vector3 object where to store the result
  3346. * @returns the current Vector4
  3347. */
  3348. negateToRef(result: Vector4): Vector4;
  3349. /**
  3350. * Multiplies the current Vector4 coordinates by scale (float).
  3351. * @param scale the number to scale with
  3352. * @returns the updated Vector4.
  3353. */
  3354. scaleInPlace(scale: number): Vector4;
  3355. /**
  3356. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3357. * @param scale the number to scale with
  3358. * @returns a new vector with the result
  3359. */
  3360. scale(scale: number): Vector4;
  3361. /**
  3362. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3363. * @param scale the number to scale with
  3364. * @param result a vector to store the result in
  3365. * @returns the current Vector4.
  3366. */
  3367. scaleToRef(scale: number, result: Vector4): Vector4;
  3368. /**
  3369. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3370. * @param scale defines the scale factor
  3371. * @param result defines the Vector4 object where to store the result
  3372. * @returns the unmodified current Vector4
  3373. */
  3374. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3375. /**
  3376. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3377. * @param otherVector the vector to compare against
  3378. * @returns true if they are equal
  3379. */
  3380. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3381. /**
  3382. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3383. * @param otherVector vector to compare against
  3384. * @param epsilon (Default: very small number)
  3385. * @returns true if they are equal
  3386. */
  3387. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3388. /**
  3389. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3390. * @param x x value to compare against
  3391. * @param y y value to compare against
  3392. * @param z z value to compare against
  3393. * @param w w value to compare against
  3394. * @returns true if equal
  3395. */
  3396. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3397. /**
  3398. * Multiplies in place the current Vector4 by the given one.
  3399. * @param otherVector vector to multiple with
  3400. * @returns the updated Vector4.
  3401. */
  3402. multiplyInPlace(otherVector: Vector4): Vector4;
  3403. /**
  3404. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3405. * @param otherVector vector to multiple with
  3406. * @returns resulting new vector
  3407. */
  3408. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3411. * @param otherVector vector to multiple with
  3412. * @param result vector to store the result
  3413. * @returns the current Vector4.
  3414. */
  3415. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3416. /**
  3417. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3418. * @param x x value multiply with
  3419. * @param y y value multiply with
  3420. * @param z z value multiply with
  3421. * @param w w value multiply with
  3422. * @returns resulting new vector
  3423. */
  3424. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3427. * @param otherVector vector to devide with
  3428. * @returns resulting new vector
  3429. */
  3430. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3431. /**
  3432. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3433. * @param otherVector vector to devide with
  3434. * @param result vector to store the result
  3435. * @returns the current Vector4.
  3436. */
  3437. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3438. /**
  3439. * Divides the current Vector3 coordinates by the given ones.
  3440. * @param otherVector vector to devide with
  3441. * @returns the updated Vector3.
  3442. */
  3443. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3446. * @param other defines the second operand
  3447. * @returns the current updated Vector4
  3448. */
  3449. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3452. * @param other defines the second operand
  3453. * @returns the current updated Vector4
  3454. */
  3455. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3456. /**
  3457. * Gets a new Vector4 from current Vector4 floored values
  3458. * @returns a new Vector4
  3459. */
  3460. floor(): Vector4;
  3461. /**
  3462. * Gets a new Vector4 from current Vector3 floored values
  3463. * @returns a new Vector4
  3464. */
  3465. fract(): Vector4;
  3466. /**
  3467. * Returns the Vector4 length (float).
  3468. * @returns the length
  3469. */
  3470. length(): number;
  3471. /**
  3472. * Returns the Vector4 squared length (float).
  3473. * @returns the length squared
  3474. */
  3475. lengthSquared(): number;
  3476. /**
  3477. * Normalizes in place the Vector4.
  3478. * @returns the updated Vector4.
  3479. */
  3480. normalize(): Vector4;
  3481. /**
  3482. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3483. * @returns this converted to a new vector3
  3484. */
  3485. toVector3(): Vector3;
  3486. /**
  3487. * Returns a new Vector4 copied from the current one.
  3488. * @returns the new cloned vector
  3489. */
  3490. clone(): Vector4;
  3491. /**
  3492. * Updates the current Vector4 with the given one coordinates.
  3493. * @param source the source vector to copy from
  3494. * @returns the updated Vector4.
  3495. */
  3496. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Updates the current Vector4 coordinates with the given floats.
  3499. * @param x float to copy from
  3500. * @param y float to copy from
  3501. * @param z float to copy from
  3502. * @param w float to copy from
  3503. * @returns the updated Vector4.
  3504. */
  3505. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3506. /**
  3507. * Updates the current Vector4 coordinates with the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @returns the updated Vector4.
  3513. */
  3514. set(x: number, y: number, z: number, w: number): Vector4;
  3515. /**
  3516. * Copies the given float to the current Vector3 coordinates
  3517. * @param v defines the x, y, z and w coordinates of the operand
  3518. * @returns the current updated Vector3
  3519. */
  3520. setAll(v: number): Vector4;
  3521. /**
  3522. * Returns a new Vector4 set from the starting index of the given array.
  3523. * @param array the array to pull values from
  3524. * @param offset the offset into the array to start at
  3525. * @returns the new vector
  3526. */
  3527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3528. /**
  3529. * Updates the given vector "result" from the starting index of the given array.
  3530. * @param array the array to pull values from
  3531. * @param offset the offset into the array to start at
  3532. * @param result the vector to store the result in
  3533. */
  3534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3535. /**
  3536. * Updates the given vector "result" from the starting index of the given Float32Array.
  3537. * @param array the array to pull values from
  3538. * @param offset the offset into the array to start at
  3539. * @param result the vector to store the result in
  3540. */
  3541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3542. /**
  3543. * Updates the given vector "result" coordinates from the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @param result the vector to the floats in
  3549. */
  3550. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3551. /**
  3552. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3553. * @returns the new vector
  3554. */
  3555. static Zero(): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3558. * @returns the new vector
  3559. */
  3560. static One(): Vector4;
  3561. /**
  3562. * Returns a new normalized Vector4 from the given one.
  3563. * @param vector the vector to normalize
  3564. * @returns the vector
  3565. */
  3566. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the normalization of the given one.
  3569. * @param vector the vector to normalize
  3570. * @param result the vector to store the result in
  3571. */
  3572. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3573. /**
  3574. * Returns a vector with the minimum values from the left and right vectors
  3575. * @param left left vector to minimize
  3576. * @param right right vector to minimize
  3577. * @returns a new vector with the minimum of the left and right vector values
  3578. */
  3579. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3580. /**
  3581. * Returns a vector with the maximum values from the left and right vectors
  3582. * @param left left vector to maximize
  3583. * @param right right vector to maximize
  3584. * @returns a new vector with the maximum of the left and right vector values
  3585. */
  3586. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns the distance (float) between the vectors "value1" and "value2".
  3589. * @param value1 value to calulate the distance between
  3590. * @param value2 value to calulate the distance between
  3591. * @return the distance between the two vectors
  3592. */
  3593. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3594. /**
  3595. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3596. * @param value1 value to calulate the distance between
  3597. * @param value2 value to calulate the distance between
  3598. * @return the distance between the two vectors squared
  3599. */
  3600. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3601. /**
  3602. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3603. * @param value1 value to calulate the center between
  3604. * @param value2 value to calulate the center between
  3605. * @return the center between the two vectors
  3606. */
  3607. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param vector the vector to transform
  3612. * @param transformation the transformation matrix to apply
  3613. * @returns the new vector
  3614. */
  3615. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3616. /**
  3617. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3618. * This methods computes transformed normalized direction vectors only.
  3619. * @param vector the vector to transform
  3620. * @param transformation the transformation matrix to apply
  3621. * @param result the vector to store the result in
  3622. */
  3623. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3624. /**
  3625. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3626. * This methods computes transformed normalized direction vectors only.
  3627. * @param x value to transform
  3628. * @param y value to transform
  3629. * @param z value to transform
  3630. * @param w value to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @param result the vector to store the results in
  3633. */
  3634. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3635. /**
  3636. * Creates a new Vector4 from a Vector3
  3637. * @param source defines the source data
  3638. * @param w defines the 4th component (default is 0)
  3639. * @returns a new Vector4
  3640. */
  3641. static FromVector3(source: Vector3, w?: number): Vector4;
  3642. }
  3643. /**
  3644. * Class used to store quaternion data
  3645. * @see https://en.wikipedia.org/wiki/Quaternion
  3646. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3647. */
  3648. export class Quaternion {
  3649. /** @hidden */
  3650. _x: number;
  3651. /** @hidden */
  3652. _y: number;
  3653. /** @hidden */
  3654. _z: number;
  3655. /** @hidden */
  3656. _w: number;
  3657. /** @hidden */
  3658. _isDirty: boolean;
  3659. /** Gets or sets the x coordinate */
  3660. get x(): number;
  3661. set x(value: number);
  3662. /** Gets or sets the y coordinate */
  3663. get y(): number;
  3664. set y(value: number);
  3665. /** Gets or sets the z coordinate */
  3666. get z(): number;
  3667. set z(value: number);
  3668. /** Gets or sets the w coordinate */
  3669. get w(): number;
  3670. set w(value: number);
  3671. /**
  3672. * Creates a new Quaternion from the given floats
  3673. * @param x defines the first component (0 by default)
  3674. * @param y defines the second component (0 by default)
  3675. * @param z defines the third component (0 by default)
  3676. * @param w defines the fourth component (1.0 by default)
  3677. */
  3678. constructor(x?: number, y?: number, z?: number, w?: number);
  3679. /**
  3680. * Gets a string representation for the current quaternion
  3681. * @returns a string with the Quaternion coordinates
  3682. */
  3683. toString(): string;
  3684. /**
  3685. * Gets the class name of the quaternion
  3686. * @returns the string "Quaternion"
  3687. */
  3688. getClassName(): string;
  3689. /**
  3690. * Gets a hash code for this quaternion
  3691. * @returns the quaternion hash code
  3692. */
  3693. getHashCode(): number;
  3694. /**
  3695. * Copy the quaternion to an array
  3696. * @returns a new array populated with 4 elements from the quaternion coordinates
  3697. */
  3698. asArray(): number[];
  3699. /**
  3700. * Check if two quaternions are equals
  3701. * @param otherQuaternion defines the second operand
  3702. * @return true if the current quaternion and the given one coordinates are strictly equals
  3703. */
  3704. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3705. /**
  3706. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3707. * @param otherQuaternion defines the other quaternion
  3708. * @param epsilon defines the minimal distance to consider equality
  3709. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3710. */
  3711. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3712. /**
  3713. * Clone the current quaternion
  3714. * @returns a new quaternion copied from the current one
  3715. */
  3716. clone(): Quaternion;
  3717. /**
  3718. * Copy a quaternion to the current one
  3719. * @param other defines the other quaternion
  3720. * @returns the updated current quaternion
  3721. */
  3722. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Updates the current quaternion with the given float coordinates
  3725. * @param x defines the x coordinate
  3726. * @param y defines the y coordinate
  3727. * @param z defines the z coordinate
  3728. * @param w defines the w coordinate
  3729. * @returns the updated current quaternion
  3730. */
  3731. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3732. /**
  3733. * Updates the current quaternion from the given float coordinates
  3734. * @param x defines the x coordinate
  3735. * @param y defines the y coordinate
  3736. * @param z defines the z coordinate
  3737. * @param w defines the w coordinate
  3738. * @returns the updated current quaternion
  3739. */
  3740. set(x: number, y: number, z: number, w: number): Quaternion;
  3741. /**
  3742. * Adds two quaternions
  3743. * @param other defines the second operand
  3744. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3745. */
  3746. add(other: DeepImmutable<Quaternion>): Quaternion;
  3747. /**
  3748. * Add a quaternion to the current one
  3749. * @param other defines the quaternion to add
  3750. * @returns the current quaternion
  3751. */
  3752. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3753. /**
  3754. * Subtract two quaternions
  3755. * @param other defines the second operand
  3756. * @returns a new quaternion as the subtraction result of the given one from the current one
  3757. */
  3758. subtract(other: Quaternion): Quaternion;
  3759. /**
  3760. * Multiplies the current quaternion by a scale factor
  3761. * @param value defines the scale factor
  3762. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3763. */
  3764. scale(value: number): Quaternion;
  3765. /**
  3766. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3767. * @param scale defines the scale factor
  3768. * @param result defines the Quaternion object where to store the result
  3769. * @returns the unmodified current quaternion
  3770. */
  3771. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Multiplies in place the current quaternion by a scale factor
  3774. * @param value defines the scale factor
  3775. * @returns the current modified quaternion
  3776. */
  3777. scaleInPlace(value: number): Quaternion;
  3778. /**
  3779. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3780. * @param scale defines the scale factor
  3781. * @param result defines the Quaternion object where to store the result
  3782. * @returns the unmodified current quaternion
  3783. */
  3784. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3785. /**
  3786. * Multiplies two quaternions
  3787. * @param q1 defines the second operand
  3788. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3789. */
  3790. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3791. /**
  3792. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3793. * @param q1 defines the second operand
  3794. * @param result defines the target quaternion
  3795. * @returns the current quaternion
  3796. */
  3797. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3800. * @param q1 defines the second operand
  3801. * @returns the currentupdated quaternion
  3802. */
  3803. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3804. /**
  3805. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3806. * @param ref defines the target quaternion
  3807. * @returns the current quaternion
  3808. */
  3809. conjugateToRef(ref: Quaternion): Quaternion;
  3810. /**
  3811. * Conjugates in place (1-q) the current quaternion
  3812. * @returns the current updated quaternion
  3813. */
  3814. conjugateInPlace(): Quaternion;
  3815. /**
  3816. * Conjugates in place (1-q) the current quaternion
  3817. * @returns a new quaternion
  3818. */
  3819. conjugate(): Quaternion;
  3820. /**
  3821. * Gets length of current quaternion
  3822. * @returns the quaternion length (float)
  3823. */
  3824. length(): number;
  3825. /**
  3826. * Normalize in place the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. normalize(): Quaternion;
  3830. /**
  3831. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3832. * @param order is a reserved parameter and is ignore for now
  3833. * @returns a new Vector3 containing the Euler angles
  3834. */
  3835. toEulerAngles(order?: string): Vector3;
  3836. /**
  3837. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3838. * @param result defines the vector which will be filled with the Euler angles
  3839. * @param order is a reserved parameter and is ignore for now
  3840. * @returns the current unchanged quaternion
  3841. */
  3842. toEulerAnglesToRef(result: Vector3): Quaternion;
  3843. /**
  3844. * Updates the given rotation matrix with the current quaternion values
  3845. * @param result defines the target matrix
  3846. * @returns the current unchanged quaternion
  3847. */
  3848. toRotationMatrix(result: Matrix): Quaternion;
  3849. /**
  3850. * Updates the current quaternion from the given rotation matrix values
  3851. * @param matrix defines the source matrix
  3852. * @returns the current updated quaternion
  3853. */
  3854. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3855. /**
  3856. * Creates a new quaternion from a rotation matrix
  3857. * @param matrix defines the source matrix
  3858. * @returns a new quaternion created from the given rotation matrix values
  3859. */
  3860. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3861. /**
  3862. * Updates the given quaternion with the given rotation matrix values
  3863. * @param matrix defines the source matrix
  3864. * @param result defines the target quaternion
  3865. */
  3866. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3867. /**
  3868. * Returns the dot product (float) between the quaternions "left" and "right"
  3869. * @param left defines the left operand
  3870. * @param right defines the right operand
  3871. * @returns the dot product
  3872. */
  3873. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3874. /**
  3875. * Checks if the two quaternions are close to each other
  3876. * @param quat0 defines the first quaternion to check
  3877. * @param quat1 defines the second quaternion to check
  3878. * @returns true if the two quaternions are close to each other
  3879. */
  3880. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3881. /**
  3882. * Creates an empty quaternion
  3883. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3884. */
  3885. static Zero(): Quaternion;
  3886. /**
  3887. * Inverse a given quaternion
  3888. * @param q defines the source quaternion
  3889. * @returns a new quaternion as the inverted current quaternion
  3890. */
  3891. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3892. /**
  3893. * Inverse a given quaternion
  3894. * @param q defines the source quaternion
  3895. * @param result the quaternion the result will be stored in
  3896. * @returns the result quaternion
  3897. */
  3898. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3899. /**
  3900. * Creates an identity quaternion
  3901. * @returns the identity quaternion
  3902. */
  3903. static Identity(): Quaternion;
  3904. /**
  3905. * Gets a boolean indicating if the given quaternion is identity
  3906. * @param quaternion defines the quaternion to check
  3907. * @returns true if the quaternion is identity
  3908. */
  3909. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3910. /**
  3911. * Creates a quaternion from a rotation around an axis
  3912. * @param axis defines the axis to use
  3913. * @param angle defines the angle to use
  3914. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3915. */
  3916. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3917. /**
  3918. * Creates a rotation around an axis and stores it into the given quaternion
  3919. * @param axis defines the axis to use
  3920. * @param angle defines the angle to use
  3921. * @param result defines the target quaternion
  3922. * @returns the target quaternion
  3923. */
  3924. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3925. /**
  3926. * Creates a new quaternion from data stored into an array
  3927. * @param array defines the data source
  3928. * @param offset defines the offset in the source array where the data starts
  3929. * @returns a new quaternion
  3930. */
  3931. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3932. /**
  3933. * Updates the given quaternion "result" from the starting index of the given array.
  3934. * @param array the array to pull values from
  3935. * @param offset the offset into the array to start at
  3936. * @param result the quaternion to store the result in
  3937. */
  3938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3939. /**
  3940. * Create a quaternion from Euler rotation angles
  3941. * @param x Pitch
  3942. * @param y Yaw
  3943. * @param z Roll
  3944. * @returns the new Quaternion
  3945. */
  3946. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3947. /**
  3948. * Updates a quaternion from Euler rotation angles
  3949. * @param x Pitch
  3950. * @param y Yaw
  3951. * @param z Roll
  3952. * @param result the quaternion to store the result
  3953. * @returns the updated quaternion
  3954. */
  3955. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3956. /**
  3957. * Create a quaternion from Euler rotation vector
  3958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation vector
  3964. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3965. * @param result the quaternion to store the result
  3966. * @returns the updated quaternion
  3967. */
  3968. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3971. * @param yaw defines the rotation around Y axis
  3972. * @param pitch defines the rotation around X axis
  3973. * @param roll defines the rotation around Z axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3977. /**
  3978. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3979. * @param yaw defines the rotation around Y axis
  3980. * @param pitch defines the rotation around X axis
  3981. * @param roll defines the rotation around Z axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3987. * @param alpha defines the rotation around first axis
  3988. * @param beta defines the rotation around second axis
  3989. * @param gamma defines the rotation around third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3993. /**
  3994. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3995. * @param alpha defines the rotation around first axis
  3996. * @param beta defines the rotation around second axis
  3997. * @param gamma defines the rotation around third axis
  3998. * @param result defines the target quaternion
  3999. */
  4000. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4001. /**
  4002. * 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)
  4003. * @param axis1 defines the first axis
  4004. * @param axis2 defines the second axis
  4005. * @param axis3 defines the third axis
  4006. * @returns the new quaternion
  4007. */
  4008. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4009. /**
  4010. * 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
  4011. * @param axis1 defines the first axis
  4012. * @param axis2 defines the second axis
  4013. * @param axis3 defines the third axis
  4014. * @param ref defines the target quaternion
  4015. */
  4016. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4017. /**
  4018. * Interpolates between two quaternions
  4019. * @param left defines first quaternion
  4020. * @param right defines second quaternion
  4021. * @param amount defines the gradient to use
  4022. * @returns the new interpolated quaternion
  4023. */
  4024. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4025. /**
  4026. * Interpolates between two quaternions and stores it into a target quaternion
  4027. * @param left defines first quaternion
  4028. * @param right defines second quaternion
  4029. * @param amount defines the gradient to use
  4030. * @param result defines the target quaternion
  4031. */
  4032. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4033. /**
  4034. * Interpolate between two quaternions using Hermite interpolation
  4035. * @param value1 defines first quaternion
  4036. * @param tangent1 defines the incoming tangent
  4037. * @param value2 defines second quaternion
  4038. * @param tangent2 defines the outgoing tangent
  4039. * @param amount defines the target quaternion
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. }
  4044. /**
  4045. * Class used to store matrix data (4x4)
  4046. */
  4047. export class Matrix {
  4048. /**
  4049. * Gets the precision of matrix computations
  4050. */
  4051. static get Use64Bits(): boolean;
  4052. private static _updateFlagSeed;
  4053. private static _identityReadOnly;
  4054. private _isIdentity;
  4055. private _isIdentityDirty;
  4056. private _isIdentity3x2;
  4057. private _isIdentity3x2Dirty;
  4058. /**
  4059. * Gets the update flag of the matrix which is an unique number for the matrix.
  4060. * It will be incremented every time the matrix data change.
  4061. * You can use it to speed the comparison between two versions of the same matrix.
  4062. */
  4063. updateFlag: number;
  4064. private readonly _m;
  4065. /**
  4066. * Gets the internal data of the matrix
  4067. */
  4068. get m(): DeepImmutable<Float32Array | Array<number>>;
  4069. /** @hidden */
  4070. _markAsUpdated(): void;
  4071. /** @hidden */
  4072. private _updateIdentityStatus;
  4073. /**
  4074. * Creates an empty matrix (filled with zeros)
  4075. */
  4076. constructor();
  4077. /**
  4078. * Check if the current matrix is identity
  4079. * @returns true is the matrix is the identity matrix
  4080. */
  4081. isIdentity(): boolean;
  4082. /**
  4083. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4084. * @returns true is the matrix is the identity matrix
  4085. */
  4086. isIdentityAs3x2(): boolean;
  4087. /**
  4088. * Gets the determinant of the matrix
  4089. * @returns the matrix determinant
  4090. */
  4091. determinant(): number;
  4092. /**
  4093. * Returns the matrix as a Float32Array or Array<number>
  4094. * @returns the matrix underlying array
  4095. */
  4096. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4097. /**
  4098. * Returns the matrix as a Float32Array or Array<number>
  4099. * @returns the matrix underlying array.
  4100. */
  4101. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4102. /**
  4103. * Inverts the current matrix in place
  4104. * @returns the current inverted matrix
  4105. */
  4106. invert(): Matrix;
  4107. /**
  4108. * Sets all the matrix elements to zero
  4109. * @returns the current matrix
  4110. */
  4111. reset(): Matrix;
  4112. /**
  4113. * Adds the current matrix with a second one
  4114. * @param other defines the matrix to add
  4115. * @returns a new matrix as the addition of the current matrix and the given one
  4116. */
  4117. add(other: DeepImmutable<Matrix>): Matrix;
  4118. /**
  4119. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4120. * @param other defines the matrix to add
  4121. * @param result defines the target matrix
  4122. * @returns the current matrix
  4123. */
  4124. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4125. /**
  4126. * Adds in place the given matrix to the current matrix
  4127. * @param other defines the second operand
  4128. * @returns the current updated matrix
  4129. */
  4130. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Sets the given matrix to the current inverted Matrix
  4133. * @param other defines the target matrix
  4134. * @returns the unmodified current matrix
  4135. */
  4136. invertToRef(other: Matrix): Matrix;
  4137. /**
  4138. * add a value at the specified position in the current Matrix
  4139. * @param index the index of the value within the matrix. between 0 and 15.
  4140. * @param value the value to be added
  4141. * @returns the current updated matrix
  4142. */
  4143. addAtIndex(index: number, value: number): Matrix;
  4144. /**
  4145. * mutiply the specified position in the current Matrix by a value
  4146. * @param index the index of the value within the matrix. between 0 and 15.
  4147. * @param value the value to be added
  4148. * @returns the current updated matrix
  4149. */
  4150. multiplyAtIndex(index: number, value: number): Matrix;
  4151. /**
  4152. * Inserts the translation vector (using 3 floats) in the current matrix
  4153. * @param x defines the 1st component of the translation
  4154. * @param y defines the 2nd component of the translation
  4155. * @param z defines the 3rd component of the translation
  4156. * @returns the current updated matrix
  4157. */
  4158. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4159. /**
  4160. * Adds the translation vector (using 3 floats) in the current matrix
  4161. * @param x defines the 1st component of the translation
  4162. * @param y defines the 2nd component of the translation
  4163. * @param z defines the 3rd component of the translation
  4164. * @returns the current updated matrix
  4165. */
  4166. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4167. /**
  4168. * Inserts the translation vector in the current matrix
  4169. * @param vector3 defines the translation to insert
  4170. * @returns the current updated matrix
  4171. */
  4172. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4173. /**
  4174. * Gets the translation value of the current matrix
  4175. * @returns a new Vector3 as the extracted translation from the matrix
  4176. */
  4177. getTranslation(): Vector3;
  4178. /**
  4179. * Fill a Vector3 with the extracted translation from the matrix
  4180. * @param result defines the Vector3 where to store the translation
  4181. * @returns the current matrix
  4182. */
  4183. getTranslationToRef(result: Vector3): Matrix;
  4184. /**
  4185. * Remove rotation and scaling part from the matrix
  4186. * @returns the updated matrix
  4187. */
  4188. removeRotationAndScaling(): Matrix;
  4189. /**
  4190. * Multiply two matrices
  4191. * @param other defines the second operand
  4192. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4193. */
  4194. multiply(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Copy the current matrix from the given one
  4197. * @param other defines the source matrix
  4198. * @returns the current updated matrix
  4199. */
  4200. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Populates the given array from the starting index with the current matrix values
  4203. * @param array defines the target array
  4204. * @param offset defines the offset in the target array where to start storing values
  4205. * @returns the current matrix
  4206. */
  4207. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4208. /**
  4209. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4210. * @param other defines the second operand
  4211. * @param result defines the matrix where to store the multiplication
  4212. * @returns the current matrix
  4213. */
  4214. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4215. /**
  4216. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4217. * @param other defines the second operand
  4218. * @param result defines the array where to store the multiplication
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4223. /**
  4224. * Check equality between this matrix and a second one
  4225. * @param value defines the second matrix to compare
  4226. * @returns true is the current matrix and the given one values are strictly equal
  4227. */
  4228. equals(value: DeepImmutable<Matrix>): boolean;
  4229. /**
  4230. * Clone the current matrix
  4231. * @returns a new matrix from the current matrix
  4232. */
  4233. clone(): Matrix;
  4234. /**
  4235. * Returns the name of the current matrix class
  4236. * @returns the string "Matrix"
  4237. */
  4238. getClassName(): string;
  4239. /**
  4240. * Gets the hash code of the current matrix
  4241. * @returns the hash code
  4242. */
  4243. getHashCode(): number;
  4244. /**
  4245. * Decomposes the current Matrix into a translation, rotation and scaling components
  4246. * @param scale defines the scale vector3 given as a reference to update
  4247. * @param rotation defines the rotation quaternion given as a reference to update
  4248. * @param translation defines the translation vector3 given as a reference to update
  4249. * @returns true if operation was successful
  4250. */
  4251. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4252. /**
  4253. * Gets specific row of the matrix
  4254. * @param index defines the number of the row to get
  4255. * @returns the index-th row of the current matrix as a new Vector4
  4256. */
  4257. getRow(index: number): Nullable<Vector4>;
  4258. /**
  4259. * Sets the index-th row of the current matrix to the vector4 values
  4260. * @param index defines the number of the row to set
  4261. * @param row defines the target vector4
  4262. * @returns the updated current matrix
  4263. */
  4264. setRow(index: number, row: Vector4): Matrix;
  4265. /**
  4266. * Compute the transpose of the matrix
  4267. * @returns the new transposed matrix
  4268. */
  4269. transpose(): Matrix;
  4270. /**
  4271. * Compute the transpose of the matrix and store it in a given matrix
  4272. * @param result defines the target matrix
  4273. * @returns the current matrix
  4274. */
  4275. transposeToRef(result: Matrix): Matrix;
  4276. /**
  4277. * Sets the index-th row of the current matrix with the given 4 x float values
  4278. * @param index defines the row index
  4279. * @param x defines the x component to set
  4280. * @param y defines the y component to set
  4281. * @param z defines the z component to set
  4282. * @param w defines the w component to set
  4283. * @returns the updated current matrix
  4284. */
  4285. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4286. /**
  4287. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4288. * @param scale defines the scale factor
  4289. * @returns a new matrix
  4290. */
  4291. scale(scale: number): Matrix;
  4292. /**
  4293. * Scale the current matrix values by a factor to a given result matrix
  4294. * @param scale defines the scale factor
  4295. * @param result defines the matrix to store the result
  4296. * @returns the current matrix
  4297. */
  4298. scaleToRef(scale: number, result: Matrix): Matrix;
  4299. /**
  4300. * Scale the current matrix values by a factor and add the result to a given matrix
  4301. * @param scale defines the scale factor
  4302. * @param result defines the Matrix to store the result
  4303. * @returns the current matrix
  4304. */
  4305. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4306. /**
  4307. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4308. * @param ref matrix to store the result
  4309. */
  4310. toNormalMatrix(ref: Matrix): void;
  4311. /**
  4312. * Gets only rotation part of the current matrix
  4313. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4314. */
  4315. getRotationMatrix(): Matrix;
  4316. /**
  4317. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4318. * @param result defines the target matrix to store data to
  4319. * @returns the current matrix
  4320. */
  4321. getRotationMatrixToRef(result: Matrix): Matrix;
  4322. /**
  4323. * Toggles model matrix from being right handed to left handed in place and vice versa
  4324. */
  4325. toggleModelMatrixHandInPlace(): void;
  4326. /**
  4327. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4328. */
  4329. toggleProjectionMatrixHandInPlace(): void;
  4330. /**
  4331. * Creates a matrix from an array
  4332. * @param array defines the source array
  4333. * @param offset defines an offset in the source array
  4334. * @returns a new Matrix set from the starting index of the given array
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4337. /**
  4338. * Copy the content of an array into a given matrix
  4339. * @param array defines the source array
  4340. * @param offset defines an offset in the source array
  4341. * @param result defines the target matrix
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4344. /**
  4345. * Stores an array into a matrix after having multiplied each component by a given factor
  4346. * @param array defines the source array
  4347. * @param offset defines the offset in the source array
  4348. * @param scale defines the scaling factor
  4349. * @param result defines the target matrix
  4350. */
  4351. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4352. /**
  4353. * Gets an identity matrix that must not be updated
  4354. */
  4355. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4356. /**
  4357. * Stores a list of values (16) inside a given matrix
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @param result defines the target matrix
  4375. */
  4376. 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;
  4377. /**
  4378. * Creates new matrix from a list of values (16)
  4379. * @param initialM11 defines 1st value of 1st row
  4380. * @param initialM12 defines 2nd value of 1st row
  4381. * @param initialM13 defines 3rd value of 1st row
  4382. * @param initialM14 defines 4th value of 1st row
  4383. * @param initialM21 defines 1st value of 2nd row
  4384. * @param initialM22 defines 2nd value of 2nd row
  4385. * @param initialM23 defines 3rd value of 2nd row
  4386. * @param initialM24 defines 4th value of 2nd row
  4387. * @param initialM31 defines 1st value of 3rd row
  4388. * @param initialM32 defines 2nd value of 3rd row
  4389. * @param initialM33 defines 3rd value of 3rd row
  4390. * @param initialM34 defines 4th value of 3rd row
  4391. * @param initialM41 defines 1st value of 4th row
  4392. * @param initialM42 defines 2nd value of 4th row
  4393. * @param initialM43 defines 3rd value of 4th row
  4394. * @param initialM44 defines 4th value of 4th row
  4395. * @returns the new matrix
  4396. */
  4397. 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;
  4398. /**
  4399. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4400. * @param scale defines the scale vector3
  4401. * @param rotation defines the rotation quaternion
  4402. * @param translation defines the translation vector3
  4403. * @returns a new matrix
  4404. */
  4405. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4408. * @param scale defines the scale vector3
  4409. * @param rotation defines the rotation quaternion
  4410. * @param translation defines the translation vector3
  4411. * @param result defines the target matrix
  4412. */
  4413. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4414. /**
  4415. * Creates a new identity matrix
  4416. * @returns a new identity matrix
  4417. */
  4418. static Identity(): Matrix;
  4419. /**
  4420. * Creates a new identity matrix and stores the result in a given matrix
  4421. * @param result defines the target matrix
  4422. */
  4423. static IdentityToRef(result: Matrix): void;
  4424. /**
  4425. * Creates a new zero matrix
  4426. * @returns a new zero matrix
  4427. */
  4428. static Zero(): Matrix;
  4429. /**
  4430. * Creates a new rotation matrix for "angle" radians around the X axis
  4431. * @param angle defines the angle (in radians) to use
  4432. * @return the new matrix
  4433. */
  4434. static RotationX(angle: number): Matrix;
  4435. /**
  4436. * Creates a new matrix as the invert of a given matrix
  4437. * @param source defines the source matrix
  4438. * @returns the new matrix
  4439. */
  4440. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4441. /**
  4442. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4443. * @param angle defines the angle (in radians) to use
  4444. * @param result defines the target matrix
  4445. */
  4446. static RotationXToRef(angle: number, result: Matrix): void;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the Y axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationY(angle: number): Matrix;
  4453. /**
  4454. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4455. * @param angle defines the angle (in radians) to use
  4456. * @param result defines the target matrix
  4457. */
  4458. static RotationYToRef(angle: number, result: Matrix): void;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the Z axis
  4461. * @param angle defines the angle (in radians) to use
  4462. * @return the new matrix
  4463. */
  4464. static RotationZ(angle: number): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4467. * @param angle defines the angle (in radians) to use
  4468. * @param result defines the target matrix
  4469. */
  4470. static RotationZToRef(angle: number, result: Matrix): void;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the given axis
  4473. * @param axis defines the axis to use
  4474. * @param angle defines the angle (in radians) to use
  4475. * @return the new matrix
  4476. */
  4477. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4478. /**
  4479. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4480. * @param axis defines the axis to use
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4485. /**
  4486. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4487. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4488. * @param from defines the vector to align
  4489. * @param to defines the vector to align to
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4493. /**
  4494. * Creates a rotation matrix
  4495. * @param yaw defines the yaw angle in radians (Y axis)
  4496. * @param pitch defines the pitch angle in radians (X axis)
  4497. * @param roll defines the roll angle in radians (Z axis)
  4498. * @returns the new rotation matrix
  4499. */
  4500. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4501. /**
  4502. * Creates a rotation matrix and stores it in a given matrix
  4503. * @param yaw defines the yaw angle in radians (Y axis)
  4504. * @param pitch defines the pitch angle in radians (X axis)
  4505. * @param roll defines the roll angle in radians (Z axis)
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4509. /**
  4510. * Creates a scaling matrix
  4511. * @param x defines the scale factor on X axis
  4512. * @param y defines the scale factor on Y axis
  4513. * @param z defines the scale factor on Z axis
  4514. * @returns the new matrix
  4515. */
  4516. static Scaling(x: number, y: number, z: number): Matrix;
  4517. /**
  4518. * Creates a scaling matrix and stores it in a given matrix
  4519. * @param x defines the scale factor on X axis
  4520. * @param y defines the scale factor on Y axis
  4521. * @param z defines the scale factor on Z axis
  4522. * @param result defines the target matrix
  4523. */
  4524. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4525. /**
  4526. * Creates a translation matrix
  4527. * @param x defines the translation on X axis
  4528. * @param y defines the translation on Y axis
  4529. * @param z defines the translationon Z axis
  4530. * @returns the new matrix
  4531. */
  4532. static Translation(x: number, y: number, z: number): Matrix;
  4533. /**
  4534. * Creates a translation matrix and stores it in a given matrix
  4535. * @param x defines the translation on X axis
  4536. * @param y defines the translation on Y axis
  4537. * @param z defines the translationon Z axis
  4538. * @param result defines the target matrix
  4539. */
  4540. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4541. /**
  4542. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4543. * @param startValue defines the start value
  4544. * @param endValue defines the end value
  4545. * @param gradient defines the gradient factor
  4546. * @returns the new matrix
  4547. */
  4548. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4549. /**
  4550. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4551. * @param startValue defines the start value
  4552. * @param endValue defines the end value
  4553. * @param gradient defines the gradient factor
  4554. * @param result defines the Matrix object where to store data
  4555. */
  4556. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4557. /**
  4558. * Builds a new matrix whose values are computed by:
  4559. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4560. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4561. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4562. * @param startValue defines the first matrix
  4563. * @param endValue defines the second matrix
  4564. * @param gradient defines the gradient between the two matrices
  4565. * @returns the new matrix
  4566. */
  4567. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4568. /**
  4569. * Update a matrix to values which are computed by:
  4570. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4571. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4572. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4573. * @param startValue defines the first matrix
  4574. * @param endValue defines the second matrix
  4575. * @param gradient defines the gradient between the two matrices
  4576. * @param result defines the target matrix
  4577. */
  4578. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * 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"
  4581. * This function works in left handed mode
  4582. * @param eye defines the final position of the entity
  4583. * @param target defines where the entity should look at
  4584. * @param up defines the up vector for the entity
  4585. * @returns the new matrix
  4586. */
  4587. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4588. /**
  4589. * 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".
  4590. * This function works in left handed mode
  4591. * @param eye defines the final position of the entity
  4592. * @param target defines where the entity should look at
  4593. * @param up defines the up vector for the entity
  4594. * @param result defines the target matrix
  4595. */
  4596. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4597. /**
  4598. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4599. * This function works in right handed mode
  4600. * @param eye defines the final position of the entity
  4601. * @param target defines where the entity should look at
  4602. * @param up defines the up vector for the entity
  4603. * @returns the new matrix
  4604. */
  4605. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4606. /**
  4607. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4608. * This function works in right handed mode
  4609. * @param eye defines the final position of the entity
  4610. * @param target defines where the entity should look at
  4611. * @param up defines the up vector for the entity
  4612. * @param result defines the target matrix
  4613. */
  4614. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * Create a left-handed orthographic projection matrix
  4617. * @param width defines the viewport width
  4618. * @param height defines the viewport height
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Store a left-handed orthographic projection to a given matrix
  4626. * @param width defines the viewport width
  4627. * @param height defines the viewport height
  4628. * @param znear defines the near clip plane
  4629. * @param zfar defines the far clip plane
  4630. * @param result defines the target matrix
  4631. */
  4632. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param left defines the viewport left coordinate
  4636. * @param right defines the viewport right coordinate
  4637. * @param bottom defines the viewport bottom coordinate
  4638. * @param top defines the viewport top coordinate
  4639. * @param znear defines the near clip plane
  4640. * @param zfar defines the far clip plane
  4641. * @returns a new matrix as a left-handed orthographic projection matrix
  4642. */
  4643. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4644. /**
  4645. * Stores a left-handed orthographic projection into a given matrix
  4646. * @param left defines the viewport left coordinate
  4647. * @param right defines the viewport right coordinate
  4648. * @param bottom defines the viewport bottom coordinate
  4649. * @param top defines the viewport top coordinate
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @param result defines the target matrix
  4653. */
  4654. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Creates a right-handed orthographic projection matrix
  4657. * @param left defines the viewport left coordinate
  4658. * @param right defines the viewport right coordinate
  4659. * @param bottom defines the viewport bottom coordinate
  4660. * @param top defines the viewport top coordinate
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a right-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a right-handed orthographic projection into a given matrix
  4668. * @param left defines the viewport left coordinate
  4669. * @param right defines the viewport right coordinate
  4670. * @param bottom defines the viewport bottom coordinate
  4671. * @param top defines the viewport top coordinate
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. */
  4676. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a left-handed perspective projection matrix
  4679. * @param width defines the viewport width
  4680. * @param height defines the viewport height
  4681. * @param znear defines the near clip plane
  4682. * @param zfar defines the far clip plane
  4683. * @returns a new matrix as a left-handed perspective projection matrix
  4684. */
  4685. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4686. /**
  4687. * Creates a left-handed perspective projection matrix
  4688. * @param fov defines the horizontal field of view
  4689. * @param aspect defines the aspect ratio
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @returns a new matrix as a left-handed perspective projection matrix
  4693. */
  4694. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4695. /**
  4696. * Stores a left-handed perspective projection into a given matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @param result defines the target matrix
  4702. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4703. */
  4704. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4705. /**
  4706. * Stores a left-handed perspective projection into a given matrix with depth reversed
  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 not used as infinity is used as far clip
  4711. * @param result defines the target matrix
  4712. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4713. */
  4714. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4715. /**
  4716. * Creates a right-handed perspective projection matrix
  4717. * @param fov defines the horizontal field of view
  4718. * @param aspect defines the aspect ratio
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed perspective projection matrix
  4722. */
  4723. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed perspective projection into a given matrix
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4732. */
  4733. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4734. /**
  4735. * Stores a right-handed perspective projection into a given 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 not used as infinity is used as far clip
  4740. * @param result defines the target matrix
  4741. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4742. */
  4743. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4744. /**
  4745. * Stores a perspective projection for WebVR info a given matrix
  4746. * @param fov defines the field of view
  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 rightHanded defines if the matrix must be in right-handed mode (false by default)
  4751. */
  4752. static PerspectiveFovWebVRToRef(fov: {
  4753. upDegrees: number;
  4754. downDegrees: number;
  4755. leftDegrees: number;
  4756. rightDegrees: number;
  4757. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4758. /**
  4759. * Computes a complete transformation matrix
  4760. * @param viewport defines the viewport to use
  4761. * @param world defines the world matrix
  4762. * @param view defines the view matrix
  4763. * @param projection defines the projection matrix
  4764. * @param zmin defines the near clip plane
  4765. * @param zmax defines the far clip plane
  4766. * @returns the transformation matrix
  4767. */
  4768. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4769. /**
  4770. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4771. * @param matrix defines the matrix to use
  4772. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4773. */
  4774. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4775. /**
  4776. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4777. * @param matrix defines the matrix to use
  4778. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4779. */
  4780. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4781. /**
  4782. * Compute the transpose of a given matrix
  4783. * @param matrix defines the matrix to transpose
  4784. * @returns the new matrix
  4785. */
  4786. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4787. /**
  4788. * Compute the transpose of a matrix and store it in a target matrix
  4789. * @param matrix defines the matrix to transpose
  4790. * @param result defines the target matrix
  4791. */
  4792. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4793. /**
  4794. * Computes a reflection matrix from a plane
  4795. * @param plane defines the reflection plane
  4796. * @returns a new matrix
  4797. */
  4798. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4799. /**
  4800. * Computes a reflection matrix from a plane
  4801. * @param plane defines the reflection plane
  4802. * @param result defines the target matrix
  4803. */
  4804. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4805. /**
  4806. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4807. * @param xaxis defines the value of the 1st axis
  4808. * @param yaxis defines the value of the 2nd axis
  4809. * @param zaxis defines the value of the 3rd axis
  4810. * @param result defines the target matrix
  4811. */
  4812. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4813. /**
  4814. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4815. * @param quat defines the quaternion to use
  4816. * @param result defines the target matrix
  4817. */
  4818. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4819. }
  4820. /**
  4821. * @hidden
  4822. */
  4823. export class TmpVectors {
  4824. static Vector2: Vector2[];
  4825. static Vector3: Vector3[];
  4826. static Vector4: Vector4[];
  4827. static Quaternion: Quaternion[];
  4828. static Matrix: Matrix[];
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Defines potential orientation for back face culling
  4834. */
  4835. export enum Orientation {
  4836. /**
  4837. * Clockwise
  4838. */
  4839. CW = 0,
  4840. /** Counter clockwise */
  4841. CCW = 1
  4842. }
  4843. /** Class used to represent a Bezier curve */
  4844. export class BezierCurve {
  4845. /**
  4846. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4847. * @param t defines the time
  4848. * @param x1 defines the left coordinate on X axis
  4849. * @param y1 defines the left coordinate on Y axis
  4850. * @param x2 defines the right coordinate on X axis
  4851. * @param y2 defines the right coordinate on Y axis
  4852. * @returns the interpolated value
  4853. */
  4854. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4855. }
  4856. /**
  4857. * Defines angle representation
  4858. */
  4859. export class Angle {
  4860. private _radians;
  4861. /**
  4862. * Creates an Angle object of "radians" radians (float).
  4863. * @param radians the angle in radians
  4864. */
  4865. constructor(radians: number);
  4866. /**
  4867. * Get value in degrees
  4868. * @returns the Angle value in degrees (float)
  4869. */
  4870. degrees(): number;
  4871. /**
  4872. * Get value in radians
  4873. * @returns the Angle value in radians (float)
  4874. */
  4875. radians(): number;
  4876. /**
  4877. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4878. * @param a defines first point as the origin
  4879. * @param b defines point
  4880. * @returns a new Angle
  4881. */
  4882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4883. /**
  4884. * Gets a new Angle object from the given float in radians
  4885. * @param radians defines the angle value in radians
  4886. * @returns a new Angle
  4887. */
  4888. static FromRadians(radians: number): Angle;
  4889. /**
  4890. * Gets a new Angle object from the given float in degrees
  4891. * @param degrees defines the angle value in degrees
  4892. * @returns a new Angle
  4893. */
  4894. static FromDegrees(degrees: number): Angle;
  4895. }
  4896. /**
  4897. * This represents an arc in a 2d space.
  4898. */
  4899. export class Arc2 {
  4900. /** Defines the start point of the arc */
  4901. startPoint: Vector2;
  4902. /** Defines the mid point of the arc */
  4903. midPoint: Vector2;
  4904. /** Defines the end point of the arc */
  4905. endPoint: Vector2;
  4906. /**
  4907. * Defines the center point of the arc.
  4908. */
  4909. centerPoint: Vector2;
  4910. /**
  4911. * Defines the radius of the arc.
  4912. */
  4913. radius: number;
  4914. /**
  4915. * Defines the angle of the arc (from mid point to end point).
  4916. */
  4917. angle: Angle;
  4918. /**
  4919. * Defines the start angle of the arc (from start point to middle point).
  4920. */
  4921. startAngle: Angle;
  4922. /**
  4923. * Defines the orientation of the arc (clock wise/counter clock wise).
  4924. */
  4925. orientation: Orientation;
  4926. /**
  4927. * Creates an Arc object from the three given points : start, middle and end.
  4928. * @param startPoint Defines the start point of the arc
  4929. * @param midPoint Defines the midlle point of the arc
  4930. * @param endPoint Defines the end point of the arc
  4931. */
  4932. constructor(
  4933. /** Defines the start point of the arc */
  4934. startPoint: Vector2,
  4935. /** Defines the mid point of the arc */
  4936. midPoint: Vector2,
  4937. /** Defines the end point of the arc */
  4938. endPoint: Vector2);
  4939. }
  4940. /**
  4941. * Represents a 2D path made up of multiple 2D points
  4942. */
  4943. export class Path2 {
  4944. private _points;
  4945. private _length;
  4946. /**
  4947. * If the path start and end point are the same
  4948. */
  4949. closed: boolean;
  4950. /**
  4951. * Creates a Path2 object from the starting 2D coordinates x and y.
  4952. * @param x the starting points x value
  4953. * @param y the starting points y value
  4954. */
  4955. constructor(x: number, y: number);
  4956. /**
  4957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4958. * @param x the added points x value
  4959. * @param y the added points y value
  4960. * @returns the updated Path2.
  4961. */
  4962. addLineTo(x: number, y: number): Path2;
  4963. /**
  4964. * 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.
  4965. * @param midX middle point x value
  4966. * @param midY middle point y value
  4967. * @param endX end point x value
  4968. * @param endY end point y value
  4969. * @param numberOfSegments (default: 36)
  4970. * @returns the updated Path2.
  4971. */
  4972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4973. /**
  4974. * Closes the Path2.
  4975. * @returns the Path2.
  4976. */
  4977. close(): Path2;
  4978. /**
  4979. * Gets the sum of the distance between each sequential point in the path
  4980. * @returns the Path2 total length (float).
  4981. */
  4982. length(): number;
  4983. /**
  4984. * Gets the points which construct the path
  4985. * @returns the Path2 internal array of points.
  4986. */
  4987. getPoints(): Vector2[];
  4988. /**
  4989. * Retreives the point at the distance aways from the starting point
  4990. * @param normalizedLengthPosition the length along the path to retreive the point from
  4991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4992. */
  4993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4994. /**
  4995. * Creates a new path starting from an x and y position
  4996. * @param x starting x value
  4997. * @param y starting y value
  4998. * @returns a new Path2 starting at the coordinates (x, y).
  4999. */
  5000. static StartingAt(x: number, y: number): Path2;
  5001. }
  5002. /**
  5003. * Represents a 3D path made up of multiple 3D points
  5004. */
  5005. export class Path3D {
  5006. /**
  5007. * an array of Vector3, the curve axis of the Path3D
  5008. */
  5009. path: Vector3[];
  5010. private _curve;
  5011. private _distances;
  5012. private _tangents;
  5013. private _normals;
  5014. private _binormals;
  5015. private _raw;
  5016. private _alignTangentsWithPath;
  5017. private readonly _pointAtData;
  5018. /**
  5019. * new Path3D(path, normal, raw)
  5020. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5021. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5022. * @param path an array of Vector3, the curve axis of the Path3D
  5023. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5024. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5025. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5026. */
  5027. constructor(
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5032. /**
  5033. * Returns the Path3D array of successive Vector3 designing its curve.
  5034. * @returns the Path3D array of successive Vector3 designing its curve.
  5035. */
  5036. getCurve(): Vector3[];
  5037. /**
  5038. * Returns the Path3D array of successive Vector3 designing its curve.
  5039. * @returns the Path3D array of successive Vector3 designing its curve.
  5040. */
  5041. getPoints(): Vector3[];
  5042. /**
  5043. * @returns the computed length (float) of the path.
  5044. */
  5045. length(): number;
  5046. /**
  5047. * Returns an array populated with tangent vectors on each Path3D curve point.
  5048. * @returns an array populated with tangent vectors on each Path3D curve point.
  5049. */
  5050. getTangents(): Vector3[];
  5051. /**
  5052. * Returns an array populated with normal vectors on each Path3D curve point.
  5053. * @returns an array populated with normal vectors on each Path3D curve point.
  5054. */
  5055. getNormals(): Vector3[];
  5056. /**
  5057. * Returns an array populated with binormal vectors on each Path3D curve point.
  5058. * @returns an array populated with binormal vectors on each Path3D curve point.
  5059. */
  5060. getBinormals(): Vector3[];
  5061. /**
  5062. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5063. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5064. */
  5065. getDistances(): number[];
  5066. /**
  5067. * Returns an interpolated point along this path
  5068. * @param position the position of the point along this path, from 0.0 to 1.0
  5069. * @returns a new Vector3 as the point
  5070. */
  5071. getPointAt(position: number): Vector3;
  5072. /**
  5073. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5076. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5077. */
  5078. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5079. /**
  5080. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5081. * @param position the position of the point along this path, from 0.0 to 1.0
  5082. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5083. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5084. */
  5085. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5086. /**
  5087. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5088. * @param position the position of the point along this path, from 0.0 to 1.0
  5089. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5090. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5091. */
  5092. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5093. /**
  5094. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5095. * @param position the position of the point along this path, from 0.0 to 1.0
  5096. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5097. */
  5098. getDistanceAt(position: number): number;
  5099. /**
  5100. * Returns the array index of the previous point of an interpolated point along this path
  5101. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5102. * @returns the array index
  5103. */
  5104. getPreviousPointIndexAt(position: number): number;
  5105. /**
  5106. * 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)
  5107. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5108. * @returns the sub position
  5109. */
  5110. getSubPositionAt(position: number): number;
  5111. /**
  5112. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5113. * @param target the vector of which to get the closest position to
  5114. * @returns the position of the closest virtual point on this path to the target vector
  5115. */
  5116. getClosestPositionTo(target: Vector3): number;
  5117. /**
  5118. * Returns a sub path (slice) of this path
  5119. * @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
  5120. * @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
  5121. * @returns a sub path (slice) of this path
  5122. */
  5123. slice(start?: number, end?: number): Path3D;
  5124. /**
  5125. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5126. * @param path path which all values are copied into the curves points
  5127. * @param firstNormal which should be projected onto the curve
  5128. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5129. * @returns the same object updated.
  5130. */
  5131. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5132. private _compute;
  5133. private _getFirstNonNullVector;
  5134. private _getLastNonNullVector;
  5135. private _normalVector;
  5136. /**
  5137. * Updates the point at data for an interpolated point along this curve
  5138. * @param position the position of the point along this curve, from 0.0 to 1.0
  5139. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5140. * @returns the (updated) point at data
  5141. */
  5142. private _updatePointAtData;
  5143. /**
  5144. * Updates the point at data from the specified parameters
  5145. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5146. * @param point the interpolated point
  5147. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5148. */
  5149. private _setPointAtData;
  5150. /**
  5151. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5152. */
  5153. private _updateInterpolationMatrix;
  5154. }
  5155. /**
  5156. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5157. * A Curve3 is designed from a series of successive Vector3.
  5158. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5159. */
  5160. export class Curve3 {
  5161. private _points;
  5162. private _length;
  5163. /**
  5164. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5165. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5166. * @param v1 (Vector3) the control point
  5167. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5168. * @param nbPoints (integer) the wanted number of points in the curve
  5169. * @returns the created Curve3
  5170. */
  5171. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5172. /**
  5173. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5174. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5175. * @param v1 (Vector3) the first control point
  5176. * @param v2 (Vector3) the second control point
  5177. * @param v3 (Vector3) the end point of the Cubic Bezier
  5178. * @param nbPoints (integer) the wanted number of points in the curve
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5182. /**
  5183. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5184. * @param p1 (Vector3) the origin point of the Hermite Spline
  5185. * @param t1 (Vector3) the tangent vector at the origin point
  5186. * @param p2 (Vector3) the end point of the Hermite Spline
  5187. * @param t2 (Vector3) the tangent vector at the end point
  5188. * @param nbPoints (integer) the wanted number of points in the curve
  5189. * @returns the created Curve3
  5190. */
  5191. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5192. /**
  5193. * Returns a Curve3 object along a CatmullRom Spline curve :
  5194. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5195. * @param nbPoints (integer) the wanted number of points between each curve control points
  5196. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5200. /**
  5201. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5202. * A Curve3 is designed from a series of successive Vector3.
  5203. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5204. * @param points points which make up the curve
  5205. */
  5206. constructor(points: Vector3[]);
  5207. /**
  5208. * @returns the Curve3 stored array of successive Vector3
  5209. */
  5210. getPoints(): Vector3[];
  5211. /**
  5212. * @returns the computed length (float) of the curve.
  5213. */
  5214. length(): number;
  5215. /**
  5216. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5217. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5218. * curveA and curveB keep unchanged.
  5219. * @param curve the curve to continue from this curve
  5220. * @returns the newly constructed curve
  5221. */
  5222. continue(curve: DeepImmutable<Curve3>): Curve3;
  5223. private _computeLength;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. /**
  5228. * This represents the main contract an easing function should follow.
  5229. * Easing functions are used throughout the animation system.
  5230. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export interface IEasingFunction {
  5233. /**
  5234. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5235. * of the easing function.
  5236. * The link below provides some of the most common examples of easing functions.
  5237. * @see https://easings.net/
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Base class used for every default easing function.
  5245. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5246. */
  5247. export class EasingFunction implements IEasingFunction {
  5248. /**
  5249. * Interpolation follows the mathematical formula associated with the easing function.
  5250. */
  5251. static readonly EASINGMODE_EASEIN: number;
  5252. /**
  5253. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5254. */
  5255. static readonly EASINGMODE_EASEOUT: number;
  5256. /**
  5257. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5258. */
  5259. static readonly EASINGMODE_EASEINOUT: number;
  5260. private _easingMode;
  5261. /**
  5262. * Sets the easing mode of the current function.
  5263. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5264. */
  5265. setEasingMode(easingMode: number): void;
  5266. /**
  5267. * Gets the current easing mode.
  5268. * @returns the easing mode
  5269. */
  5270. getEasingMode(): number;
  5271. /**
  5272. * @hidden
  5273. */
  5274. easeInCore(gradient: number): number;
  5275. /**
  5276. * Given an input gradient between 0 and 1, this returns the corresponding value
  5277. * of the easing function.
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a circle shape (see link below).
  5285. * @see https://easings.net/#easeInCirc
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class CircleEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a ease back shape (see link below).
  5294. * @see https://easings.net/#easeInBack
  5295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BackEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the amplitude of the function */
  5299. amplitude: number;
  5300. /**
  5301. * Instantiates a back ease easing
  5302. * @see https://easings.net/#easeInBack
  5303. * @param amplitude Defines the amplitude of the function
  5304. */
  5305. constructor(
  5306. /** Defines the amplitude of the function */
  5307. amplitude?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a bouncing shape (see link below).
  5313. * @see https://easings.net/#easeInBounce
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class BounceEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the number of bounces */
  5318. bounces: number;
  5319. /** Defines the amplitude of the bounce */
  5320. bounciness: number;
  5321. /**
  5322. * Instantiates a bounce easing
  5323. * @see https://easings.net/#easeInBounce
  5324. * @param bounces Defines the number of bounces
  5325. * @param bounciness Defines the amplitude of the bounce
  5326. */
  5327. constructor(
  5328. /** Defines the number of bounces */
  5329. bounces?: number,
  5330. /** Defines the amplitude of the bounce */
  5331. bounciness?: number);
  5332. /** @hidden */
  5333. easeInCore(gradient: number): number;
  5334. }
  5335. /**
  5336. * Easing function with a power of 3 shape (see link below).
  5337. * @see https://easings.net/#easeInCubic
  5338. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5339. */
  5340. export class CubicEase extends EasingFunction implements IEasingFunction {
  5341. /** @hidden */
  5342. easeInCore(gradient: number): number;
  5343. }
  5344. /**
  5345. * Easing function with an elastic shape (see link below).
  5346. * @see https://easings.net/#easeInElastic
  5347. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5348. */
  5349. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5350. /** Defines the number of oscillations*/
  5351. oscillations: number;
  5352. /** Defines the amplitude of the oscillations*/
  5353. springiness: number;
  5354. /**
  5355. * Instantiates an elastic easing function
  5356. * @see https://easings.net/#easeInElastic
  5357. * @param oscillations Defines the number of oscillations
  5358. * @param springiness Defines the amplitude of the oscillations
  5359. */
  5360. constructor(
  5361. /** Defines the number of oscillations*/
  5362. oscillations?: number,
  5363. /** Defines the amplitude of the oscillations*/
  5364. springiness?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with an exponential shape (see link below).
  5370. * @see https://easings.net/#easeInExpo
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the exponent of the function */
  5375. exponent: number;
  5376. /**
  5377. * Instantiates an exponential easing function
  5378. * @see https://easings.net/#easeInExpo
  5379. * @param exponent Defines the exponent of the function
  5380. */
  5381. constructor(
  5382. /** Defines the exponent of the function */
  5383. exponent?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class PowerEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the power of the function */
  5394. power: number;
  5395. /**
  5396. * Instantiates an power base easing function
  5397. * @see https://easings.net/#easeInQuad
  5398. * @param power Defines the power of the function
  5399. */
  5400. constructor(
  5401. /** Defines the power of the function */
  5402. power?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 2 shape (see link below).
  5408. * @see https://easings.net/#easeInQuad
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 4 shape (see link below).
  5417. * @see https://easings.net/#easeInQuart
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 5 shape (see link below).
  5426. * @see https://easings.net/#easeInQuint
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a sin shape (see link below).
  5435. * @see https://easings.net/#easeInSine
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class SineEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a bezier shape (see link below).
  5444. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5448. /** Defines the x component of the start tangent in the bezier curve */
  5449. x1: number;
  5450. /** Defines the y component of the start tangent in the bezier curve */
  5451. y1: number;
  5452. /** Defines the x component of the end tangent in the bezier curve */
  5453. x2: number;
  5454. /** Defines the y component of the end tangent in the bezier curve */
  5455. y2: number;
  5456. /**
  5457. * Instantiates a bezier function
  5458. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5459. * @param x1 Defines the x component of the start tangent in the bezier curve
  5460. * @param y1 Defines the y component of the start tangent in the bezier curve
  5461. * @param x2 Defines the x component of the end tangent in the bezier curve
  5462. * @param y2 Defines the y component of the end tangent in the bezier curve
  5463. */
  5464. constructor(
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1?: number,
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1?: number,
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2?: number,
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2?: number);
  5473. /** @hidden */
  5474. easeInCore(gradient: number): number;
  5475. }
  5476. }
  5477. declare module BABYLON {
  5478. /**
  5479. * Class used to hold a RBG color
  5480. */
  5481. export class Color3 {
  5482. /**
  5483. * Defines the red component (between 0 and 1, default is 0)
  5484. */
  5485. r: number;
  5486. /**
  5487. * Defines the green component (between 0 and 1, default is 0)
  5488. */
  5489. g: number;
  5490. /**
  5491. * Defines the blue component (between 0 and 1, default is 0)
  5492. */
  5493. b: number;
  5494. /**
  5495. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5496. * @param r defines the red component (between 0 and 1, default is 0)
  5497. * @param g defines the green component (between 0 and 1, default is 0)
  5498. * @param b defines the blue component (between 0 and 1, default is 0)
  5499. */
  5500. constructor(
  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 string with the Color3 current values
  5515. * @returns the string representation of the Color3 object
  5516. */
  5517. toString(): string;
  5518. /**
  5519. * Returns the string "Color3"
  5520. * @returns "Color3"
  5521. */
  5522. getClassName(): string;
  5523. /**
  5524. * Compute the Color3 hash code
  5525. * @returns an unique number that can be used to hash Color3 objects
  5526. */
  5527. getHashCode(): number;
  5528. /**
  5529. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5530. * @param array defines the array where to store the r,g,b components
  5531. * @param index defines an optional index in the target array to define where to start storing values
  5532. * @returns the current Color3 object
  5533. */
  5534. toArray(array: FloatArray, index?: number): Color3;
  5535. /**
  5536. * Update the current color with values stored in an array from the starting index of the given array
  5537. * @param array defines the source array
  5538. * @param offset defines an offset in the source array
  5539. * @returns the current Color3 object
  5540. */
  5541. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5542. /**
  5543. * Returns a new Color4 object from the current Color3 and the given alpha
  5544. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5545. * @returns a new Color4 object
  5546. */
  5547. toColor4(alpha?: number): Color4;
  5548. /**
  5549. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5550. * @returns the new array
  5551. */
  5552. asArray(): number[];
  5553. /**
  5554. * Returns the luminance value
  5555. * @returns a float value
  5556. */
  5557. toLuminance(): number;
  5558. /**
  5559. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5560. * @param otherColor defines the second operand
  5561. * @returns the new Color3 object
  5562. */
  5563. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5564. /**
  5565. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5566. * @param otherColor defines the second operand
  5567. * @param result defines the Color3 object where to store the result
  5568. * @returns the current Color3
  5569. */
  5570. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5571. /**
  5572. * Determines equality between Color3 objects
  5573. * @param otherColor defines the second operand
  5574. * @returns true if the rgb values are equal to the given ones
  5575. */
  5576. equals(otherColor: DeepImmutable<Color3>): boolean;
  5577. /**
  5578. * Determines equality between the current Color3 object and a set of r,b,g values
  5579. * @param r defines the red component to check
  5580. * @param g defines the green component to check
  5581. * @param b defines the blue component to check
  5582. * @returns true if the rgb values are equal to the given ones
  5583. */
  5584. equalsFloats(r: number, g: number, b: number): boolean;
  5585. /**
  5586. * Multiplies in place each rgb value by scale
  5587. * @param scale defines the scaling factor
  5588. * @returns the updated Color3
  5589. */
  5590. scale(scale: number): Color3;
  5591. /**
  5592. * Multiplies the rgb values by scale and stores the result into "result"
  5593. * @param scale defines the scaling factor
  5594. * @param result defines the Color3 object where to store the result
  5595. * @returns the unmodified current Color3
  5596. */
  5597. scaleToRef(scale: number, result: Color3): Color3;
  5598. /**
  5599. * Scale the current Color3 values by a factor and add the result to a given Color3
  5600. * @param scale defines the scale factor
  5601. * @param result defines color to store the result into
  5602. * @returns the unmodified current Color3
  5603. */
  5604. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5605. /**
  5606. * Clamps the rgb values by the min and max values and stores the result into "result"
  5607. * @param min defines minimum clamping value (default is 0)
  5608. * @param max defines maximum clamping value (default is 1)
  5609. * @param result defines color to store the result into
  5610. * @returns the original Color3
  5611. */
  5612. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5613. /**
  5614. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5615. * @param otherColor defines the second operand
  5616. * @returns the new Color3
  5617. */
  5618. add(otherColor: DeepImmutable<Color3>): Color3;
  5619. /**
  5620. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5621. * @param otherColor defines the second operand
  5622. * @param result defines Color3 object to store the result into
  5623. * @returns the unmodified current Color3
  5624. */
  5625. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5626. /**
  5627. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5628. * @param otherColor defines the second operand
  5629. * @returns the new Color3
  5630. */
  5631. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5632. /**
  5633. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5634. * @param otherColor defines the second operand
  5635. * @param result defines Color3 object to store the result into
  5636. * @returns the unmodified current Color3
  5637. */
  5638. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5639. /**
  5640. * Copy the current object
  5641. * @returns a new Color3 copied the current one
  5642. */
  5643. clone(): Color3;
  5644. /**
  5645. * Copies the rgb values from the source in the current Color3
  5646. * @param source defines the source Color3 object
  5647. * @returns the updated Color3 object
  5648. */
  5649. copyFrom(source: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Updates the Color3 rgb values from the given floats
  5652. * @param r defines the red component to read from
  5653. * @param g defines the green component to read from
  5654. * @param b defines the blue component to read from
  5655. * @returns the current Color3 object
  5656. */
  5657. copyFromFloats(r: number, g: number, b: number): Color3;
  5658. /**
  5659. * Updates the Color3 rgb values from the given floats
  5660. * @param r defines the red component to read from
  5661. * @param g defines the green component to read from
  5662. * @param b defines the blue component to read from
  5663. * @returns the current Color3 object
  5664. */
  5665. set(r: number, g: number, b: number): Color3;
  5666. /**
  5667. * Compute the Color3 hexadecimal code as a string
  5668. * @returns a string containing the hexadecimal representation of the Color3 object
  5669. */
  5670. toHexString(): string;
  5671. /**
  5672. * Computes a new Color3 converted from the current one to linear space
  5673. * @returns a new Color3 object
  5674. */
  5675. toLinearSpace(): Color3;
  5676. /**
  5677. * Converts current color in rgb space to HSV values
  5678. * @returns a new color3 representing the HSV values
  5679. */
  5680. toHSV(): Color3;
  5681. /**
  5682. * Converts current color in rgb space to HSV values
  5683. * @param result defines the Color3 where to store the HSV values
  5684. */
  5685. toHSVToRef(result: Color3): void;
  5686. /**
  5687. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5688. * @param convertedColor defines the Color3 object where to store the linear space version
  5689. * @returns the unmodified Color3
  5690. */
  5691. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5692. /**
  5693. * Computes a new Color3 converted from the current one to gamma space
  5694. * @returns a new Color3 object
  5695. */
  5696. toGammaSpace(): Color3;
  5697. /**
  5698. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the gamma space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5703. private static _BlackReadOnly;
  5704. /**
  5705. * Convert Hue, saturation and value to a Color3 (RGB)
  5706. * @param hue defines the hue
  5707. * @param saturation defines the saturation
  5708. * @param value defines the value
  5709. * @param result defines the Color3 where to store the RGB values
  5710. */
  5711. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5712. /**
  5713. * Creates a new Color3 from the string containing valid hexadecimal values
  5714. * @param hex defines a string containing valid hexadecimal values
  5715. * @returns a new Color3 object
  5716. */
  5717. static FromHexString(hex: string): Color3;
  5718. /**
  5719. * Creates a new Color3 from the starting index of the given array
  5720. * @param array defines the source array
  5721. * @param offset defines an offset in the source array
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5725. /**
  5726. * Creates a new Color3 from the starting index element of the given array
  5727. * @param array defines the source array to read from
  5728. * @param offset defines the offset in the source array
  5729. * @param result defines the target Color3 object
  5730. */
  5731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5732. /**
  5733. * Creates a new Color3 from integer values (< 256)
  5734. * @param r defines the red component to read from (value between 0 and 255)
  5735. * @param g defines the green component to read from (value between 0 and 255)
  5736. * @param b defines the blue component to read from (value between 0 and 255)
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromInts(r: number, g: number, b: number): Color3;
  5740. /**
  5741. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5742. * @param start defines the start Color3 value
  5743. * @param end defines the end Color3 value
  5744. * @param amount defines the gradient value between start and end
  5745. * @returns a new Color3 object
  5746. */
  5747. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5748. /**
  5749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5750. * @param left defines the start value
  5751. * @param right defines the end value
  5752. * @param amount defines the gradient factor
  5753. * @param result defines the Color3 object where to store the result
  5754. */
  5755. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5756. /**
  5757. * Returns a Color3 value containing a red color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Red(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a green color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Green(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a blue color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Blue(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a black color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Black(): Color3;
  5776. /**
  5777. * Gets a Color3 value containing a black color that must not be updated
  5778. */
  5779. static get BlackReadOnly(): DeepImmutable<Color3>;
  5780. /**
  5781. * Returns a Color3 value containing a white color
  5782. * @returns a new Color3 object
  5783. */
  5784. static White(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a purple color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Purple(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a magenta color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Magenta(): Color3;
  5795. /**
  5796. * Returns a Color3 value containing a yellow color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Yellow(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a gray color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Gray(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a teal color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Teal(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a random color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Random(): Color3;
  5815. }
  5816. /**
  5817. * Class used to hold a RBGA color
  5818. */
  5819. export class Color4 {
  5820. /**
  5821. * Defines the red component (between 0 and 1, default is 0)
  5822. */
  5823. r: number;
  5824. /**
  5825. * Defines the green component (between 0 and 1, default is 0)
  5826. */
  5827. g: number;
  5828. /**
  5829. * Defines the blue component (between 0 and 1, default is 0)
  5830. */
  5831. b: number;
  5832. /**
  5833. * Defines the alpha component (between 0 and 1, default is 1)
  5834. */
  5835. a: number;
  5836. /**
  5837. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5838. * @param r defines the red component (between 0 and 1, default is 0)
  5839. * @param g defines the green component (between 0 and 1, default is 0)
  5840. * @param b defines the blue component (between 0 and 1, default is 0)
  5841. * @param a defines the alpha component (between 0 and 1, default is 1)
  5842. */
  5843. constructor(
  5844. /**
  5845. * Defines the red component (between 0 and 1, default is 0)
  5846. */
  5847. r?: number,
  5848. /**
  5849. * Defines the green component (between 0 and 1, default is 0)
  5850. */
  5851. g?: number,
  5852. /**
  5853. * Defines the blue component (between 0 and 1, default is 0)
  5854. */
  5855. b?: number,
  5856. /**
  5857. * Defines the alpha component (between 0 and 1, default is 1)
  5858. */
  5859. a?: number);
  5860. /**
  5861. * Adds in place the given Color4 values to the current Color4 object
  5862. * @param right defines the second operand
  5863. * @returns the current updated Color4 object
  5864. */
  5865. addInPlace(right: DeepImmutable<Color4>): Color4;
  5866. /**
  5867. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5868. * @returns the new array
  5869. */
  5870. asArray(): number[];
  5871. /**
  5872. * Stores from the starting index in the given array the Color4 successive values
  5873. * @param array defines the array where to store the r,g,b components
  5874. * @param index defines an optional index in the target array to define where to start storing values
  5875. * @returns the current Color4 object
  5876. */
  5877. toArray(array: number[], index?: number): Color4;
  5878. /**
  5879. * Update the current color with values stored in an array from the starting index of the given array
  5880. * @param array defines the source array
  5881. * @param offset defines an offset in the source array
  5882. * @returns the current Color4 object
  5883. */
  5884. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5885. /**
  5886. * Determines equality between Color4 objects
  5887. * @param otherColor defines the second operand
  5888. * @returns true if the rgba values are equal to the given ones
  5889. */
  5890. equals(otherColor: DeepImmutable<Color4>): boolean;
  5891. /**
  5892. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5893. * @param right defines the second operand
  5894. * @returns a new Color4 object
  5895. */
  5896. add(right: DeepImmutable<Color4>): Color4;
  5897. /**
  5898. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5899. * @param right defines the second operand
  5900. * @returns a new Color4 object
  5901. */
  5902. subtract(right: DeepImmutable<Color4>): Color4;
  5903. /**
  5904. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5905. * @param right defines the second operand
  5906. * @param result defines the Color4 object where to store the result
  5907. * @returns the current Color4 object
  5908. */
  5909. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5910. /**
  5911. * Creates a new Color4 with the current Color4 values multiplied by scale
  5912. * @param scale defines the scaling factor to apply
  5913. * @returns a new Color4 object
  5914. */
  5915. scale(scale: number): Color4;
  5916. /**
  5917. * Multiplies the current Color4 values by scale and stores the result in "result"
  5918. * @param scale defines the scaling factor to apply
  5919. * @param result defines the Color4 object where to store the result
  5920. * @returns the current unmodified Color4
  5921. */
  5922. scaleToRef(scale: number, result: Color4): Color4;
  5923. /**
  5924. * Scale the current Color4 values by a factor and add the result to a given Color4
  5925. * @param scale defines the scale factor
  5926. * @param result defines the Color4 object where to store the result
  5927. * @returns the unmodified current Color4
  5928. */
  5929. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5930. /**
  5931. * Clamps the rgb values by the min and max values and stores the result into "result"
  5932. * @param min defines minimum clamping value (default is 0)
  5933. * @param max defines maximum clamping value (default is 1)
  5934. * @param result defines color to store the result into.
  5935. * @returns the cuurent Color4
  5936. */
  5937. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5938. /**
  5939. * Multipy an Color4 value by another and return a new Color4 object
  5940. * @param color defines the Color4 value to multiply by
  5941. * @returns a new Color4 object
  5942. */
  5943. multiply(color: Color4): Color4;
  5944. /**
  5945. * Multipy a Color4 value by another and push the result in a reference value
  5946. * @param color defines the Color4 value to multiply by
  5947. * @param result defines the Color4 to fill the result in
  5948. * @returns the result Color4
  5949. */
  5950. multiplyToRef(color: Color4, result: Color4): Color4;
  5951. /**
  5952. * Creates a string with the Color4 current values
  5953. * @returns the string representation of the Color4 object
  5954. */
  5955. toString(): string;
  5956. /**
  5957. * Returns the string "Color4"
  5958. * @returns "Color4"
  5959. */
  5960. getClassName(): string;
  5961. /**
  5962. * Compute the Color4 hash code
  5963. * @returns an unique number that can be used to hash Color4 objects
  5964. */
  5965. getHashCode(): number;
  5966. /**
  5967. * Creates a new Color4 copied from the current one
  5968. * @returns a new Color4 object
  5969. */
  5970. clone(): Color4;
  5971. /**
  5972. * Copies the given Color4 values into the current one
  5973. * @param source defines the source Color4 object
  5974. * @returns the current updated Color4 object
  5975. */
  5976. copyFrom(source: Color4): Color4;
  5977. /**
  5978. * Copies the given float values into the current one
  5979. * @param r defines the red component to read from
  5980. * @param g defines the green component to read from
  5981. * @param b defines the blue component to read from
  5982. * @param a defines the alpha component to read from
  5983. * @returns the current updated Color4 object
  5984. */
  5985. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5986. /**
  5987. * Copies the given float values into the current one
  5988. * @param r defines the red component to read from
  5989. * @param g defines the green component to read from
  5990. * @param b defines the blue component to read from
  5991. * @param a defines the alpha component to read from
  5992. * @returns the current updated Color4 object
  5993. */
  5994. set(r: number, g: number, b: number, a: number): Color4;
  5995. /**
  5996. * Compute the Color4 hexadecimal code as a string
  5997. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5998. * @returns a string containing the hexadecimal representation of the Color4 object
  5999. */
  6000. toHexString(returnAsColor3?: boolean): string;
  6001. /**
  6002. * Computes a new Color4 converted from the current one to linear space
  6003. * @returns a new Color4 object
  6004. */
  6005. toLinearSpace(): Color4;
  6006. /**
  6007. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6008. * @param convertedColor defines the Color4 object where to store the linear space version
  6009. * @returns the unmodified Color4
  6010. */
  6011. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6012. /**
  6013. * Computes a new Color4 converted from the current one to gamma space
  6014. * @returns a new Color4 object
  6015. */
  6016. toGammaSpace(): Color4;
  6017. /**
  6018. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6019. * @param convertedColor defines the Color4 object where to store the gamma space version
  6020. * @returns the unmodified Color4
  6021. */
  6022. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6023. /**
  6024. * Creates a new Color4 from the string containing valid hexadecimal values
  6025. * @param hex defines a string containing valid hexadecimal values
  6026. * @returns a new Color4 object
  6027. */
  6028. static FromHexString(hex: string): Color4;
  6029. /**
  6030. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6031. * @param left defines the start value
  6032. * @param right defines the end value
  6033. * @param amount defines the gradient factor
  6034. * @returns a new Color4 object
  6035. */
  6036. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6037. /**
  6038. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6039. * @param left defines the start value
  6040. * @param right defines the end value
  6041. * @param amount defines the gradient factor
  6042. * @param result defines the Color4 object where to store data
  6043. */
  6044. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6045. /**
  6046. * Creates a new Color4 from a Color3 and an alpha value
  6047. * @param color3 defines the source Color3 to read from
  6048. * @param alpha defines the alpha component (1.0 by default)
  6049. * @returns a new Color4 object
  6050. */
  6051. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6052. /**
  6053. * Creates a new Color4 from the starting index element of the given array
  6054. * @param array defines the source array to read from
  6055. * @param offset defines the offset in the source array
  6056. * @returns a new Color4 object
  6057. */
  6058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6059. /**
  6060. * Creates a new Color4 from the starting index element of the given array
  6061. * @param array defines the source array to read from
  6062. * @param offset defines the offset in the source array
  6063. * @param result defines the target Color4 object
  6064. */
  6065. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6066. /**
  6067. * Creates a new Color3 from integer values (< 256)
  6068. * @param r defines the red component to read from (value between 0 and 255)
  6069. * @param g defines the green component to read from (value between 0 and 255)
  6070. * @param b defines the blue component to read from (value between 0 and 255)
  6071. * @param a defines the alpha component to read from (value between 0 and 255)
  6072. * @returns a new Color3 object
  6073. */
  6074. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6075. /**
  6076. * Check the content of a given array and convert it to an array containing RGBA data
  6077. * If the original array was already containing count * 4 values then it is returned directly
  6078. * @param colors defines the array to check
  6079. * @param count defines the number of RGBA data to expect
  6080. * @returns an array containing count * 4 values (RGBA)
  6081. */
  6082. static CheckColors4(colors: number[], count: number): number[];
  6083. }
  6084. /**
  6085. * @hidden
  6086. */
  6087. export class TmpColors {
  6088. static Color3: Color3[];
  6089. static Color4: Color4[];
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * Defines an interface which represents an animation key frame
  6095. */
  6096. export interface IAnimationKey {
  6097. /**
  6098. * Frame of the key frame
  6099. */
  6100. frame: number;
  6101. /**
  6102. * Value at the specifies key frame
  6103. */
  6104. value: any;
  6105. /**
  6106. * The input tangent for the cubic hermite spline
  6107. */
  6108. inTangent?: any;
  6109. /**
  6110. * The output tangent for the cubic hermite spline
  6111. */
  6112. outTangent?: any;
  6113. /**
  6114. * The animation interpolation type
  6115. */
  6116. interpolation?: AnimationKeyInterpolation;
  6117. }
  6118. /**
  6119. * Enum for the animation key frame interpolation type
  6120. */
  6121. export enum AnimationKeyInterpolation {
  6122. /**
  6123. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6124. */
  6125. STEP = 1
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * Represents the range of an animation
  6131. */
  6132. export class AnimationRange {
  6133. /**The name of the animation range**/
  6134. name: string;
  6135. /**The starting frame of the animation */
  6136. from: number;
  6137. /**The ending frame of the animation*/
  6138. to: number;
  6139. /**
  6140. * Initializes the range of an animation
  6141. * @param name The name of the animation range
  6142. * @param from The starting frame of the animation
  6143. * @param to The ending frame of the animation
  6144. */
  6145. constructor(
  6146. /**The name of the animation range**/
  6147. name: string,
  6148. /**The starting frame of the animation */
  6149. from: number,
  6150. /**The ending frame of the animation*/
  6151. to: number);
  6152. /**
  6153. * Makes a copy of the animation range
  6154. * @returns A copy of the animation range
  6155. */
  6156. clone(): AnimationRange;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Composed of a frame, and an action function
  6162. */
  6163. export class AnimationEvent {
  6164. /** The frame for which the event is triggered **/
  6165. frame: number;
  6166. /** The event to perform when triggered **/
  6167. action: (currentFrame: number) => void;
  6168. /** Specifies if the event should be triggered only once**/
  6169. onlyOnce?: boolean | undefined;
  6170. /**
  6171. * Specifies if the animation event is done
  6172. */
  6173. isDone: boolean;
  6174. /**
  6175. * Initializes the animation event
  6176. * @param frame The frame for which the event is triggered
  6177. * @param action The event to perform when triggered
  6178. * @param onlyOnce Specifies if the event should be triggered only once
  6179. */
  6180. constructor(
  6181. /** The frame for which the event is triggered **/
  6182. frame: number,
  6183. /** The event to perform when triggered **/
  6184. action: (currentFrame: number) => void,
  6185. /** Specifies if the event should be triggered only once**/
  6186. onlyOnce?: boolean | undefined);
  6187. /** @hidden */
  6188. _clone(): AnimationEvent;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. /**
  6193. * Interface used to define a behavior
  6194. */
  6195. export interface Behavior<T> {
  6196. /** gets or sets behavior's name */
  6197. name: string;
  6198. /**
  6199. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6200. */
  6201. init(): void;
  6202. /**
  6203. * Called when the behavior is attached to a target
  6204. * @param target defines the target where the behavior is attached to
  6205. */
  6206. attach(target: T): void;
  6207. /**
  6208. * Called when the behavior is detached from its target
  6209. */
  6210. detach(): void;
  6211. }
  6212. /**
  6213. * Interface implemented by classes supporting behaviors
  6214. */
  6215. export interface IBehaviorAware<T> {
  6216. /**
  6217. * Attach a behavior
  6218. * @param behavior defines the behavior to attach
  6219. * @returns the current host
  6220. */
  6221. addBehavior(behavior: Behavior<T>): T;
  6222. /**
  6223. * Remove a behavior from the current object
  6224. * @param behavior defines the behavior to detach
  6225. * @returns the current host
  6226. */
  6227. removeBehavior(behavior: Behavior<T>): T;
  6228. /**
  6229. * Gets a behavior using its name to search
  6230. * @param name defines the name to search
  6231. * @returns the behavior or null if not found
  6232. */
  6233. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6234. }
  6235. }
  6236. declare module BABYLON {
  6237. /**
  6238. * Defines an array and its length.
  6239. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6240. */
  6241. export interface ISmartArrayLike<T> {
  6242. /**
  6243. * The data of the array.
  6244. */
  6245. data: Array<T>;
  6246. /**
  6247. * The active length of the array.
  6248. */
  6249. length: number;
  6250. }
  6251. /**
  6252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6253. */
  6254. export class SmartArray<T> implements ISmartArrayLike<T> {
  6255. /**
  6256. * The full set of data from the array.
  6257. */
  6258. data: Array<T>;
  6259. /**
  6260. * The active length of the array.
  6261. */
  6262. length: number;
  6263. protected _id: number;
  6264. /**
  6265. * Instantiates a Smart Array.
  6266. * @param capacity defines the default capacity of the array.
  6267. */
  6268. constructor(capacity: number);
  6269. /**
  6270. * Pushes a value at the end of the active data.
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Iterates over the active data and apply the lambda to them.
  6276. * @param func defines the action to apply on each value.
  6277. */
  6278. forEach(func: (content: T) => void): void;
  6279. /**
  6280. * Sorts the full sets of data.
  6281. * @param compareFn defines the comparison function to apply.
  6282. */
  6283. sort(compareFn: (a: T, b: T) => number): void;
  6284. /**
  6285. * Resets the active data to an empty array.
  6286. */
  6287. reset(): void;
  6288. /**
  6289. * Releases all the data from the array as well as the array.
  6290. */
  6291. dispose(): void;
  6292. /**
  6293. * Concats the active data with a given array.
  6294. * @param array defines the data to concatenate with.
  6295. */
  6296. concat(array: any): void;
  6297. /**
  6298. * Returns the position of a value in the active data.
  6299. * @param value defines the value to find the index for
  6300. * @returns the index if found in the active data otherwise -1
  6301. */
  6302. indexOf(value: T): number;
  6303. /**
  6304. * Returns whether an element is part of the active data.
  6305. * @param value defines the value to look for
  6306. * @returns true if found in the active data otherwise false
  6307. */
  6308. contains(value: T): boolean;
  6309. private static _GlobalId;
  6310. }
  6311. /**
  6312. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6313. * The data in this array can only be present once
  6314. */
  6315. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6316. private _duplicateId;
  6317. /**
  6318. * Pushes a value at the end of the active data.
  6319. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6320. * @param value defines the object to push in the array.
  6321. */
  6322. push(value: T): void;
  6323. /**
  6324. * Pushes a value at the end of the active data.
  6325. * If the data is already present, it won t be added again
  6326. * @param value defines the object to push in the array.
  6327. * @returns true if added false if it was already present
  6328. */
  6329. pushNoDuplicate(value: T): boolean;
  6330. /**
  6331. * Resets the active data to an empty array.
  6332. */
  6333. reset(): void;
  6334. /**
  6335. * Concats the active data with a given array.
  6336. * This ensures no dupplicate will be present in the result.
  6337. * @param array defines the data to concatenate with.
  6338. */
  6339. concatWithNoDuplicate(array: any): void;
  6340. }
  6341. }
  6342. declare module BABYLON {
  6343. /**
  6344. * @ignore
  6345. * This is a list of all the different input types that are available in the application.
  6346. * Fo instance: ArcRotateCameraGamepadInput...
  6347. */
  6348. export var CameraInputTypes: {};
  6349. /**
  6350. * This is the contract to implement in order to create a new input class.
  6351. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6352. */
  6353. export interface ICameraInput<TCamera extends Camera> {
  6354. /**
  6355. * Defines the camera the input is attached to.
  6356. */
  6357. camera: Nullable<TCamera>;
  6358. /**
  6359. * Gets the class name of the current intput.
  6360. * @returns the class name
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Get the friendly name associated with the input class.
  6365. * @returns the input friendly name
  6366. */
  6367. getSimpleName(): string;
  6368. /**
  6369. * Attach the input controls to a specific dom element to get the input from.
  6370. * @param element Defines the element the controls should be listened from
  6371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6374. /**
  6375. * Detach the current controls from the specified dom element.
  6376. * @param element Defines the element to stop listening the inputs from
  6377. */
  6378. detachControl(element: Nullable<HTMLElement>): void;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs?: () => void;
  6384. }
  6385. /**
  6386. * Represents a map of input types to input instance or input index to input instance.
  6387. */
  6388. export interface CameraInputsMap<TCamera extends Camera> {
  6389. /**
  6390. * Accessor to the input by input type.
  6391. */
  6392. [name: string]: ICameraInput<TCamera>;
  6393. /**
  6394. * Accessor to the input by input index.
  6395. */
  6396. [idx: number]: ICameraInput<TCamera>;
  6397. }
  6398. /**
  6399. * This represents the input manager used within a camera.
  6400. * It helps dealing with all the different kind of input attached to a camera.
  6401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6402. */
  6403. export class CameraInputsManager<TCamera extends Camera> {
  6404. /**
  6405. * Defines the list of inputs attahed to the camera.
  6406. */
  6407. attached: CameraInputsMap<TCamera>;
  6408. /**
  6409. * Defines the dom element the camera is collecting inputs from.
  6410. * This is null if the controls have not been attached.
  6411. */
  6412. attachedElement: Nullable<HTMLElement>;
  6413. /**
  6414. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6415. */
  6416. noPreventDefault: boolean;
  6417. /**
  6418. * Defined the camera the input manager belongs to.
  6419. */
  6420. camera: TCamera;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs: () => void;
  6426. /**
  6427. * Instantiate a new Camera Input Manager.
  6428. * @param camera Defines the camera the input manager blongs to
  6429. */
  6430. constructor(camera: TCamera);
  6431. /**
  6432. * Add an input method to a camera
  6433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6434. * @param input camera input method
  6435. */
  6436. add(input: ICameraInput<TCamera>): void;
  6437. /**
  6438. * Remove a specific input method from a camera
  6439. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6440. * @param inputToRemove camera input method
  6441. */
  6442. remove(inputToRemove: ICameraInput<TCamera>): void;
  6443. /**
  6444. * Remove a specific input type from a camera
  6445. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6446. * @param inputType the type of the input to remove
  6447. */
  6448. removeByType(inputType: string): void;
  6449. private _addCheckInputs;
  6450. /**
  6451. * Attach the input controls to the currently attached dom element to listen the events from.
  6452. * @param input Defines the input to attach
  6453. */
  6454. attachInput(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6457. * @param element Defines the dom element to collect the events from
  6458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6459. */
  6460. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6461. /**
  6462. * Detach the current manager inputs controls from a specific dom element.
  6463. * @param element Defines the dom element to collect the events from
  6464. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6465. */
  6466. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6467. /**
  6468. * Rebuild the dynamic inputCheck function from the current list of
  6469. * defined inputs in the manager.
  6470. */
  6471. rebuildInputCheck(): void;
  6472. /**
  6473. * Remove all attached input methods from a camera
  6474. */
  6475. clear(): void;
  6476. /**
  6477. * Serialize the current input manager attached to a camera.
  6478. * This ensures than once parsed,
  6479. * the input associated to the camera will be identical to the current ones
  6480. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6481. */
  6482. serialize(serializedCamera: any): void;
  6483. /**
  6484. * Parses an input manager serialized JSON to restore the previous list of inputs
  6485. * and states associated to a camera.
  6486. * @param parsedCamera Defines the JSON to parse
  6487. */
  6488. parse(parsedCamera: any): void;
  6489. }
  6490. }
  6491. declare module BABYLON {
  6492. /**
  6493. * Class used to store data that will be store in GPU memory
  6494. */
  6495. export class Buffer {
  6496. private _engine;
  6497. private _buffer;
  6498. /** @hidden */
  6499. _data: Nullable<DataArray>;
  6500. private _updatable;
  6501. private _instanced;
  6502. private _divisor;
  6503. /**
  6504. * Gets the byte stride.
  6505. */
  6506. readonly byteStride: number;
  6507. /**
  6508. * Constructor
  6509. * @param engine the engine
  6510. * @param data the data to use for this buffer
  6511. * @param updatable whether the data is updatable
  6512. * @param stride the stride (optional)
  6513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6514. * @param instanced whether the buffer is instanced (optional)
  6515. * @param useBytes set to true if the stride in in bytes (optional)
  6516. * @param divisor sets an optional divisor for instances (1 by default)
  6517. */
  6518. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6519. /**
  6520. * Create a new VertexBuffer based on the current buffer
  6521. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6522. * @param offset defines offset in the buffer (0 by default)
  6523. * @param size defines the size in floats of attributes (position is 3 for instance)
  6524. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6525. * @param instanced defines if the vertex buffer contains indexed data
  6526. * @param useBytes defines if the offset and stride are in bytes *
  6527. * @param divisor sets an optional divisor for instances (1 by default)
  6528. * @returns the new vertex buffer
  6529. */
  6530. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6531. /**
  6532. * Gets a boolean indicating if the Buffer is updatable?
  6533. * @returns true if the buffer is updatable
  6534. */
  6535. isUpdatable(): boolean;
  6536. /**
  6537. * Gets current buffer's data
  6538. * @returns a DataArray or null
  6539. */
  6540. getData(): Nullable<DataArray>;
  6541. /**
  6542. * Gets underlying native buffer
  6543. * @returns underlying native buffer
  6544. */
  6545. getBuffer(): Nullable<DataBuffer>;
  6546. /**
  6547. * Gets the stride in float32 units (i.e. byte stride / 4).
  6548. * May not be an integer if the byte stride is not divisible by 4.
  6549. * @returns the stride in float32 units
  6550. * @deprecated Please use byteStride instead.
  6551. */
  6552. getStrideSize(): number;
  6553. /**
  6554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6555. * @param data defines the data to store
  6556. */
  6557. create(data?: Nullable<DataArray>): void;
  6558. /** @hidden */
  6559. _rebuild(): void;
  6560. /**
  6561. * Update current buffer data
  6562. * @param data defines the data to store
  6563. */
  6564. update(data: DataArray): void;
  6565. /**
  6566. * Updates the data directly.
  6567. * @param data the new data
  6568. * @param offset the new offset
  6569. * @param vertexCount the vertex count (optional)
  6570. * @param useBytes set to true if the offset is in bytes
  6571. */
  6572. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6573. /**
  6574. * Release all resources
  6575. */
  6576. dispose(): void;
  6577. }
  6578. /**
  6579. * Specialized buffer used to store vertex data
  6580. */
  6581. export class VertexBuffer {
  6582. /** @hidden */
  6583. _buffer: Buffer;
  6584. private _kind;
  6585. private _size;
  6586. private _ownsBuffer;
  6587. private _instanced;
  6588. private _instanceDivisor;
  6589. /**
  6590. * The byte type.
  6591. */
  6592. static readonly BYTE: number;
  6593. /**
  6594. * The unsigned byte type.
  6595. */
  6596. static readonly UNSIGNED_BYTE: number;
  6597. /**
  6598. * The short type.
  6599. */
  6600. static readonly SHORT: number;
  6601. /**
  6602. * The unsigned short type.
  6603. */
  6604. static readonly UNSIGNED_SHORT: number;
  6605. /**
  6606. * The integer type.
  6607. */
  6608. static readonly INT: number;
  6609. /**
  6610. * The unsigned integer type.
  6611. */
  6612. static readonly UNSIGNED_INT: number;
  6613. /**
  6614. * The float type.
  6615. */
  6616. static readonly FLOAT: number;
  6617. /**
  6618. * Gets or sets the instance divisor when in instanced mode
  6619. */
  6620. get instanceDivisor(): number;
  6621. set instanceDivisor(value: number);
  6622. /**
  6623. * Gets the byte stride.
  6624. */
  6625. readonly byteStride: number;
  6626. /**
  6627. * Gets the byte offset.
  6628. */
  6629. readonly byteOffset: number;
  6630. /**
  6631. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6632. */
  6633. readonly normalized: boolean;
  6634. /**
  6635. * Gets the data type of each component in the array.
  6636. */
  6637. readonly type: number;
  6638. /**
  6639. * Constructor
  6640. * @param engine the engine
  6641. * @param data the data to use for this vertex buffer
  6642. * @param kind the vertex buffer kind
  6643. * @param updatable whether the data is updatable
  6644. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6645. * @param stride the stride (optional)
  6646. * @param instanced whether the buffer is instanced (optional)
  6647. * @param offset the offset of the data (optional)
  6648. * @param size the number of components (optional)
  6649. * @param type the type of the component (optional)
  6650. * @param normalized whether the data contains normalized data (optional)
  6651. * @param useBytes set to true if stride and offset are in bytes (optional)
  6652. * @param divisor defines the instance divisor to use (1 by default)
  6653. */
  6654. 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);
  6655. /** @hidden */
  6656. _rebuild(): void;
  6657. /**
  6658. * Returns the kind of the VertexBuffer (string)
  6659. * @returns a string
  6660. */
  6661. getKind(): string;
  6662. /**
  6663. * Gets a boolean indicating if the VertexBuffer is updatable?
  6664. * @returns true if the buffer is updatable
  6665. */
  6666. isUpdatable(): boolean;
  6667. /**
  6668. * Gets current buffer's data
  6669. * @returns a DataArray or null
  6670. */
  6671. getData(): Nullable<DataArray>;
  6672. /**
  6673. * Gets underlying native buffer
  6674. * @returns underlying native buffer
  6675. */
  6676. getBuffer(): Nullable<DataBuffer>;
  6677. /**
  6678. * Gets the stride in float32 units (i.e. byte stride / 4).
  6679. * May not be an integer if the byte stride is not divisible by 4.
  6680. * @returns the stride in float32 units
  6681. * @deprecated Please use byteStride instead.
  6682. */
  6683. getStrideSize(): number;
  6684. /**
  6685. * Returns the offset as a multiple of the type byte length.
  6686. * @returns the offset in bytes
  6687. * @deprecated Please use byteOffset instead.
  6688. */
  6689. getOffset(): number;
  6690. /**
  6691. * Returns the number of components per vertex attribute (integer)
  6692. * @returns the size in float
  6693. */
  6694. getSize(): number;
  6695. /**
  6696. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6697. * @returns true if this buffer is instanced
  6698. */
  6699. getIsInstanced(): boolean;
  6700. /**
  6701. * Returns the instancing divisor, zero for non-instanced (integer).
  6702. * @returns a number
  6703. */
  6704. getInstanceDivisor(): number;
  6705. /**
  6706. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6707. * @param data defines the data to store
  6708. */
  6709. create(data?: DataArray): void;
  6710. /**
  6711. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6712. * This function will create a new buffer if the current one is not updatable
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6718. * Returns the directly updated WebGLBuffer.
  6719. * @param data the new data
  6720. * @param offset the new offset
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6724. /**
  6725. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6726. */
  6727. dispose(): void;
  6728. /**
  6729. * Enumerates each value of this vertex buffer as numbers.
  6730. * @param count the number of values to enumerate
  6731. * @param callback the callback function called for each value
  6732. */
  6733. forEach(count: number, callback: (value: number, index: number) => void): void;
  6734. /**
  6735. * Positions
  6736. */
  6737. static readonly PositionKind: string;
  6738. /**
  6739. * Normals
  6740. */
  6741. static readonly NormalKind: string;
  6742. /**
  6743. * Tangents
  6744. */
  6745. static readonly TangentKind: string;
  6746. /**
  6747. * Texture coordinates
  6748. */
  6749. static readonly UVKind: string;
  6750. /**
  6751. * Texture coordinates 2
  6752. */
  6753. static readonly UV2Kind: string;
  6754. /**
  6755. * Texture coordinates 3
  6756. */
  6757. static readonly UV3Kind: string;
  6758. /**
  6759. * Texture coordinates 4
  6760. */
  6761. static readonly UV4Kind: string;
  6762. /**
  6763. * Texture coordinates 5
  6764. */
  6765. static readonly UV5Kind: string;
  6766. /**
  6767. * Texture coordinates 6
  6768. */
  6769. static readonly UV6Kind: string;
  6770. /**
  6771. * Colors
  6772. */
  6773. static readonly ColorKind: string;
  6774. /**
  6775. * Matrix indices (for bones)
  6776. */
  6777. static readonly MatricesIndicesKind: string;
  6778. /**
  6779. * Matrix weights (for bones)
  6780. */
  6781. static readonly MatricesWeightsKind: string;
  6782. /**
  6783. * Additional matrix indices (for bones)
  6784. */
  6785. static readonly MatricesIndicesExtraKind: string;
  6786. /**
  6787. * Additional matrix weights (for bones)
  6788. */
  6789. static readonly MatricesWeightsExtraKind: string;
  6790. /**
  6791. * Deduces the stride given a kind.
  6792. * @param kind The kind string to deduce
  6793. * @returns The deduced stride
  6794. */
  6795. static DeduceStride(kind: string): number;
  6796. /**
  6797. * Gets the byte length of the given type.
  6798. * @param type the type
  6799. * @returns the number of bytes
  6800. */
  6801. static GetTypeByteLength(type: number): number;
  6802. /**
  6803. * Enumerates each value of the given parameters as numbers.
  6804. * @param data the data to enumerate
  6805. * @param byteOffset the byte offset of the data
  6806. * @param byteStride the byte stride of the data
  6807. * @param componentCount the number of components per element
  6808. * @param componentType the type of the component
  6809. * @param count the number of values to enumerate
  6810. * @param normalized whether the data is normalized
  6811. * @param callback the callback function called for each value
  6812. */
  6813. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6814. private static _GetFloatValue;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * @hidden
  6820. */
  6821. export class IntersectionInfo {
  6822. bu: Nullable<number>;
  6823. bv: Nullable<number>;
  6824. distance: number;
  6825. faceId: number;
  6826. subMeshId: number;
  6827. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * Class used to store bounding sphere information
  6833. */
  6834. export class BoundingSphere {
  6835. /**
  6836. * Gets the center of the bounding sphere in local space
  6837. */
  6838. readonly center: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in local space
  6841. */
  6842. radius: number;
  6843. /**
  6844. * Gets the center of the bounding sphere in world space
  6845. */
  6846. readonly centerWorld: Vector3;
  6847. /**
  6848. * Radius of the bounding sphere in world space
  6849. */
  6850. radiusWorld: number;
  6851. /**
  6852. * Gets the minimum vector in local space
  6853. */
  6854. readonly minimum: Vector3;
  6855. /**
  6856. * Gets the maximum vector in local space
  6857. */
  6858. readonly maximum: Vector3;
  6859. private _worldMatrix;
  6860. private static readonly TmpVector3;
  6861. /**
  6862. * Creates a new bounding sphere
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding sphere by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingSphere;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding sphere is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding sphere center is in between the frustum planes.
  6896. * Used for optimistic fast inclusion.
  6897. * @param frustumPlanes defines the frustum planes to test
  6898. * @returns true if the sphere center is in between the frustum planes
  6899. */
  6900. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6901. /**
  6902. * Tests if a point is inside the bounding sphere
  6903. * @param point defines the point to test
  6904. * @returns true if the point is inside the bounding sphere
  6905. */
  6906. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6907. /**
  6908. * Checks if two sphere intersct
  6909. * @param sphere0 sphere 0
  6910. * @param sphere1 sphere 1
  6911. * @returns true if the speres intersect
  6912. */
  6913. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6914. }
  6915. }
  6916. declare module BABYLON {
  6917. /**
  6918. * Class used to store bounding box information
  6919. */
  6920. export class BoundingBox implements ICullable {
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in local space
  6923. */
  6924. readonly vectors: Vector3[];
  6925. /**
  6926. * Gets the center of the bounding box in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Gets the center of the bounding box in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Gets the extend size in local space
  6935. */
  6936. readonly extendSize: Vector3;
  6937. /**
  6938. * Gets the extend size in world space
  6939. */
  6940. readonly extendSizeWorld: Vector3;
  6941. /**
  6942. * Gets the OBB (object bounding box) directions
  6943. */
  6944. readonly directions: Vector3[];
  6945. /**
  6946. * Gets the 8 vectors representing the bounding box in world space
  6947. */
  6948. readonly vectorsWorld: Vector3[];
  6949. /**
  6950. * Gets the minimum vector in world space
  6951. */
  6952. readonly minimumWorld: Vector3;
  6953. /**
  6954. * Gets the maximum vector in world space
  6955. */
  6956. readonly maximumWorld: Vector3;
  6957. /**
  6958. * Gets the minimum vector in local space
  6959. */
  6960. readonly minimum: Vector3;
  6961. /**
  6962. * Gets the maximum vector in local space
  6963. */
  6964. readonly maximum: Vector3;
  6965. private _worldMatrix;
  6966. private static readonly TmpVector3;
  6967. /**
  6968. * @hidden
  6969. */
  6970. _tag: number;
  6971. /**
  6972. * Creates a new bounding box
  6973. * @param min defines the minimum vector (in local space)
  6974. * @param max defines the maximum vector (in local space)
  6975. * @param worldMatrix defines the new world matrix
  6976. */
  6977. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6978. /**
  6979. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6980. * @param min defines the new minimum vector (in local space)
  6981. * @param max defines the new maximum vector (in local space)
  6982. * @param worldMatrix defines the new world matrix
  6983. */
  6984. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6985. /**
  6986. * Scale the current bounding box by applying a scale factor
  6987. * @param factor defines the scale factor to apply
  6988. * @returns the current bounding box
  6989. */
  6990. scale(factor: number): BoundingBox;
  6991. /**
  6992. * Gets the world matrix of the bounding box
  6993. * @returns a matrix
  6994. */
  6995. getWorldMatrix(): DeepImmutable<Matrix>;
  6996. /** @hidden */
  6997. _update(world: DeepImmutable<Matrix>): void;
  6998. /**
  6999. * Tests if the bounding box is intersecting the frustum planes
  7000. * @param frustumPlanes defines the frustum planes to test
  7001. * @returns true if there is an intersection
  7002. */
  7003. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /**
  7005. * Tests if the bounding box is entirely inside the frustum planes
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @returns true if there is an inclusion
  7008. */
  7009. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. /**
  7011. * Tests if a point is inside the bounding box
  7012. * @param point defines the point to test
  7013. * @returns true if the point is inside the bounding box
  7014. */
  7015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7016. /**
  7017. * Tests if the bounding box intersects with a bounding sphere
  7018. * @param sphere defines the sphere to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7022. /**
  7023. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7024. * @param min defines the min vector to use
  7025. * @param max defines the max vector to use
  7026. * @returns true if there is an intersection
  7027. */
  7028. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7029. /**
  7030. * Tests if two bounding boxes are intersections
  7031. * @param box0 defines the first box to test
  7032. * @param box1 defines the second box to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7036. /**
  7037. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7038. * @param minPoint defines the minimum vector of the bounding box
  7039. * @param maxPoint defines the maximum vector of the bounding box
  7040. * @param sphereCenter defines the sphere center
  7041. * @param sphereRadius defines the sphere radius
  7042. * @returns true if there is an intersection
  7043. */
  7044. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7045. /**
  7046. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7047. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7048. * @param frustumPlanes defines the frustum planes to test
  7049. * @return true if there is an inclusion
  7050. */
  7051. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /**
  7053. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7054. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @return true if there is an intersection
  7057. */
  7058. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. }
  7060. }
  7061. declare module BABYLON {
  7062. /** @hidden */
  7063. export class Collider {
  7064. /** Define if a collision was found */
  7065. collisionFound: boolean;
  7066. /**
  7067. * Define last intersection point in local space
  7068. */
  7069. intersectionPoint: Vector3;
  7070. /**
  7071. * Define last collided mesh
  7072. */
  7073. collidedMesh: Nullable<AbstractMesh>;
  7074. private _collisionPoint;
  7075. private _planeIntersectionPoint;
  7076. private _tempVector;
  7077. private _tempVector2;
  7078. private _tempVector3;
  7079. private _tempVector4;
  7080. private _edge;
  7081. private _baseToVertex;
  7082. private _destinationPoint;
  7083. private _slidePlaneNormal;
  7084. private _displacementVector;
  7085. /** @hidden */
  7086. _radius: Vector3;
  7087. /** @hidden */
  7088. _retry: number;
  7089. private _velocity;
  7090. private _basePoint;
  7091. private _epsilon;
  7092. /** @hidden */
  7093. _velocityWorldLength: number;
  7094. /** @hidden */
  7095. _basePointWorld: Vector3;
  7096. private _velocityWorld;
  7097. private _normalizedVelocity;
  7098. /** @hidden */
  7099. _initialVelocity: Vector3;
  7100. /** @hidden */
  7101. _initialPosition: Vector3;
  7102. private _nearestDistance;
  7103. private _collisionMask;
  7104. get collisionMask(): number;
  7105. set collisionMask(mask: number);
  7106. /**
  7107. * Gets the plane normal used to compute the sliding response (in local space)
  7108. */
  7109. get slidePlaneNormal(): Vector3;
  7110. /** @hidden */
  7111. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7112. /** @hidden */
  7113. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7114. /** @hidden */
  7115. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7116. /** @hidden */
  7117. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7118. /** @hidden */
  7119. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7120. /** @hidden */
  7121. _getResponse(pos: Vector3, vel: Vector3): void;
  7122. }
  7123. }
  7124. declare module BABYLON {
  7125. /**
  7126. * Interface for cullable objects
  7127. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7128. */
  7129. export interface ICullable {
  7130. /**
  7131. * Checks if the object or part of the object is in the frustum
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isInFrustum(frustumPlanes: Plane[]): boolean;
  7136. /**
  7137. * Checks if a cullable object (mesh...) is in the camera frustum
  7138. * Unlike isInFrustum this cheks the full bounding box
  7139. * @param frustumPlanes Camera near/planes
  7140. * @returns true if the object is in frustum otherwise false
  7141. */
  7142. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7143. }
  7144. /**
  7145. * Info for a bounding data of a mesh
  7146. */
  7147. export class BoundingInfo implements ICullable {
  7148. /**
  7149. * Bounding box for the mesh
  7150. */
  7151. readonly boundingBox: BoundingBox;
  7152. /**
  7153. * Bounding sphere for the mesh
  7154. */
  7155. readonly boundingSphere: BoundingSphere;
  7156. private _isLocked;
  7157. private static readonly TmpVector3;
  7158. /**
  7159. * Constructs bounding info
  7160. * @param minimum min vector of the bounding box/sphere
  7161. * @param maximum max vector of the bounding box/sphere
  7162. * @param worldMatrix defines the new world matrix
  7163. */
  7164. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7165. /**
  7166. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7167. * @param min defines the new minimum vector (in local space)
  7168. * @param max defines the new maximum vector (in local space)
  7169. * @param worldMatrix defines the new world matrix
  7170. */
  7171. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7172. /**
  7173. * min vector of the bounding box/sphere
  7174. */
  7175. get minimum(): Vector3;
  7176. /**
  7177. * max vector of the bounding box/sphere
  7178. */
  7179. get maximum(): Vector3;
  7180. /**
  7181. * If the info is locked and won't be updated to avoid perf overhead
  7182. */
  7183. get isLocked(): boolean;
  7184. set isLocked(value: boolean);
  7185. /**
  7186. * Updates the bounding sphere and box
  7187. * @param world world matrix to be used to update
  7188. */
  7189. update(world: DeepImmutable<Matrix>): void;
  7190. /**
  7191. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7192. * @param center New center of the bounding info
  7193. * @param extend New extend of the bounding info
  7194. * @returns the current bounding info
  7195. */
  7196. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7197. /**
  7198. * Scale the current bounding info by applying a scale factor
  7199. * @param factor defines the scale factor to apply
  7200. * @returns the current bounding info
  7201. */
  7202. scale(factor: number): BoundingInfo;
  7203. /**
  7204. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7205. * @param frustumPlanes defines the frustum to test
  7206. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7207. * @returns true if the bounding info is in the frustum planes
  7208. */
  7209. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7210. /**
  7211. * Gets the world distance between the min and max points of the bounding box
  7212. */
  7213. get diagonalLength(): number;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7221. /** @hidden */
  7222. _checkCollision(collider: Collider): boolean;
  7223. /**
  7224. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7225. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7226. * @param point the point to check intersection with
  7227. * @returns if the point intersects
  7228. */
  7229. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7230. /**
  7231. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7232. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7233. * @param boundingInfo the bounding info to check intersection with
  7234. * @param precise if the intersection should be done using OBB
  7235. * @returns if the bounding info intersects
  7236. */
  7237. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7238. }
  7239. }
  7240. declare module BABYLON {
  7241. /**
  7242. * Extracts minimum and maximum values from a list of indexed positions
  7243. * @param positions defines the positions to use
  7244. * @param indices defines the indices to the positions
  7245. * @param indexStart defines the start index
  7246. * @param indexCount defines the end index
  7247. * @param bias defines bias value to add to the result
  7248. * @return minimum and maximum values
  7249. */
  7250. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7251. minimum: Vector3;
  7252. maximum: Vector3;
  7253. };
  7254. /**
  7255. * Extracts minimum and maximum values from a list of positions
  7256. * @param positions defines the positions to use
  7257. * @param start defines the start index in the positions array
  7258. * @param count defines the number of positions to handle
  7259. * @param bias defines bias value to add to the result
  7260. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7261. * @return minimum and maximum values
  7262. */
  7263. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7264. minimum: Vector3;
  7265. maximum: Vector3;
  7266. };
  7267. }
  7268. declare module BABYLON {
  7269. /** @hidden */
  7270. export class WebGLDataBuffer extends DataBuffer {
  7271. private _buffer;
  7272. constructor(resource: WebGLBuffer);
  7273. get underlyingResource(): any;
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /** @hidden */
  7278. export class WebGLPipelineContext implements IPipelineContext {
  7279. engine: ThinEngine;
  7280. program: Nullable<WebGLProgram>;
  7281. context?: WebGLRenderingContext;
  7282. vertexShader?: WebGLShader;
  7283. fragmentShader?: WebGLShader;
  7284. isParallelCompiled: boolean;
  7285. onCompiled?: () => void;
  7286. transformFeedback?: WebGLTransformFeedback | null;
  7287. vertexCompilationError: Nullable<string>;
  7288. fragmentCompilationError: Nullable<string>;
  7289. programLinkError: Nullable<string>;
  7290. programValidationError: Nullable<string>;
  7291. get isAsync(): boolean;
  7292. get isReady(): boolean;
  7293. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7294. _getVertexShaderCode(): string | null;
  7295. _getFragmentShaderCode(): string | null;
  7296. }
  7297. }
  7298. declare module BABYLON {
  7299. interface ThinEngine {
  7300. /**
  7301. * Create an uniform buffer
  7302. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7303. * @param elements defines the content of the uniform buffer
  7304. * @returns the webGL uniform buffer
  7305. */
  7306. createUniformBuffer(elements: FloatArray): DataBuffer;
  7307. /**
  7308. * Create a dynamic uniform buffer
  7309. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7310. * @param elements defines the content of the uniform buffer
  7311. * @returns the webGL uniform buffer
  7312. */
  7313. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7314. /**
  7315. * Update an existing uniform buffer
  7316. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7317. * @param uniformBuffer defines the target uniform buffer
  7318. * @param elements defines the content to update
  7319. * @param offset defines the offset in the uniform buffer where update should start
  7320. * @param count defines the size of the data to update
  7321. */
  7322. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7323. /**
  7324. * Bind an uniform buffer to the current webGL context
  7325. * @param buffer defines the buffer to bind
  7326. */
  7327. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7328. /**
  7329. * Bind a buffer to the current webGL context at a given location
  7330. * @param buffer defines the buffer to bind
  7331. * @param location defines the index where to bind the buffer
  7332. */
  7333. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7334. /**
  7335. * Bind a specific block at a given index in a specific shader program
  7336. * @param pipelineContext defines the pipeline context to use
  7337. * @param blockName defines the block name
  7338. * @param index defines the index where to bind the block
  7339. */
  7340. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. */
  7354. export class UniformBuffer {
  7355. private _engine;
  7356. private _buffer;
  7357. private _data;
  7358. private _bufferData;
  7359. private _dynamic?;
  7360. private _uniformLocations;
  7361. private _uniformSizes;
  7362. private _uniformLocationPointer;
  7363. private _needSync;
  7364. private _noUBO;
  7365. private _currentEffect;
  7366. /** @hidden */
  7367. _alreadyBound: boolean;
  7368. private static _MAX_UNIFORM_SIZE;
  7369. private static _tempBuffer;
  7370. /**
  7371. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7372. * This is dynamic to allow compat with webgl 1 and 2.
  7373. * You will need to pass the name of the uniform as well as the value.
  7374. */
  7375. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7376. /**
  7377. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7378. * This is dynamic to allow compat with webgl 1 and 2.
  7379. * You will need to pass the name of the uniform as well as the value.
  7380. */
  7381. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7382. /**
  7383. * Lambda to Update a single float in a uniform buffer.
  7384. * This is dynamic to allow compat with webgl 1 and 2.
  7385. * You will need to pass the name of the uniform as well as the value.
  7386. */
  7387. updateFloat: (name: string, x: number) => void;
  7388. /**
  7389. * Lambda to Update a vec2 of float in a uniform buffer.
  7390. * This is dynamic to allow compat with webgl 1 and 2.
  7391. * You will need to pass the name of the uniform as well as the value.
  7392. */
  7393. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7394. /**
  7395. * Lambda to Update a vec3 of float in a uniform buffer.
  7396. * This is dynamic to allow compat with webgl 1 and 2.
  7397. * You will need to pass the name of the uniform as well as the value.
  7398. */
  7399. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7400. /**
  7401. * Lambda to Update a vec4 of float in a uniform buffer.
  7402. * This is dynamic to allow compat with webgl 1 and 2.
  7403. * You will need to pass the name of the uniform as well as the value.
  7404. */
  7405. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7406. /**
  7407. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7408. * This is dynamic to allow compat with webgl 1 and 2.
  7409. * You will need to pass the name of the uniform as well as the value.
  7410. */
  7411. updateMatrix: (name: string, mat: Matrix) => void;
  7412. /**
  7413. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7414. * This is dynamic to allow compat with webgl 1 and 2.
  7415. * You will need to pass the name of the uniform as well as the value.
  7416. */
  7417. updateVector3: (name: string, vector: Vector3) => void;
  7418. /**
  7419. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7420. * This is dynamic to allow compat with webgl 1 and 2.
  7421. * You will need to pass the name of the uniform as well as the value.
  7422. */
  7423. updateVector4: (name: string, vector: Vector4) => void;
  7424. /**
  7425. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7426. * This is dynamic to allow compat with webgl 1 and 2.
  7427. * You will need to pass the name of the uniform as well as the value.
  7428. */
  7429. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7430. /**
  7431. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7432. * This is dynamic to allow compat with webgl 1 and 2.
  7433. * You will need to pass the name of the uniform as well as the value.
  7434. */
  7435. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7436. /**
  7437. * Instantiates a new Uniform buffer objects.
  7438. *
  7439. * Handles blocks of uniform on the GPU.
  7440. *
  7441. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7442. *
  7443. * For more information, please refer to :
  7444. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7445. * @param engine Define the engine the buffer is associated with
  7446. * @param data Define the data contained in the buffer
  7447. * @param dynamic Define if the buffer is updatable
  7448. */
  7449. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7450. /**
  7451. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7452. * or just falling back on setUniformXXX calls.
  7453. */
  7454. get useUbo(): boolean;
  7455. /**
  7456. * Indicates if the WebGL underlying uniform buffer is in sync
  7457. * with the javascript cache data.
  7458. */
  7459. get isSync(): boolean;
  7460. /**
  7461. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7462. * Also, a dynamic UniformBuffer will disable cache verification and always
  7463. * update the underlying WebGL uniform buffer to the GPU.
  7464. * @returns if Dynamic, otherwise false
  7465. */
  7466. isDynamic(): boolean;
  7467. /**
  7468. * The data cache on JS side.
  7469. * @returns the underlying data as a float array
  7470. */
  7471. getData(): Float32Array;
  7472. /**
  7473. * The underlying WebGL Uniform buffer.
  7474. * @returns the webgl buffer
  7475. */
  7476. getBuffer(): Nullable<DataBuffer>;
  7477. /**
  7478. * std140 layout specifies how to align data within an UBO structure.
  7479. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7480. * for specs.
  7481. */
  7482. private _fillAlignment;
  7483. /**
  7484. * Adds an uniform in the buffer.
  7485. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7486. * for the layout to be correct !
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param size Data size, or data directly.
  7489. */
  7490. addUniform(name: string, size: number | number[]): void;
  7491. /**
  7492. * Adds a Matrix 4x4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param mat A 4x4 matrix.
  7495. */
  7496. addMatrix(name: string, mat: Matrix): void;
  7497. /**
  7498. * Adds a vec2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. * @param x Define the x component value of the vec2
  7501. * @param y Define the y component value of the vec2
  7502. */
  7503. addFloat2(name: string, x: number, y: number): void;
  7504. /**
  7505. * Adds a vec3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. * @param x Define the x component value of the vec3
  7508. * @param y Define the y component value of the vec3
  7509. * @param z Define the z component value of the vec3
  7510. */
  7511. addFloat3(name: string, x: number, y: number, z: number): void;
  7512. /**
  7513. * Adds a vec3 to the uniform buffer.
  7514. * @param name Name of the uniform, as used in the uniform block in the shader.
  7515. * @param color Define the vec3 from a Color
  7516. */
  7517. addColor3(name: string, color: Color3): void;
  7518. /**
  7519. * Adds a vec4 to the uniform buffer.
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param color Define the rgb components from a Color
  7522. * @param alpha Define the a component of the vec4
  7523. */
  7524. addColor4(name: string, color: Color3, alpha: number): void;
  7525. /**
  7526. * Adds a vec3 to the uniform buffer.
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param vector Define the vec3 components from a Vector
  7529. */
  7530. addVector3(name: string, vector: Vector3): void;
  7531. /**
  7532. * Adds a Matrix 3x3 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. */
  7535. addMatrix3x3(name: string): void;
  7536. /**
  7537. * Adds a Matrix 2x2 to the uniform buffer.
  7538. * @param name Name of the uniform, as used in the uniform block in the shader.
  7539. */
  7540. addMatrix2x2(name: string): void;
  7541. /**
  7542. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7543. */
  7544. create(): void;
  7545. /** @hidden */
  7546. _rebuild(): void;
  7547. /**
  7548. * Updates the WebGL Uniform Buffer on the GPU.
  7549. * If the `dynamic` flag is set to true, no cache comparison is done.
  7550. * Otherwise, the buffer will be updated only if the cache differs.
  7551. */
  7552. update(): void;
  7553. /**
  7554. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. * @param size Define the size of the data.
  7558. */
  7559. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7560. private _valueCache;
  7561. private _cacheMatrix;
  7562. private _updateMatrix3x3ForUniform;
  7563. private _updateMatrix3x3ForEffect;
  7564. private _updateMatrix2x2ForEffect;
  7565. private _updateMatrix2x2ForUniform;
  7566. private _updateFloatForEffect;
  7567. private _updateFloatForUniform;
  7568. private _updateFloat2ForEffect;
  7569. private _updateFloat2ForUniform;
  7570. private _updateFloat3ForEffect;
  7571. private _updateFloat3ForUniform;
  7572. private _updateFloat4ForEffect;
  7573. private _updateFloat4ForUniform;
  7574. private _updateMatrixForEffect;
  7575. private _updateMatrixForUniform;
  7576. private _updateVector3ForEffect;
  7577. private _updateVector3ForUniform;
  7578. private _updateVector4ForEffect;
  7579. private _updateVector4ForUniform;
  7580. private _updateColor3ForEffect;
  7581. private _updateColor3ForUniform;
  7582. private _updateColor4ForEffect;
  7583. private _updateColor4ForUniform;
  7584. /**
  7585. * Sets a sampler uniform on the effect.
  7586. * @param name Define the name of the sampler.
  7587. * @param texture Define the texture to set in the sampler
  7588. */
  7589. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7590. /**
  7591. * Directly updates the value of the uniform in the cache AND on the GPU.
  7592. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7593. * @param data Define the flattened data
  7594. */
  7595. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7596. /**
  7597. * Binds this uniform buffer to an effect.
  7598. * @param effect Define the effect to bind the buffer to
  7599. * @param name Name of the uniform block in the shader.
  7600. */
  7601. bindToEffect(effect: Effect, name: string): void;
  7602. /**
  7603. * Disposes the uniform buffer.
  7604. */
  7605. dispose(): void;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. /**
  7610. * Enum that determines the text-wrapping mode to use.
  7611. */
  7612. export enum InspectableType {
  7613. /**
  7614. * Checkbox for booleans
  7615. */
  7616. Checkbox = 0,
  7617. /**
  7618. * Sliders for numbers
  7619. */
  7620. Slider = 1,
  7621. /**
  7622. * Vector3
  7623. */
  7624. Vector3 = 2,
  7625. /**
  7626. * Quaternions
  7627. */
  7628. Quaternion = 3,
  7629. /**
  7630. * Color3
  7631. */
  7632. Color3 = 4,
  7633. /**
  7634. * String
  7635. */
  7636. String = 5
  7637. }
  7638. /**
  7639. * Interface used to define custom inspectable properties.
  7640. * This interface is used by the inspector to display custom property grids
  7641. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7642. */
  7643. export interface IInspectable {
  7644. /**
  7645. * Gets the label to display
  7646. */
  7647. label: string;
  7648. /**
  7649. * Gets the name of the property to edit
  7650. */
  7651. propertyName: string;
  7652. /**
  7653. * Gets the type of the editor to use
  7654. */
  7655. type: InspectableType;
  7656. /**
  7657. * Gets the minimum value of the property when using in "slider" mode
  7658. */
  7659. min?: number;
  7660. /**
  7661. * Gets the maximum value of the property when using in "slider" mode
  7662. */
  7663. max?: number;
  7664. /**
  7665. * Gets the setp to use when using in "slider" mode
  7666. */
  7667. step?: number;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class used to provide helper for timing
  7673. */
  7674. export class TimingTools {
  7675. /**
  7676. * Polyfill for setImmediate
  7677. * @param action defines the action to execute after the current execution block
  7678. */
  7679. static SetImmediate(action: () => void): void;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. /**
  7684. * Class used to enable instatition of objects by class name
  7685. */
  7686. export class InstantiationTools {
  7687. /**
  7688. * Use this object to register external classes like custom textures or material
  7689. * to allow the laoders to instantiate them
  7690. */
  7691. static RegisteredExternalClasses: {
  7692. [key: string]: Object;
  7693. };
  7694. /**
  7695. * Tries to instantiate a new object from a given class name
  7696. * @param className defines the class name to instantiate
  7697. * @returns the new object or null if the system was not able to do the instantiation
  7698. */
  7699. static Instantiate(className: string): any;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Define options used to create a depth texture
  7705. */
  7706. export class DepthTextureCreationOptions {
  7707. /** Specifies whether or not a stencil should be allocated in the texture */
  7708. generateStencil?: boolean;
  7709. /** Specifies whether or not bilinear filtering is enable on the texture */
  7710. bilinearFiltering?: boolean;
  7711. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7712. comparisonFunction?: number;
  7713. /** Specifies if the created texture is a cube texture */
  7714. isCube?: boolean;
  7715. }
  7716. }
  7717. declare module BABYLON {
  7718. interface ThinEngine {
  7719. /**
  7720. * Creates a depth stencil cube texture.
  7721. * This is only available in WebGL 2.
  7722. * @param size The size of face edge in the cube texture.
  7723. * @param options The options defining the cube texture.
  7724. * @returns The cube texture
  7725. */
  7726. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7727. /**
  7728. * Creates a cube texture
  7729. * @param rootUrl defines the url where the files to load is located
  7730. * @param scene defines the current scene
  7731. * @param files defines the list of files to load (1 per face)
  7732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7733. * @param onLoad defines an optional callback raised when the texture is loaded
  7734. * @param onError defines an optional callback raised if there is an issue to load the texture
  7735. * @param format defines the format of the data
  7736. * @param forcedExtension defines the extension to use to pick the right loader
  7737. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7740. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7741. * @returns the cube texture as an InternalTexture
  7742. */
  7743. 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;
  7744. /**
  7745. * Creates a cube texture
  7746. * @param rootUrl defines the url where the files to load is located
  7747. * @param scene defines the current scene
  7748. * @param files defines the list of files to load (1 per face)
  7749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7750. * @param onLoad defines an optional callback raised when the texture is loaded
  7751. * @param onError defines an optional callback raised if there is an issue to load the texture
  7752. * @param format defines the format of the data
  7753. * @param forcedExtension defines the extension to use to pick the right loader
  7754. * @returns the cube texture as an InternalTexture
  7755. */
  7756. 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;
  7757. /**
  7758. * Creates a cube texture
  7759. * @param rootUrl defines the url where the files to load is located
  7760. * @param scene defines the current scene
  7761. * @param files defines the list of files to load (1 per face)
  7762. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7763. * @param onLoad defines an optional callback raised when the texture is loaded
  7764. * @param onError defines an optional callback raised if there is an issue to load the texture
  7765. * @param format defines the format of the data
  7766. * @param forcedExtension defines the extension to use to pick the right loader
  7767. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7768. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7769. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7770. * @returns the cube texture as an InternalTexture
  7771. */
  7772. 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;
  7773. /** @hidden */
  7774. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7775. /** @hidden */
  7776. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7777. /** @hidden */
  7778. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7779. /** @hidden */
  7780. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7781. /**
  7782. * @hidden
  7783. */
  7784. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Class for creating a cube texture
  7790. */
  7791. export class CubeTexture extends BaseTexture {
  7792. private _delayedOnLoad;
  7793. /**
  7794. * Observable triggered once the texture has been loaded.
  7795. */
  7796. onLoadObservable: Observable<CubeTexture>;
  7797. /**
  7798. * The url of the texture
  7799. */
  7800. url: string;
  7801. /**
  7802. * Gets or sets the center of the bounding box associated with the cube texture.
  7803. * It must define where the camera used to render the texture was set
  7804. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7805. */
  7806. boundingBoxPosition: Vector3;
  7807. private _boundingBoxSize;
  7808. /**
  7809. * Gets or sets the size of the bounding box associated with the cube texture
  7810. * When defined, the cubemap will switch to local mode
  7811. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7812. * @example https://www.babylonjs-playground.com/#RNASML
  7813. */
  7814. set boundingBoxSize(value: Vector3);
  7815. /**
  7816. * Returns the bounding box size
  7817. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7818. */
  7819. get boundingBoxSize(): Vector3;
  7820. protected _rotationY: number;
  7821. /**
  7822. * Sets texture matrix rotation angle around Y axis in radians.
  7823. */
  7824. set rotationY(value: number);
  7825. /**
  7826. * Gets texture matrix rotation angle around Y axis radians.
  7827. */
  7828. get rotationY(): number;
  7829. /**
  7830. * Are mip maps generated for this texture or not.
  7831. */
  7832. get noMipmap(): boolean;
  7833. private _noMipmap;
  7834. private _files;
  7835. protected _forcedExtension: Nullable<string>;
  7836. private _extensions;
  7837. private _textureMatrix;
  7838. private _format;
  7839. private _createPolynomials;
  7840. /**
  7841. * Creates a cube texture from an array of image urls
  7842. * @param files defines an array of image urls
  7843. * @param scene defines the hosting scene
  7844. * @param noMipmap specifies if mip maps are not used
  7845. * @returns a cube texture
  7846. */
  7847. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7848. /**
  7849. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7850. * @param url defines the url of the prefiltered texture
  7851. * @param scene defines the scene the texture is attached to
  7852. * @param forcedExtension defines the extension of the file if different from the url
  7853. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7854. * @return the prefiltered texture
  7855. */
  7856. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7857. /**
  7858. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7859. * as prefiltered data.
  7860. * @param rootUrl defines the url of the texture or the root name of the six images
  7861. * @param null defines the scene or engine the texture is attached to
  7862. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7863. * @param noMipmap defines if mipmaps should be created or not
  7864. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7865. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7866. * @param onError defines a callback triggered in case of error during load
  7867. * @param format defines the internal format to use for the texture once loaded
  7868. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7869. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7870. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7871. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7872. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7873. * @return the cube texture
  7874. */
  7875. 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);
  7876. /**
  7877. * Get the current class name of the texture useful for serialization or dynamic coding.
  7878. * @returns "CubeTexture"
  7879. */
  7880. getClassName(): string;
  7881. /**
  7882. * Update the url (and optional buffer) of this texture if url was null during construction.
  7883. * @param url the url of the texture
  7884. * @param forcedExtension defines the extension to use
  7885. * @param onLoad callback called when the texture is loaded (defaults to null)
  7886. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7887. */
  7888. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7889. /**
  7890. * Delays loading of the cube texture
  7891. * @param forcedExtension defines the extension to use
  7892. */
  7893. delayLoad(forcedExtension?: string): void;
  7894. /**
  7895. * Returns the reflection texture matrix
  7896. * @returns the reflection texture matrix
  7897. */
  7898. getReflectionTextureMatrix(): Matrix;
  7899. /**
  7900. * Sets the reflection texture matrix
  7901. * @param value Reflection texture matrix
  7902. */
  7903. setReflectionTextureMatrix(value: Matrix): void;
  7904. /**
  7905. * Parses text to create a cube texture
  7906. * @param parsedTexture define the serialized text to read from
  7907. * @param scene defines the hosting scene
  7908. * @param rootUrl defines the root url of the cube texture
  7909. * @returns a cube texture
  7910. */
  7911. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7912. /**
  7913. * Makes a clone, or deep copy, of the cube texture
  7914. * @returns a new cube texture
  7915. */
  7916. clone(): CubeTexture;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * Manages the defines for the Material
  7922. */
  7923. export class MaterialDefines {
  7924. /** @hidden */
  7925. protected _keys: string[];
  7926. private _isDirty;
  7927. /** @hidden */
  7928. _renderId: number;
  7929. /** @hidden */
  7930. _areLightsDirty: boolean;
  7931. /** @hidden */
  7932. _areLightsDisposed: boolean;
  7933. /** @hidden */
  7934. _areAttributesDirty: boolean;
  7935. /** @hidden */
  7936. _areTexturesDirty: boolean;
  7937. /** @hidden */
  7938. _areFresnelDirty: boolean;
  7939. /** @hidden */
  7940. _areMiscDirty: boolean;
  7941. /** @hidden */
  7942. _areImageProcessingDirty: boolean;
  7943. /** @hidden */
  7944. _normals: boolean;
  7945. /** @hidden */
  7946. _uvs: boolean;
  7947. /** @hidden */
  7948. _needNormals: boolean;
  7949. /** @hidden */
  7950. _needUVs: boolean;
  7951. [id: string]: any;
  7952. /**
  7953. * Specifies if the material needs to be re-calculated
  7954. */
  7955. get isDirty(): boolean;
  7956. /**
  7957. * Marks the material to indicate that it has been re-calculated
  7958. */
  7959. markAsProcessed(): void;
  7960. /**
  7961. * Marks the material to indicate that it needs to be re-calculated
  7962. */
  7963. markAsUnprocessed(): void;
  7964. /**
  7965. * Marks the material to indicate all of its defines need to be re-calculated
  7966. */
  7967. markAllAsDirty(): void;
  7968. /**
  7969. * Marks the material to indicate that image processing needs to be re-calculated
  7970. */
  7971. markAsImageProcessingDirty(): void;
  7972. /**
  7973. * Marks the material to indicate the lights need to be re-calculated
  7974. * @param disposed Defines whether the light is dirty due to dispose or not
  7975. */
  7976. markAsLightDirty(disposed?: boolean): void;
  7977. /**
  7978. * Marks the attribute state as changed
  7979. */
  7980. markAsAttributesDirty(): void;
  7981. /**
  7982. * Marks the texture state as changed
  7983. */
  7984. markAsTexturesDirty(): void;
  7985. /**
  7986. * Marks the fresnel state as changed
  7987. */
  7988. markAsFresnelDirty(): void;
  7989. /**
  7990. * Marks the misc state as changed
  7991. */
  7992. markAsMiscDirty(): void;
  7993. /**
  7994. * Rebuilds the material defines
  7995. */
  7996. rebuild(): void;
  7997. /**
  7998. * Specifies if two material defines are equal
  7999. * @param other - A material define instance to compare to
  8000. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8001. */
  8002. isEqual(other: MaterialDefines): boolean;
  8003. /**
  8004. * Clones this instance's defines to another instance
  8005. * @param other - material defines to clone values to
  8006. */
  8007. cloneTo(other: MaterialDefines): void;
  8008. /**
  8009. * Resets the material define values
  8010. */
  8011. reset(): void;
  8012. /**
  8013. * Converts the material define values to a string
  8014. * @returns - String of material define information
  8015. */
  8016. toString(): string;
  8017. }
  8018. }
  8019. declare module BABYLON {
  8020. /**
  8021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8023. * 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;
  8024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8025. */
  8026. export class ColorCurves {
  8027. private _dirty;
  8028. private _tempColor;
  8029. private _globalCurve;
  8030. private _highlightsCurve;
  8031. private _midtonesCurve;
  8032. private _shadowsCurve;
  8033. private _positiveCurve;
  8034. private _negativeCurve;
  8035. private _globalHue;
  8036. private _globalDensity;
  8037. private _globalSaturation;
  8038. private _globalExposure;
  8039. /**
  8040. * Gets the global Hue value.
  8041. * 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).
  8042. */
  8043. get globalHue(): number;
  8044. /**
  8045. * Sets the global Hue value.
  8046. * 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).
  8047. */
  8048. set globalHue(value: number);
  8049. /**
  8050. * Gets the global Density value.
  8051. * 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.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. get globalDensity(): number;
  8055. /**
  8056. * Sets the global Density value.
  8057. * 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.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. set globalDensity(value: number);
  8061. /**
  8062. * Gets the global Saturation value.
  8063. * 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.
  8064. */
  8065. get globalSaturation(): number;
  8066. /**
  8067. * Sets the global Saturation value.
  8068. * 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.
  8069. */
  8070. set globalSaturation(value: number);
  8071. /**
  8072. * Gets the global Exposure value.
  8073. * 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.
  8074. */
  8075. get globalExposure(): number;
  8076. /**
  8077. * Sets the global Exposure value.
  8078. * 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.
  8079. */
  8080. set globalExposure(value: number);
  8081. private _highlightsHue;
  8082. private _highlightsDensity;
  8083. private _highlightsSaturation;
  8084. private _highlightsExposure;
  8085. /**
  8086. * Gets the highlights Hue value.
  8087. * 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).
  8088. */
  8089. get highlightsHue(): number;
  8090. /**
  8091. * Sets the highlights Hue value.
  8092. * 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).
  8093. */
  8094. set highlightsHue(value: number);
  8095. /**
  8096. * Gets the highlights Density value.
  8097. * 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.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. get highlightsDensity(): number;
  8101. /**
  8102. * Sets the highlights Density value.
  8103. * 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.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. set highlightsDensity(value: number);
  8107. /**
  8108. * Gets the highlights Saturation value.
  8109. * 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.
  8110. */
  8111. get highlightsSaturation(): number;
  8112. /**
  8113. * Sets the highlights Saturation value.
  8114. * 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.
  8115. */
  8116. set highlightsSaturation(value: number);
  8117. /**
  8118. * Gets the highlights Exposure value.
  8119. * 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.
  8120. */
  8121. get highlightsExposure(): number;
  8122. /**
  8123. * Sets the highlights Exposure value.
  8124. * 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.
  8125. */
  8126. set highlightsExposure(value: number);
  8127. private _midtonesHue;
  8128. private _midtonesDensity;
  8129. private _midtonesSaturation;
  8130. private _midtonesExposure;
  8131. /**
  8132. * Gets the midtones Hue value.
  8133. * 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).
  8134. */
  8135. get midtonesHue(): number;
  8136. /**
  8137. * Sets the midtones Hue value.
  8138. * 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).
  8139. */
  8140. set midtonesHue(value: number);
  8141. /**
  8142. * Gets the midtones Density value.
  8143. * 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.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. get midtonesDensity(): number;
  8147. /**
  8148. * Sets the midtones Density value.
  8149. * 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.
  8150. * Values less than zero provide a filter of opposite hue.
  8151. */
  8152. set midtonesDensity(value: number);
  8153. /**
  8154. * Gets the midtones Saturation value.
  8155. * 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.
  8156. */
  8157. get midtonesSaturation(): number;
  8158. /**
  8159. * Sets the midtones Saturation value.
  8160. * 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.
  8161. */
  8162. set midtonesSaturation(value: number);
  8163. /**
  8164. * Gets the midtones Exposure value.
  8165. * 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.
  8166. */
  8167. get midtonesExposure(): number;
  8168. /**
  8169. * Sets the midtones Exposure value.
  8170. * 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.
  8171. */
  8172. set midtonesExposure(value: number);
  8173. private _shadowsHue;
  8174. private _shadowsDensity;
  8175. private _shadowsSaturation;
  8176. private _shadowsExposure;
  8177. /**
  8178. * Gets the shadows Hue value.
  8179. * 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).
  8180. */
  8181. get shadowsHue(): number;
  8182. /**
  8183. * Sets the shadows Hue value.
  8184. * 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).
  8185. */
  8186. set shadowsHue(value: number);
  8187. /**
  8188. * Gets the shadows Density value.
  8189. * 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.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get shadowsDensity(): number;
  8193. /**
  8194. * Sets the shadows Density value.
  8195. * 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.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set shadowsDensity(value: number);
  8199. /**
  8200. * Gets the shadows Saturation value.
  8201. * 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.
  8202. */
  8203. get shadowsSaturation(): number;
  8204. /**
  8205. * Sets the shadows Saturation value.
  8206. * 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.
  8207. */
  8208. set shadowsSaturation(value: number);
  8209. /**
  8210. * Gets the shadows Exposure value.
  8211. * 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.
  8212. */
  8213. get shadowsExposure(): number;
  8214. /**
  8215. * Sets the shadows Exposure value.
  8216. * 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.
  8217. */
  8218. set shadowsExposure(value: number);
  8219. /**
  8220. * Returns the class name
  8221. * @returns The class name
  8222. */
  8223. getClassName(): string;
  8224. /**
  8225. * Binds the color curves to the shader.
  8226. * @param colorCurves The color curve to bind
  8227. * @param effect The effect to bind to
  8228. * @param positiveUniform The positive uniform shader parameter
  8229. * @param neutralUniform The neutral uniform shader parameter
  8230. * @param negativeUniform The negative uniform shader parameter
  8231. */
  8232. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8233. /**
  8234. * Prepare the list of uniforms associated with the ColorCurves effects.
  8235. * @param uniformsList The list of uniforms used in the effect
  8236. */
  8237. static PrepareUniforms(uniformsList: string[]): void;
  8238. /**
  8239. * Returns color grading data based on a hue, density, saturation and exposure value.
  8240. * @param filterHue The hue of the color filter.
  8241. * @param filterDensity The density of the color filter.
  8242. * @param saturation The saturation.
  8243. * @param exposure The exposure.
  8244. * @param result The result data container.
  8245. */
  8246. private getColorGradingDataToRef;
  8247. /**
  8248. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8249. * @param value The input slider value in range [-100,100].
  8250. * @returns Adjusted value.
  8251. */
  8252. private static applyColorGradingSliderNonlinear;
  8253. /**
  8254. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8255. * @param hue The hue (H) input.
  8256. * @param saturation The saturation (S) input.
  8257. * @param brightness The brightness (B) input.
  8258. * @result An RGBA color represented as Vector4.
  8259. */
  8260. private static fromHSBToRef;
  8261. /**
  8262. * Returns a value clamped between min and max
  8263. * @param value The value to clamp
  8264. * @param min The minimum of value
  8265. * @param max The maximum of value
  8266. * @returns The clamped value.
  8267. */
  8268. private static clamp;
  8269. /**
  8270. * Clones the current color curve instance.
  8271. * @return The cloned curves
  8272. */
  8273. clone(): ColorCurves;
  8274. /**
  8275. * Serializes the current color curve instance to a json representation.
  8276. * @return a JSON representation
  8277. */
  8278. serialize(): any;
  8279. /**
  8280. * Parses the color curve from a json representation.
  8281. * @param source the JSON source to parse
  8282. * @return The parsed curves
  8283. */
  8284. static Parse(source: any): ColorCurves;
  8285. }
  8286. }
  8287. declare module BABYLON {
  8288. /**
  8289. * Interface to follow in your material defines to integrate easily the
  8290. * Image proccessing functions.
  8291. * @hidden
  8292. */
  8293. export interface IImageProcessingConfigurationDefines {
  8294. IMAGEPROCESSING: boolean;
  8295. VIGNETTE: boolean;
  8296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8297. VIGNETTEBLENDMODEOPAQUE: boolean;
  8298. TONEMAPPING: boolean;
  8299. TONEMAPPING_ACES: boolean;
  8300. CONTRAST: boolean;
  8301. EXPOSURE: boolean;
  8302. COLORCURVES: boolean;
  8303. COLORGRADING: boolean;
  8304. COLORGRADING3D: boolean;
  8305. SAMPLER3DGREENDEPTH: boolean;
  8306. SAMPLER3DBGRMAP: boolean;
  8307. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8308. }
  8309. /**
  8310. * @hidden
  8311. */
  8312. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. COLORCURVES: boolean;
  8321. COLORGRADING: boolean;
  8322. COLORGRADING3D: boolean;
  8323. SAMPLER3DGREENDEPTH: boolean;
  8324. SAMPLER3DBGRMAP: boolean;
  8325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8326. EXPOSURE: boolean;
  8327. constructor();
  8328. }
  8329. /**
  8330. * This groups together the common properties used for image processing either in direct forward pass
  8331. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8332. * or not.
  8333. */
  8334. export class ImageProcessingConfiguration {
  8335. /**
  8336. * Default tone mapping applied in BabylonJS.
  8337. */
  8338. static readonly TONEMAPPING_STANDARD: number;
  8339. /**
  8340. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8341. * to other engines rendering to increase portability.
  8342. */
  8343. static readonly TONEMAPPING_ACES: number;
  8344. /**
  8345. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8346. */
  8347. colorCurves: Nullable<ColorCurves>;
  8348. private _colorCurvesEnabled;
  8349. /**
  8350. * Gets wether the color curves effect is enabled.
  8351. */
  8352. get colorCurvesEnabled(): boolean;
  8353. /**
  8354. * Sets wether the color curves effect is enabled.
  8355. */
  8356. set colorCurvesEnabled(value: boolean);
  8357. private _colorGradingTexture;
  8358. /**
  8359. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8360. */
  8361. get colorGradingTexture(): Nullable<BaseTexture>;
  8362. /**
  8363. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8364. */
  8365. set colorGradingTexture(value: Nullable<BaseTexture>);
  8366. private _colorGradingEnabled;
  8367. /**
  8368. * Gets wether the color grading effect is enabled.
  8369. */
  8370. get colorGradingEnabled(): boolean;
  8371. /**
  8372. * Sets wether the color grading effect is enabled.
  8373. */
  8374. set colorGradingEnabled(value: boolean);
  8375. private _colorGradingWithGreenDepth;
  8376. /**
  8377. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8378. */
  8379. get colorGradingWithGreenDepth(): boolean;
  8380. /**
  8381. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8382. */
  8383. set colorGradingWithGreenDepth(value: boolean);
  8384. private _colorGradingBGR;
  8385. /**
  8386. * Gets wether the color grading texture contains BGR values.
  8387. */
  8388. get colorGradingBGR(): boolean;
  8389. /**
  8390. * Sets wether the color grading texture contains BGR values.
  8391. */
  8392. set colorGradingBGR(value: boolean);
  8393. /** @hidden */
  8394. _exposure: number;
  8395. /**
  8396. * Gets the Exposure used in the effect.
  8397. */
  8398. get exposure(): number;
  8399. /**
  8400. * Sets the Exposure used in the effect.
  8401. */
  8402. set exposure(value: number);
  8403. private _toneMappingEnabled;
  8404. /**
  8405. * Gets wether the tone mapping effect is enabled.
  8406. */
  8407. get toneMappingEnabled(): boolean;
  8408. /**
  8409. * Sets wether the tone mapping effect is enabled.
  8410. */
  8411. set toneMappingEnabled(value: boolean);
  8412. private _toneMappingType;
  8413. /**
  8414. * Gets the type of tone mapping effect.
  8415. */
  8416. get toneMappingType(): number;
  8417. /**
  8418. * Sets the type of tone mapping effect used in BabylonJS.
  8419. */
  8420. set toneMappingType(value: number);
  8421. protected _contrast: number;
  8422. /**
  8423. * Gets the contrast used in the effect.
  8424. */
  8425. get contrast(): number;
  8426. /**
  8427. * Sets the contrast used in the effect.
  8428. */
  8429. set contrast(value: number);
  8430. /**
  8431. * Vignette stretch size.
  8432. */
  8433. vignetteStretch: number;
  8434. /**
  8435. * Vignette centre X Offset.
  8436. */
  8437. vignetteCentreX: number;
  8438. /**
  8439. * Vignette centre Y Offset.
  8440. */
  8441. vignetteCentreY: number;
  8442. /**
  8443. * Vignette weight or intensity of the vignette effect.
  8444. */
  8445. vignetteWeight: number;
  8446. /**
  8447. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8448. * if vignetteEnabled is set to true.
  8449. */
  8450. vignetteColor: Color4;
  8451. /**
  8452. * Camera field of view used by the Vignette effect.
  8453. */
  8454. vignetteCameraFov: number;
  8455. private _vignetteBlendMode;
  8456. /**
  8457. * Gets the vignette blend mode allowing different kind of effect.
  8458. */
  8459. get vignetteBlendMode(): number;
  8460. /**
  8461. * Sets the vignette blend mode allowing different kind of effect.
  8462. */
  8463. set vignetteBlendMode(value: number);
  8464. private _vignetteEnabled;
  8465. /**
  8466. * Gets wether the vignette effect is enabled.
  8467. */
  8468. get vignetteEnabled(): boolean;
  8469. /**
  8470. * Sets wether the vignette effect is enabled.
  8471. */
  8472. set vignetteEnabled(value: boolean);
  8473. private _applyByPostProcess;
  8474. /**
  8475. * Gets wether the image processing is applied through a post process or not.
  8476. */
  8477. get applyByPostProcess(): boolean;
  8478. /**
  8479. * Sets wether the image processing is applied through a post process or not.
  8480. */
  8481. set applyByPostProcess(value: boolean);
  8482. private _isEnabled;
  8483. /**
  8484. * Gets wether the image processing is enabled or not.
  8485. */
  8486. get isEnabled(): boolean;
  8487. /**
  8488. * Sets wether the image processing is enabled or not.
  8489. */
  8490. set isEnabled(value: boolean);
  8491. /**
  8492. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8493. */
  8494. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8495. /**
  8496. * Method called each time the image processing information changes requires to recompile the effect.
  8497. */
  8498. protected _updateParameters(): void;
  8499. /**
  8500. * Gets the current class name.
  8501. * @return "ImageProcessingConfiguration"
  8502. */
  8503. getClassName(): string;
  8504. /**
  8505. * Prepare the list of uniforms associated with the Image Processing effects.
  8506. * @param uniforms The list of uniforms used in the effect
  8507. * @param defines the list of defines currently in use
  8508. */
  8509. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8510. /**
  8511. * Prepare the list of samplers associated with the Image Processing effects.
  8512. * @param samplersList The list of uniforms used in the effect
  8513. * @param defines the list of defines currently in use
  8514. */
  8515. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8516. /**
  8517. * Prepare the list of defines associated to the shader.
  8518. * @param defines the list of defines to complete
  8519. * @param forPostProcess Define if we are currently in post process mode or not
  8520. */
  8521. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8522. /**
  8523. * Returns true if all the image processing information are ready.
  8524. * @returns True if ready, otherwise, false
  8525. */
  8526. isReady(): boolean;
  8527. /**
  8528. * Binds the image processing to the shader.
  8529. * @param effect The effect to bind to
  8530. * @param overrideAspectRatio Override the aspect ratio of the effect
  8531. */
  8532. bind(effect: Effect, overrideAspectRatio?: number): void;
  8533. /**
  8534. * Clones the current image processing instance.
  8535. * @return The cloned image processing
  8536. */
  8537. clone(): ImageProcessingConfiguration;
  8538. /**
  8539. * Serializes the current image processing instance to a json representation.
  8540. * @return a JSON representation
  8541. */
  8542. serialize(): any;
  8543. /**
  8544. * Parses the image processing from a json representation.
  8545. * @param source the JSON source to parse
  8546. * @return The parsed image processing
  8547. */
  8548. static Parse(source: any): ImageProcessingConfiguration;
  8549. private static _VIGNETTEMODE_MULTIPLY;
  8550. private static _VIGNETTEMODE_OPAQUE;
  8551. /**
  8552. * Used to apply the vignette as a mix with the pixel color.
  8553. */
  8554. static get VIGNETTEMODE_MULTIPLY(): number;
  8555. /**
  8556. * Used to apply the vignette as a replacement of the pixel color.
  8557. */
  8558. static get VIGNETTEMODE_OPAQUE(): number;
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /** @hidden */
  8563. export var postprocessVertexShader: {
  8564. name: string;
  8565. shader: string;
  8566. };
  8567. }
  8568. declare module BABYLON {
  8569. interface ThinEngine {
  8570. /**
  8571. * Creates a new render target texture
  8572. * @param size defines the size of the texture
  8573. * @param options defines the options used to create the texture
  8574. * @returns a new render target texture stored in an InternalTexture
  8575. */
  8576. createRenderTargetTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8581. /**
  8582. * Creates a depth stencil texture.
  8583. * This is only available in WebGL 2 or with the depth texture extension available.
  8584. * @param size The size of face edge in the texture.
  8585. * @param options The options defining the texture.
  8586. * @returns The texture
  8587. */
  8588. createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. /** @hidden */
  8594. _createDepthStencilTexture(size: number | {
  8595. width: number;
  8596. height: number;
  8597. layers?: number;
  8598. }, options: DepthTextureCreationOptions): InternalTexture;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /**
  8603. * Defines the kind of connection point for node based material
  8604. */
  8605. export enum NodeMaterialBlockConnectionPointTypes {
  8606. /** Float */
  8607. Float = 1,
  8608. /** Int */
  8609. Int = 2,
  8610. /** Vector2 */
  8611. Vector2 = 4,
  8612. /** Vector3 */
  8613. Vector3 = 8,
  8614. /** Vector4 */
  8615. Vector4 = 16,
  8616. /** Color3 */
  8617. Color3 = 32,
  8618. /** Color4 */
  8619. Color4 = 64,
  8620. /** Matrix */
  8621. Matrix = 128,
  8622. /** Custom object */
  8623. Object = 256,
  8624. /** Detect type based on connection */
  8625. AutoDetect = 1024,
  8626. /** Output type that will be defined by input type */
  8627. BasedOnInput = 2048
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /**
  8632. * Enum used to define the target of a block
  8633. */
  8634. export enum NodeMaterialBlockTargets {
  8635. /** Vertex shader */
  8636. Vertex = 1,
  8637. /** Fragment shader */
  8638. Fragment = 2,
  8639. /** Neutral */
  8640. Neutral = 4,
  8641. /** Vertex and Fragment */
  8642. VertexAndFragment = 3
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8648. */
  8649. export enum NodeMaterialBlockConnectionPointMode {
  8650. /** Value is an uniform */
  8651. Uniform = 0,
  8652. /** Value is a mesh attribute */
  8653. Attribute = 1,
  8654. /** Value is a varying between vertex and fragment shaders */
  8655. Varying = 2,
  8656. /** Mode is undefined */
  8657. Undefined = 3
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Enum used to define system values e.g. values automatically provided by the system
  8663. */
  8664. export enum NodeMaterialSystemValues {
  8665. /** World */
  8666. World = 1,
  8667. /** View */
  8668. View = 2,
  8669. /** Projection */
  8670. Projection = 3,
  8671. /** ViewProjection */
  8672. ViewProjection = 4,
  8673. /** WorldView */
  8674. WorldView = 5,
  8675. /** WorldViewProjection */
  8676. WorldViewProjection = 6,
  8677. /** CameraPosition */
  8678. CameraPosition = 7,
  8679. /** Fog Color */
  8680. FogColor = 8,
  8681. /** Delta time */
  8682. DeltaTime = 9
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /** Defines supported spaces */
  8687. export enum Space {
  8688. /** Local (object) space */
  8689. LOCAL = 0,
  8690. /** World space */
  8691. WORLD = 1,
  8692. /** Bone space */
  8693. BONE = 2
  8694. }
  8695. /** Defines the 3 main axes */
  8696. export class Axis {
  8697. /** X axis */
  8698. static X: Vector3;
  8699. /** Y axis */
  8700. static Y: Vector3;
  8701. /** Z axis */
  8702. static Z: Vector3;
  8703. }
  8704. }
  8705. declare module BABYLON {
  8706. /**
  8707. * Represents a camera frustum
  8708. */
  8709. export class Frustum {
  8710. /**
  8711. * Gets the planes representing the frustum
  8712. * @param transform matrix to be applied to the returned planes
  8713. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8714. */
  8715. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8716. /**
  8717. * Gets the near frustum plane transformed by the transform matrix
  8718. * @param transform transformation matrix to be applied to the resulting frustum plane
  8719. * @param frustumPlane the resuling frustum plane
  8720. */
  8721. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8722. /**
  8723. * Gets the far frustum plane transformed by the transform matrix
  8724. * @param transform transformation matrix to be applied to the resulting frustum plane
  8725. * @param frustumPlane the resuling frustum plane
  8726. */
  8727. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8728. /**
  8729. * Gets the left frustum plane transformed by the transform matrix
  8730. * @param transform transformation matrix to be applied to the resulting frustum plane
  8731. * @param frustumPlane the resuling frustum plane
  8732. */
  8733. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8734. /**
  8735. * Gets the right frustum plane transformed by the transform matrix
  8736. * @param transform transformation matrix to be applied to the resulting frustum plane
  8737. * @param frustumPlane the resuling frustum plane
  8738. */
  8739. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8740. /**
  8741. * Gets the top frustum plane transformed by the transform matrix
  8742. * @param transform transformation matrix to be applied to the resulting frustum plane
  8743. * @param frustumPlane the resuling frustum plane
  8744. */
  8745. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8746. /**
  8747. * Gets the bottom frustum plane transformed by the transform matrix
  8748. * @param transform transformation matrix to be applied to the resulting frustum plane
  8749. * @param frustumPlane the resuling frustum plane
  8750. */
  8751. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8752. /**
  8753. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8754. * @param transform transformation matrix to be applied to the resulting frustum planes
  8755. * @param frustumPlanes the resuling frustum planes
  8756. */
  8757. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8758. }
  8759. }
  8760. declare module BABYLON {
  8761. /**
  8762. * Interface for the size containing width and height
  8763. */
  8764. export interface ISize {
  8765. /**
  8766. * Width
  8767. */
  8768. width: number;
  8769. /**
  8770. * Heighht
  8771. */
  8772. height: number;
  8773. }
  8774. /**
  8775. * Size containing widht and height
  8776. */
  8777. export class Size implements ISize {
  8778. /**
  8779. * Width
  8780. */
  8781. width: number;
  8782. /**
  8783. * Height
  8784. */
  8785. height: number;
  8786. /**
  8787. * Creates a Size object from the given width and height (floats).
  8788. * @param width width of the new size
  8789. * @param height height of the new size
  8790. */
  8791. constructor(width: number, height: number);
  8792. /**
  8793. * Returns a string with the Size width and height
  8794. * @returns a string with the Size width and height
  8795. */
  8796. toString(): string;
  8797. /**
  8798. * "Size"
  8799. * @returns the string "Size"
  8800. */
  8801. getClassName(): string;
  8802. /**
  8803. * Returns the Size hash code.
  8804. * @returns a hash code for a unique width and height
  8805. */
  8806. getHashCode(): number;
  8807. /**
  8808. * Updates the current size from the given one.
  8809. * @param src the given size
  8810. */
  8811. copyFrom(src: Size): void;
  8812. /**
  8813. * Updates in place the current Size from the given floats.
  8814. * @param width width of the new size
  8815. * @param height height of the new size
  8816. * @returns the updated Size.
  8817. */
  8818. copyFromFloats(width: number, height: number): Size;
  8819. /**
  8820. * Updates in place the current Size from the given floats.
  8821. * @param width width to set
  8822. * @param height height to set
  8823. * @returns the updated Size.
  8824. */
  8825. set(width: number, height: number): Size;
  8826. /**
  8827. * Multiplies the width and height by numbers
  8828. * @param w factor to multiple the width by
  8829. * @param h factor to multiple the height by
  8830. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8831. */
  8832. multiplyByFloats(w: number, h: number): Size;
  8833. /**
  8834. * Clones the size
  8835. * @returns a new Size copied from the given one.
  8836. */
  8837. clone(): Size;
  8838. /**
  8839. * True if the current Size and the given one width and height are strictly equal.
  8840. * @param other the other size to compare against
  8841. * @returns True if the current Size and the given one width and height are strictly equal.
  8842. */
  8843. equals(other: Size): boolean;
  8844. /**
  8845. * The surface of the Size : width * height (float).
  8846. */
  8847. get surface(): number;
  8848. /**
  8849. * Create a new size of zero
  8850. * @returns a new Size set to (0.0, 0.0)
  8851. */
  8852. static Zero(): Size;
  8853. /**
  8854. * Sums the width and height of two sizes
  8855. * @param otherSize size to add to this size
  8856. * @returns a new Size set as the addition result of the current Size and the given one.
  8857. */
  8858. add(otherSize: Size): Size;
  8859. /**
  8860. * Subtracts the width and height of two
  8861. * @param otherSize size to subtract to this size
  8862. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8863. */
  8864. subtract(otherSize: Size): Size;
  8865. /**
  8866. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8867. * @param start starting size to lerp between
  8868. * @param end end size to lerp between
  8869. * @param amount amount to lerp between the start and end values
  8870. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8871. */
  8872. static Lerp(start: Size, end: Size, amount: number): Size;
  8873. }
  8874. }
  8875. declare module BABYLON {
  8876. /**
  8877. * Contains position and normal vectors for a vertex
  8878. */
  8879. export class PositionNormalVertex {
  8880. /** the position of the vertex (defaut: 0,0,0) */
  8881. position: Vector3;
  8882. /** the normal of the vertex (defaut: 0,1,0) */
  8883. normal: Vector3;
  8884. /**
  8885. * Creates a PositionNormalVertex
  8886. * @param position the position of the vertex (defaut: 0,0,0)
  8887. * @param normal the normal of the vertex (defaut: 0,1,0)
  8888. */
  8889. constructor(
  8890. /** the position of the vertex (defaut: 0,0,0) */
  8891. position?: Vector3,
  8892. /** the normal of the vertex (defaut: 0,1,0) */
  8893. normal?: Vector3);
  8894. /**
  8895. * Clones the PositionNormalVertex
  8896. * @returns the cloned PositionNormalVertex
  8897. */
  8898. clone(): PositionNormalVertex;
  8899. }
  8900. /**
  8901. * Contains position, normal and uv vectors for a vertex
  8902. */
  8903. export class PositionNormalTextureVertex {
  8904. /** the position of the vertex (defaut: 0,0,0) */
  8905. position: Vector3;
  8906. /** the normal of the vertex (defaut: 0,1,0) */
  8907. normal: Vector3;
  8908. /** the uv of the vertex (default: 0,0) */
  8909. uv: Vector2;
  8910. /**
  8911. * Creates a PositionNormalTextureVertex
  8912. * @param position the position of the vertex (defaut: 0,0,0)
  8913. * @param normal the normal of the vertex (defaut: 0,1,0)
  8914. * @param uv the uv of the vertex (default: 0,0)
  8915. */
  8916. constructor(
  8917. /** the position of the vertex (defaut: 0,0,0) */
  8918. position?: Vector3,
  8919. /** the normal of the vertex (defaut: 0,1,0) */
  8920. normal?: Vector3,
  8921. /** the uv of the vertex (default: 0,0) */
  8922. uv?: Vector2);
  8923. /**
  8924. * Clones the PositionNormalTextureVertex
  8925. * @returns the cloned PositionNormalTextureVertex
  8926. */
  8927. clone(): PositionNormalTextureVertex;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Enum defining the type of animations supported by InputBlock
  8933. */
  8934. export enum AnimatedInputBlockTypes {
  8935. /** No animation */
  8936. None = 0,
  8937. /** Time based animation. Will only work for floats */
  8938. Time = 1
  8939. }
  8940. }
  8941. declare module BABYLON {
  8942. /**
  8943. * Interface describing all the common properties and methods a shadow light needs to implement.
  8944. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8945. * as well as binding the different shadow properties to the effects.
  8946. */
  8947. export interface IShadowLight extends Light {
  8948. /**
  8949. * The light id in the scene (used in scene.findLighById for instance)
  8950. */
  8951. id: string;
  8952. /**
  8953. * The position the shdow will be casted from.
  8954. */
  8955. position: Vector3;
  8956. /**
  8957. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8958. */
  8959. direction: Vector3;
  8960. /**
  8961. * The transformed position. Position of the light in world space taking parenting in account.
  8962. */
  8963. transformedPosition: Vector3;
  8964. /**
  8965. * The transformed direction. Direction of the light in world space taking parenting in account.
  8966. */
  8967. transformedDirection: Vector3;
  8968. /**
  8969. * The friendly name of the light in the scene.
  8970. */
  8971. name: string;
  8972. /**
  8973. * Defines the shadow projection clipping minimum z value.
  8974. */
  8975. shadowMinZ: number;
  8976. /**
  8977. * Defines the shadow projection clipping maximum z value.
  8978. */
  8979. shadowMaxZ: number;
  8980. /**
  8981. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8982. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8983. */
  8984. computeTransformedInformation(): boolean;
  8985. /**
  8986. * Gets the scene the light belongs to.
  8987. * @returns The scene
  8988. */
  8989. getScene(): Scene;
  8990. /**
  8991. * Callback defining a custom Projection Matrix Builder.
  8992. * This can be used to override the default projection matrix computation.
  8993. */
  8994. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8995. /**
  8996. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8997. * @param matrix The materix to updated with the projection information
  8998. * @param viewMatrix The transform matrix of the light
  8999. * @param renderList The list of mesh to render in the map
  9000. * @returns The current light
  9001. */
  9002. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9003. /**
  9004. * Gets the current depth scale used in ESM.
  9005. * @returns The scale
  9006. */
  9007. getDepthScale(): number;
  9008. /**
  9009. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9010. * @returns true if a cube texture needs to be use
  9011. */
  9012. needCube(): boolean;
  9013. /**
  9014. * Detects if the projection matrix requires to be recomputed this frame.
  9015. * @returns true if it requires to be recomputed otherwise, false.
  9016. */
  9017. needProjectionMatrixCompute(): boolean;
  9018. /**
  9019. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9020. */
  9021. forceProjectionMatrixCompute(): void;
  9022. /**
  9023. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9024. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9025. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9026. */
  9027. getShadowDirection(faceIndex?: number): Vector3;
  9028. /**
  9029. * Gets the minZ used for shadow according to both the scene and the light.
  9030. * @param activeCamera The camera we are returning the min for
  9031. * @returns the depth min z
  9032. */
  9033. getDepthMinZ(activeCamera: Camera): number;
  9034. /**
  9035. * Gets the maxZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the max for
  9037. * @returns the depth max z
  9038. */
  9039. getDepthMaxZ(activeCamera: Camera): number;
  9040. }
  9041. /**
  9042. * Base implementation IShadowLight
  9043. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9044. */
  9045. export abstract class ShadowLight extends Light implements IShadowLight {
  9046. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9047. protected _position: Vector3;
  9048. protected _setPosition(value: Vector3): void;
  9049. /**
  9050. * Sets the position the shadow will be casted from. Also use as the light position for both
  9051. * point and spot lights.
  9052. */
  9053. get position(): Vector3;
  9054. /**
  9055. * Sets the position the shadow will be casted from. Also use as the light position for both
  9056. * point and spot lights.
  9057. */
  9058. set position(value: Vector3);
  9059. protected _direction: Vector3;
  9060. protected _setDirection(value: Vector3): void;
  9061. /**
  9062. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9063. * Also use as the light direction on spot and directional lights.
  9064. */
  9065. get direction(): Vector3;
  9066. /**
  9067. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9068. * Also use as the light direction on spot and directional lights.
  9069. */
  9070. set direction(value: Vector3);
  9071. protected _shadowMinZ: number;
  9072. /**
  9073. * Gets the shadow projection clipping minimum z value.
  9074. */
  9075. get shadowMinZ(): number;
  9076. /**
  9077. * Sets the shadow projection clipping minimum z value.
  9078. */
  9079. set shadowMinZ(value: number);
  9080. protected _shadowMaxZ: number;
  9081. /**
  9082. * Sets the shadow projection clipping maximum z value.
  9083. */
  9084. get shadowMaxZ(): number;
  9085. /**
  9086. * Gets the shadow projection clipping maximum z value.
  9087. */
  9088. set shadowMaxZ(value: number);
  9089. /**
  9090. * Callback defining a custom Projection Matrix Builder.
  9091. * This can be used to override the default projection matrix computation.
  9092. */
  9093. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9094. /**
  9095. * The transformed position. Position of the light in world space taking parenting in account.
  9096. */
  9097. transformedPosition: Vector3;
  9098. /**
  9099. * The transformed direction. Direction of the light in world space taking parenting in account.
  9100. */
  9101. transformedDirection: Vector3;
  9102. private _needProjectionMatrixCompute;
  9103. /**
  9104. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9105. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9106. */
  9107. computeTransformedInformation(): boolean;
  9108. /**
  9109. * Return the depth scale used for the shadow map.
  9110. * @returns the depth scale.
  9111. */
  9112. getDepthScale(): number;
  9113. /**
  9114. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9115. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9116. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9117. */
  9118. getShadowDirection(faceIndex?: number): Vector3;
  9119. /**
  9120. * Returns the ShadowLight absolute position in the World.
  9121. * @returns the position vector in world space
  9122. */
  9123. getAbsolutePosition(): Vector3;
  9124. /**
  9125. * Sets the ShadowLight direction toward the passed target.
  9126. * @param target The point to target in local space
  9127. * @returns the updated ShadowLight direction
  9128. */
  9129. setDirectionToTarget(target: Vector3): Vector3;
  9130. /**
  9131. * Returns the light rotation in euler definition.
  9132. * @returns the x y z rotation in local space.
  9133. */
  9134. getRotation(): Vector3;
  9135. /**
  9136. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9137. * @returns true if a cube texture needs to be use
  9138. */
  9139. needCube(): boolean;
  9140. /**
  9141. * Detects if the projection matrix requires to be recomputed this frame.
  9142. * @returns true if it requires to be recomputed otherwise, false.
  9143. */
  9144. needProjectionMatrixCompute(): boolean;
  9145. /**
  9146. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9147. */
  9148. forceProjectionMatrixCompute(): void;
  9149. /** @hidden */
  9150. _initCache(): void;
  9151. /** @hidden */
  9152. _isSynchronized(): boolean;
  9153. /**
  9154. * Computes the world matrix of the node
  9155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9156. * @returns the world matrix
  9157. */
  9158. computeWorldMatrix(force?: boolean): Matrix;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. /**
  9172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9173. * @param matrix The materix to updated with the projection information
  9174. * @param viewMatrix The transform matrix of the light
  9175. * @param renderList The list of mesh to render in the map
  9176. * @returns The current light
  9177. */
  9178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var packingFunctions: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var bayerDitherFunctions: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var shadowMapFragmentDeclaration: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var clipPlaneFragmentDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var clipPlaneFragment: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapFragment: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapPixelShader: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var bonesDeclaration: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var morphTargetsVertexGlobalDeclaration: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var morphTargetsVertexDeclaration: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var instancesDeclaration: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var helperFunctions: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapVertexDeclaration: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var clipPlaneVertexDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var morphTargetsVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var instancesVertex: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var bonesVertex: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var shadowMapVertexNormalBias: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var shadowMapVertexMetric: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var clipPlaneVertex: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var shadowMapVertexShader: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var depthBoxBlurPixelShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var shadowMapFragmentSoftTransparentShadow: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9345. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9346. */
  9347. export class EffectFallbacks implements IEffectFallbacks {
  9348. private _defines;
  9349. private _currentRank;
  9350. private _maxRank;
  9351. private _mesh;
  9352. /**
  9353. * Removes the fallback from the bound mesh.
  9354. */
  9355. unBindMesh(): void;
  9356. /**
  9357. * Adds a fallback on the specified property.
  9358. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9359. * @param define The name of the define in the shader
  9360. */
  9361. addFallback(rank: number, define: string): void;
  9362. /**
  9363. * Sets the mesh to use CPU skinning when needing to fallback.
  9364. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9365. * @param mesh The mesh to use the fallbacks.
  9366. */
  9367. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9368. /**
  9369. * Checks to see if more fallbacks are still availible.
  9370. */
  9371. get hasMoreFallbacks(): boolean;
  9372. /**
  9373. * Removes the defines that should be removed when falling back.
  9374. * @param currentDefines defines the current define statements for the shader.
  9375. * @param effect defines the current effect we try to compile
  9376. * @returns The resulting defines with defines of the current rank removed.
  9377. */
  9378. reduce(currentDefines: string, effect: Effect): string;
  9379. }
  9380. }
  9381. declare module BABYLON {
  9382. /**
  9383. * Interface used to define Action
  9384. */
  9385. export interface IAction {
  9386. /**
  9387. * Trigger for the action
  9388. */
  9389. trigger: number;
  9390. /** Options of the trigger */
  9391. triggerOptions: any;
  9392. /**
  9393. * Gets the trigger parameters
  9394. * @returns the trigger parameters
  9395. */
  9396. getTriggerParameter(): any;
  9397. /**
  9398. * Internal only - executes current action event
  9399. * @hidden
  9400. */
  9401. _executeCurrent(evt?: ActionEvent): void;
  9402. /**
  9403. * Serialize placeholder for child classes
  9404. * @param parent of child
  9405. * @returns the serialized object
  9406. */
  9407. serialize(parent: any): any;
  9408. /**
  9409. * Internal only
  9410. * @hidden
  9411. */
  9412. _prepare(): void;
  9413. /**
  9414. * Internal only - manager for action
  9415. * @hidden
  9416. */
  9417. _actionManager: Nullable<AbstractActionManager>;
  9418. /**
  9419. * Adds action to chain of actions, may be a DoNothingAction
  9420. * @param action defines the next action to execute
  9421. * @returns The action passed in
  9422. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9423. */
  9424. then(action: IAction): IAction;
  9425. }
  9426. /**
  9427. * The action to be carried out following a trigger
  9428. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9429. */
  9430. export class Action implements IAction {
  9431. /** the trigger, with or without parameters, for the action */
  9432. triggerOptions: any;
  9433. /**
  9434. * Trigger for the action
  9435. */
  9436. trigger: number;
  9437. /**
  9438. * Internal only - manager for action
  9439. * @hidden
  9440. */
  9441. _actionManager: ActionManager;
  9442. private _nextActiveAction;
  9443. private _child;
  9444. private _condition?;
  9445. private _triggerParameter;
  9446. /**
  9447. * An event triggered prior to action being executed.
  9448. */
  9449. onBeforeExecuteObservable: Observable<Action>;
  9450. /**
  9451. * Creates a new Action
  9452. * @param triggerOptions the trigger, with or without parameters, for the action
  9453. * @param condition an optional determinant of action
  9454. */
  9455. constructor(
  9456. /** the trigger, with or without parameters, for the action */
  9457. triggerOptions: any, condition?: Condition);
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _prepare(): void;
  9463. /**
  9464. * Gets the trigger parameters
  9465. * @returns the trigger parameters
  9466. */
  9467. getTriggerParameter(): any;
  9468. /**
  9469. * Internal only - executes current action event
  9470. * @hidden
  9471. */
  9472. _executeCurrent(evt?: ActionEvent): void;
  9473. /**
  9474. * Execute placeholder for child classes
  9475. * @param evt optional action event
  9476. */
  9477. execute(evt?: ActionEvent): void;
  9478. /**
  9479. * Skips to next active action
  9480. */
  9481. skipToNextActiveAction(): void;
  9482. /**
  9483. * Adds action to chain of actions, may be a DoNothingAction
  9484. * @param action defines the next action to execute
  9485. * @returns The action passed in
  9486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9487. */
  9488. then(action: Action): Action;
  9489. /**
  9490. * Internal only
  9491. * @hidden
  9492. */
  9493. _getProperty(propertyPath: string): string;
  9494. /**
  9495. * Internal only
  9496. * @hidden
  9497. */
  9498. _getEffectiveTarget(target: any, propertyPath: string): any;
  9499. /**
  9500. * Serialize placeholder for child classes
  9501. * @param parent of child
  9502. * @returns the serialized object
  9503. */
  9504. serialize(parent: any): any;
  9505. /**
  9506. * Internal only called by serialize
  9507. * @hidden
  9508. */
  9509. protected _serialize(serializedAction: any, parent?: any): any;
  9510. /**
  9511. * Internal only
  9512. * @hidden
  9513. */
  9514. static _SerializeValueAsString: (value: any) => string;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. static _GetTargetProperty: (target: Scene | Node) => {
  9520. name: string;
  9521. targetType: string;
  9522. value: string;
  9523. };
  9524. }
  9525. }
  9526. declare module BABYLON {
  9527. /**
  9528. * A Condition applied to an Action
  9529. */
  9530. export class Condition {
  9531. /**
  9532. * Internal only - manager for action
  9533. * @hidden
  9534. */
  9535. _actionManager: ActionManager;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. _evaluationId: number;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. _currentResult: boolean;
  9546. /**
  9547. * Creates a new Condition
  9548. * @param actionManager the manager of the action the condition is applied to
  9549. */
  9550. constructor(actionManager: ActionManager);
  9551. /**
  9552. * Check if the current condition is valid
  9553. * @returns a boolean
  9554. */
  9555. isValid(): boolean;
  9556. /**
  9557. * Internal only
  9558. * @hidden
  9559. */
  9560. _getProperty(propertyPath: string): string;
  9561. /**
  9562. * Internal only
  9563. * @hidden
  9564. */
  9565. _getEffectiveTarget(target: any, propertyPath: string): any;
  9566. /**
  9567. * Serialize placeholder for child classes
  9568. * @returns the serialized object
  9569. */
  9570. serialize(): any;
  9571. /**
  9572. * Internal only
  9573. * @hidden
  9574. */
  9575. protected _serialize(serializedCondition: any): any;
  9576. }
  9577. /**
  9578. * Defines specific conditional operators as extensions of Condition
  9579. */
  9580. export class ValueCondition extends Condition {
  9581. /** path to specify the property of the target the conditional operator uses */
  9582. propertyPath: string;
  9583. /** the value compared by the conditional operator against the current value of the property */
  9584. value: any;
  9585. /** the conditional operator, default ValueCondition.IsEqual */
  9586. operator: number;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. private static _IsEqual;
  9592. /**
  9593. * Internal only
  9594. * @hidden
  9595. */
  9596. private static _IsDifferent;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. private static _IsGreater;
  9602. /**
  9603. * Internal only
  9604. * @hidden
  9605. */
  9606. private static _IsLesser;
  9607. /**
  9608. * returns the number for IsEqual
  9609. */
  9610. static get IsEqual(): number;
  9611. /**
  9612. * Returns the number for IsDifferent
  9613. */
  9614. static get IsDifferent(): number;
  9615. /**
  9616. * Returns the number for IsGreater
  9617. */
  9618. static get IsGreater(): number;
  9619. /**
  9620. * Returns the number for IsLesser
  9621. */
  9622. static get IsLesser(): number;
  9623. /**
  9624. * Internal only The action manager for the condition
  9625. * @hidden
  9626. */
  9627. _actionManager: ActionManager;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private _target;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. private _effectiveTarget;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. private _property;
  9643. /**
  9644. * Creates a new ValueCondition
  9645. * @param actionManager manager for the action the condition applies to
  9646. * @param target for the action
  9647. * @param propertyPath path to specify the property of the target the conditional operator uses
  9648. * @param value the value compared by the conditional operator against the current value of the property
  9649. * @param operator the conditional operator, default ValueCondition.IsEqual
  9650. */
  9651. constructor(actionManager: ActionManager, target: any,
  9652. /** path to specify the property of the target the conditional operator uses */
  9653. propertyPath: string,
  9654. /** the value compared by the conditional operator against the current value of the property */
  9655. value: any,
  9656. /** the conditional operator, default ValueCondition.IsEqual */
  9657. operator?: number);
  9658. /**
  9659. * Compares the given value with the property value for the specified conditional operator
  9660. * @returns the result of the comparison
  9661. */
  9662. isValid(): boolean;
  9663. /**
  9664. * Serialize the ValueCondition into a JSON compatible object
  9665. * @returns serialization object
  9666. */
  9667. serialize(): any;
  9668. /**
  9669. * Gets the name of the conditional operator for the ValueCondition
  9670. * @param operator the conditional operator
  9671. * @returns the name
  9672. */
  9673. static GetOperatorName(operator: number): string;
  9674. }
  9675. /**
  9676. * Defines a predicate condition as an extension of Condition
  9677. */
  9678. export class PredicateCondition extends Condition {
  9679. /** defines the predicate function used to validate the condition */
  9680. predicate: () => boolean;
  9681. /**
  9682. * Internal only - manager for action
  9683. * @hidden
  9684. */
  9685. _actionManager: ActionManager;
  9686. /**
  9687. * Creates a new PredicateCondition
  9688. * @param actionManager manager for the action the condition applies to
  9689. * @param predicate defines the predicate function used to validate the condition
  9690. */
  9691. constructor(actionManager: ActionManager,
  9692. /** defines the predicate function used to validate the condition */
  9693. predicate: () => boolean);
  9694. /**
  9695. * @returns the validity of the predicate condition
  9696. */
  9697. isValid(): boolean;
  9698. }
  9699. /**
  9700. * Defines a state condition as an extension of Condition
  9701. */
  9702. export class StateCondition extends Condition {
  9703. /** Value to compare with target state */
  9704. value: string;
  9705. /**
  9706. * Internal only - manager for action
  9707. * @hidden
  9708. */
  9709. _actionManager: ActionManager;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. private _target;
  9715. /**
  9716. * Creates a new StateCondition
  9717. * @param actionManager manager for the action the condition applies to
  9718. * @param target of the condition
  9719. * @param value to compare with target state
  9720. */
  9721. constructor(actionManager: ActionManager, target: any,
  9722. /** Value to compare with target state */
  9723. value: string);
  9724. /**
  9725. * Gets a boolean indicating if the current condition is met
  9726. * @returns the validity of the state
  9727. */
  9728. isValid(): boolean;
  9729. /**
  9730. * Serialize the StateCondition into a JSON compatible object
  9731. * @returns serialization object
  9732. */
  9733. serialize(): any;
  9734. }
  9735. }
  9736. declare module BABYLON {
  9737. /**
  9738. * This defines an action responsible to toggle a boolean once triggered.
  9739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9740. */
  9741. export class SwitchBooleanAction extends Action {
  9742. /**
  9743. * The path to the boolean property in the target object
  9744. */
  9745. propertyPath: string;
  9746. private _target;
  9747. private _effectiveTarget;
  9748. private _property;
  9749. /**
  9750. * Instantiate the action
  9751. * @param triggerOptions defines the trigger options
  9752. * @param target defines the object containing the boolean
  9753. * @param propertyPath defines the path to the boolean property in the target object
  9754. * @param condition defines the trigger related conditions
  9755. */
  9756. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9757. /** @hidden */
  9758. _prepare(): void;
  9759. /**
  9760. * Execute the action toggle the boolean value.
  9761. */
  9762. execute(): void;
  9763. /**
  9764. * Serializes the actions and its related information.
  9765. * @param parent defines the object to serialize in
  9766. * @returns the serialized object
  9767. */
  9768. serialize(parent: any): any;
  9769. }
  9770. /**
  9771. * This defines an action responsible to set a the state field of the target
  9772. * to a desired value once triggered.
  9773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9774. */
  9775. export class SetStateAction extends Action {
  9776. /**
  9777. * The value to store in the state field.
  9778. */
  9779. value: string;
  9780. private _target;
  9781. /**
  9782. * Instantiate the action
  9783. * @param triggerOptions defines the trigger options
  9784. * @param target defines the object containing the state property
  9785. * @param value defines the value to store in the state field
  9786. * @param condition defines the trigger related conditions
  9787. */
  9788. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9789. /**
  9790. * Execute the action and store the value on the target state property.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to set a property of the target
  9802. * to a desired value once triggered.
  9803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9804. */
  9805. export class SetValueAction extends Action {
  9806. /**
  9807. * The path of the property to set in the target.
  9808. */
  9809. propertyPath: string;
  9810. /**
  9811. * The value to set in the property
  9812. */
  9813. value: any;
  9814. private _target;
  9815. private _effectiveTarget;
  9816. private _property;
  9817. /**
  9818. * Instantiate the action
  9819. * @param triggerOptions defines the trigger options
  9820. * @param target defines the object containing the property
  9821. * @param propertyPath defines the path of the property to set in the target
  9822. * @param value defines the value to set in the property
  9823. * @param condition defines the trigger related conditions
  9824. */
  9825. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9826. /** @hidden */
  9827. _prepare(): void;
  9828. /**
  9829. * Execute the action and set the targetted property to the desired value.
  9830. */
  9831. execute(): void;
  9832. /**
  9833. * Serializes the actions and its related information.
  9834. * @param parent defines the object to serialize in
  9835. * @returns the serialized object
  9836. */
  9837. serialize(parent: any): any;
  9838. }
  9839. /**
  9840. * This defines an action responsible to increment the target value
  9841. * to a desired value once triggered.
  9842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9843. */
  9844. export class IncrementValueAction extends Action {
  9845. /**
  9846. * The path of the property to increment in the target.
  9847. */
  9848. propertyPath: string;
  9849. /**
  9850. * The value we should increment the property by.
  9851. */
  9852. value: any;
  9853. private _target;
  9854. private _effectiveTarget;
  9855. private _property;
  9856. /**
  9857. * Instantiate the action
  9858. * @param triggerOptions defines the trigger options
  9859. * @param target defines the object containing the property
  9860. * @param propertyPath defines the path of the property to increment in the target
  9861. * @param value defines the value value we should increment the property by
  9862. * @param condition defines the trigger related conditions
  9863. */
  9864. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9865. /** @hidden */
  9866. _prepare(): void;
  9867. /**
  9868. * Execute the action and increment the target of the value amount.
  9869. */
  9870. execute(): void;
  9871. /**
  9872. * Serializes the actions and its related information.
  9873. * @param parent defines the object to serialize in
  9874. * @returns the serialized object
  9875. */
  9876. serialize(parent: any): any;
  9877. }
  9878. /**
  9879. * This defines an action responsible to start an animation once triggered.
  9880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class PlayAnimationAction extends Action {
  9883. /**
  9884. * Where the animation should start (animation frame)
  9885. */
  9886. from: number;
  9887. /**
  9888. * Where the animation should stop (animation frame)
  9889. */
  9890. to: number;
  9891. /**
  9892. * Define if the animation should loop or stop after the first play.
  9893. */
  9894. loop?: boolean;
  9895. private _target;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the target animation or animation name
  9900. * @param from defines from where the animation should start (animation frame)
  9901. * @param end defines where the animation should stop (animation frame)
  9902. * @param loop defines if the animation should loop or stop after the first play
  9903. * @param condition defines the trigger related conditions
  9904. */
  9905. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9906. /** @hidden */
  9907. _prepare(): void;
  9908. /**
  9909. * Execute the action and play the animation.
  9910. */
  9911. execute(): void;
  9912. /**
  9913. * Serializes the actions and its related information.
  9914. * @param parent defines the object to serialize in
  9915. * @returns the serialized object
  9916. */
  9917. serialize(parent: any): any;
  9918. }
  9919. /**
  9920. * This defines an action responsible to stop an animation once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class StopAnimationAction extends Action {
  9924. private _target;
  9925. /**
  9926. * Instantiate the action
  9927. * @param triggerOptions defines the trigger options
  9928. * @param target defines the target animation or animation name
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and stop the animation.
  9936. */
  9937. execute(): void;
  9938. /**
  9939. * Serializes the actions and its related information.
  9940. * @param parent defines the object to serialize in
  9941. * @returns the serialized object
  9942. */
  9943. serialize(parent: any): any;
  9944. }
  9945. /**
  9946. * This defines an action responsible that does nothing once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class DoNothingAction extends Action {
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param condition defines the trigger related conditions
  9954. */
  9955. constructor(triggerOptions?: any, condition?: Condition);
  9956. /**
  9957. * Execute the action and do nothing.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. /**
  9968. * This defines an action responsible to trigger several actions once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class CombineAction extends Action {
  9972. /**
  9973. * The list of aggregated animations to run.
  9974. */
  9975. children: Action[];
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param children defines the list of aggregated animations to run
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and executes all the aggregated actions.
  9987. */
  9988. execute(evt: ActionEvent): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to run code (external event) once triggered.
  9998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class ExecuteCodeAction extends Action {
  10001. /**
  10002. * The callback function to run.
  10003. */
  10004. func: (evt: ActionEvent) => void;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param func defines the callback function to run
  10009. * @param condition defines the trigger related conditions
  10010. */
  10011. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10012. /**
  10013. * Execute the action and run the attached code.
  10014. */
  10015. execute(evt: ActionEvent): void;
  10016. }
  10017. /**
  10018. * This defines an action responsible to set the parent property of the target once triggered.
  10019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10020. */
  10021. export class SetParentAction extends Action {
  10022. private _parent;
  10023. private _target;
  10024. /**
  10025. * Instantiate the action
  10026. * @param triggerOptions defines the trigger options
  10027. * @param target defines the target containing the parent property
  10028. * @param parent defines from where the animation should start (animation frame)
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10032. /** @hidden */
  10033. _prepare(): void;
  10034. /**
  10035. * Execute the action and set the parent property.
  10036. */
  10037. execute(): void;
  10038. /**
  10039. * Serializes the actions and its related information.
  10040. * @param parent defines the object to serialize in
  10041. * @returns the serialized object
  10042. */
  10043. serialize(parent: any): any;
  10044. }
  10045. }
  10046. declare module BABYLON {
  10047. /**
  10048. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10049. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10050. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10051. */
  10052. export class ActionManager extends AbstractActionManager {
  10053. /**
  10054. * Nothing
  10055. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10056. */
  10057. static readonly NothingTrigger: number;
  10058. /**
  10059. * On pick
  10060. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10061. */
  10062. static readonly OnPickTrigger: number;
  10063. /**
  10064. * On left pick
  10065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10066. */
  10067. static readonly OnLeftPickTrigger: number;
  10068. /**
  10069. * On right pick
  10070. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10071. */
  10072. static readonly OnRightPickTrigger: number;
  10073. /**
  10074. * On center pick
  10075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10076. */
  10077. static readonly OnCenterPickTrigger: number;
  10078. /**
  10079. * On pick down
  10080. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10081. */
  10082. static readonly OnPickDownTrigger: number;
  10083. /**
  10084. * On double pick
  10085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10086. */
  10087. static readonly OnDoublePickTrigger: number;
  10088. /**
  10089. * On pick up
  10090. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10091. */
  10092. static readonly OnPickUpTrigger: number;
  10093. /**
  10094. * On pick out.
  10095. * This trigger will only be raised if you also declared a OnPickDown
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnPickOutTrigger: number;
  10099. /**
  10100. * On long press
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnLongPressTrigger: number;
  10104. /**
  10105. * On pointer over
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPointerOverTrigger: number;
  10109. /**
  10110. * On pointer out
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnPointerOutTrigger: number;
  10114. /**
  10115. * On every frame
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnEveryFrameTrigger: number;
  10119. /**
  10120. * On intersection enter
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10122. */
  10123. static readonly OnIntersectionEnterTrigger: number;
  10124. /**
  10125. * On intersection exit
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10127. */
  10128. static readonly OnIntersectionExitTrigger: number;
  10129. /**
  10130. * On key down
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10132. */
  10133. static readonly OnKeyDownTrigger: number;
  10134. /**
  10135. * On key up
  10136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10137. */
  10138. static readonly OnKeyUpTrigger: number;
  10139. private _scene;
  10140. /**
  10141. * Creates a new action manager
  10142. * @param scene defines the hosting scene
  10143. */
  10144. constructor(scene: Scene);
  10145. /**
  10146. * Releases all associated resources
  10147. */
  10148. dispose(): void;
  10149. /**
  10150. * Gets hosting scene
  10151. * @returns the hosting scene
  10152. */
  10153. getScene(): Scene;
  10154. /**
  10155. * Does this action manager handles actions of any of the given triggers
  10156. * @param triggers defines the triggers to be tested
  10157. * @return a boolean indicating whether one (or more) of the triggers is handled
  10158. */
  10159. hasSpecificTriggers(triggers: number[]): boolean;
  10160. /**
  10161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10162. * speed.
  10163. * @param triggerA defines the trigger to be tested
  10164. * @param triggerB defines the trigger to be tested
  10165. * @return a boolean indicating whether one (or more) of the triggers is handled
  10166. */
  10167. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10168. /**
  10169. * Does this action manager handles actions of a given trigger
  10170. * @param trigger defines the trigger to be tested
  10171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10172. * @return whether the trigger is handled
  10173. */
  10174. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10175. /**
  10176. * Does this action manager has pointer triggers
  10177. */
  10178. get hasPointerTriggers(): boolean;
  10179. /**
  10180. * Does this action manager has pick triggers
  10181. */
  10182. get hasPickTriggers(): boolean;
  10183. /**
  10184. * Registers an action to this action manager
  10185. * @param action defines the action to be registered
  10186. * @return the action amended (prepared) after registration
  10187. */
  10188. registerAction(action: IAction): Nullable<IAction>;
  10189. /**
  10190. * Unregisters an action to this action manager
  10191. * @param action defines the action to be unregistered
  10192. * @return a boolean indicating whether the action has been unregistered
  10193. */
  10194. unregisterAction(action: IAction): Boolean;
  10195. /**
  10196. * Process a specific trigger
  10197. * @param trigger defines the trigger to process
  10198. * @param evt defines the event details to be processed
  10199. */
  10200. processTrigger(trigger: number, evt?: IActionEvent): void;
  10201. /** @hidden */
  10202. _getEffectiveTarget(target: any, propertyPath: string): any;
  10203. /** @hidden */
  10204. _getProperty(propertyPath: string): string;
  10205. /**
  10206. * Serialize this manager to a JSON object
  10207. * @param name defines the property name to store this manager
  10208. * @returns a JSON representation of this manager
  10209. */
  10210. serialize(name: string): any;
  10211. /**
  10212. * Creates a new ActionManager from a JSON data
  10213. * @param parsedActions defines the JSON data to read from
  10214. * @param object defines the hosting mesh
  10215. * @param scene defines the hosting scene
  10216. */
  10217. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10218. /**
  10219. * Get a trigger name by index
  10220. * @param trigger defines the trigger index
  10221. * @returns a trigger name
  10222. */
  10223. static GetTriggerName(trigger: number): string;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Class used to represent a sprite
  10229. * @see https://doc.babylonjs.com/babylon101/sprites
  10230. */
  10231. export class Sprite implements IAnimatable {
  10232. /** defines the name */
  10233. name: string;
  10234. /** Gets or sets the current world position */
  10235. position: Vector3;
  10236. /** Gets or sets the main color */
  10237. color: Color4;
  10238. /** Gets or sets the width */
  10239. width: number;
  10240. /** Gets or sets the height */
  10241. height: number;
  10242. /** Gets or sets rotation angle */
  10243. angle: number;
  10244. /** Gets or sets the cell index in the sprite sheet */
  10245. cellIndex: number;
  10246. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10247. cellRef: string;
  10248. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10249. invertU: boolean;
  10250. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10251. invertV: boolean;
  10252. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10253. disposeWhenFinishedAnimating: boolean;
  10254. /** Gets the list of attached animations */
  10255. animations: Nullable<Array<Animation>>;
  10256. /** Gets or sets a boolean indicating if the sprite can be picked */
  10257. isPickable: boolean;
  10258. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10259. useAlphaForPicking: boolean;
  10260. /** @hidden */
  10261. _xOffset: number;
  10262. /** @hidden */
  10263. _yOffset: number;
  10264. /** @hidden */
  10265. _xSize: number;
  10266. /** @hidden */
  10267. _ySize: number;
  10268. /**
  10269. * Gets or sets the associated action manager
  10270. */
  10271. actionManager: Nullable<ActionManager>;
  10272. /**
  10273. * An event triggered when the control has been disposed
  10274. */
  10275. onDisposeObservable: Observable<Sprite>;
  10276. private _animationStarted;
  10277. private _loopAnimation;
  10278. private _fromIndex;
  10279. private _toIndex;
  10280. private _delay;
  10281. private _direction;
  10282. private _manager;
  10283. private _time;
  10284. private _onAnimationEnd;
  10285. /**
  10286. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10287. */
  10288. isVisible: boolean;
  10289. /**
  10290. * Gets or sets the sprite size
  10291. */
  10292. get size(): number;
  10293. set size(value: number);
  10294. /**
  10295. * Returns a boolean indicating if the animation is started
  10296. */
  10297. get animationStarted(): boolean;
  10298. /**
  10299. * Gets or sets the unique id of the sprite
  10300. */
  10301. uniqueId: number;
  10302. /**
  10303. * Gets the manager of this sprite
  10304. */
  10305. get manager(): ISpriteManager;
  10306. /**
  10307. * Creates a new Sprite
  10308. * @param name defines the name
  10309. * @param manager defines the manager
  10310. */
  10311. constructor(
  10312. /** defines the name */
  10313. name: string, manager: ISpriteManager);
  10314. /**
  10315. * Returns the string "Sprite"
  10316. * @returns "Sprite"
  10317. */
  10318. getClassName(): string;
  10319. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10320. get fromIndex(): number;
  10321. set fromIndex(value: number);
  10322. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10323. get toIndex(): number;
  10324. set toIndex(value: number);
  10325. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10326. get loopAnimation(): boolean;
  10327. set loopAnimation(value: boolean);
  10328. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10329. get delay(): number;
  10330. set delay(value: number);
  10331. /**
  10332. * Starts an animation
  10333. * @param from defines the initial key
  10334. * @param to defines the end key
  10335. * @param loop defines if the animation must loop
  10336. * @param delay defines the start delay (in ms)
  10337. * @param onAnimationEnd defines a callback to call when animation ends
  10338. */
  10339. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10340. /** Stops current animation (if any) */
  10341. stopAnimation(): void;
  10342. /** @hidden */
  10343. _animate(deltaTime: number): void;
  10344. /** Release associated resources */
  10345. dispose(): void;
  10346. /**
  10347. * Serializes the sprite to a JSON object
  10348. * @returns the JSON object
  10349. */
  10350. serialize(): any;
  10351. /**
  10352. * Parses a JSON object to create a new sprite
  10353. * @param parsedSprite The JSON object to parse
  10354. * @param manager defines the hosting manager
  10355. * @returns the new sprite
  10356. */
  10357. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10358. }
  10359. }
  10360. declare module BABYLON {
  10361. /**
  10362. * Information about the result of picking within a scene
  10363. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10364. */
  10365. export class PickingInfo {
  10366. /** @hidden */
  10367. _pickingUnavailable: boolean;
  10368. /**
  10369. * If the pick collided with an object
  10370. */
  10371. hit: boolean;
  10372. /**
  10373. * Distance away where the pick collided
  10374. */
  10375. distance: number;
  10376. /**
  10377. * The location of pick collision
  10378. */
  10379. pickedPoint: Nullable<Vector3>;
  10380. /**
  10381. * The mesh corresponding the the pick collision
  10382. */
  10383. pickedMesh: Nullable<AbstractMesh>;
  10384. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10385. bu: number;
  10386. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10387. bv: number;
  10388. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10389. faceId: number;
  10390. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10391. subMeshFaceId: number;
  10392. /** Id of the the submesh that was picked */
  10393. subMeshId: number;
  10394. /** If a sprite was picked, this will be the sprite the pick collided with */
  10395. pickedSprite: Nullable<Sprite>;
  10396. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10397. thinInstanceIndex: number;
  10398. /**
  10399. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10400. */
  10401. originMesh: Nullable<AbstractMesh>;
  10402. /**
  10403. * The ray that was used to perform the picking.
  10404. */
  10405. ray: Nullable<Ray>;
  10406. /**
  10407. * Gets the normal correspodning to the face the pick collided with
  10408. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10409. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10410. * @returns The normal correspodning to the face the pick collided with
  10411. */
  10412. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10413. /**
  10414. * Gets the texture coordinates of where the pick occured
  10415. * @returns the vector containing the coordnates of the texture
  10416. */
  10417. getTextureCoordinates(): Nullable<Vector2>;
  10418. }
  10419. }
  10420. declare module BABYLON {
  10421. /**
  10422. * Class representing a ray with position and direction
  10423. */
  10424. export class Ray {
  10425. /** origin point */
  10426. origin: Vector3;
  10427. /** direction */
  10428. direction: Vector3;
  10429. /** length of the ray */
  10430. length: number;
  10431. private static readonly _TmpVector3;
  10432. private _tmpRay;
  10433. /**
  10434. * Creates a new ray
  10435. * @param origin origin point
  10436. * @param direction direction
  10437. * @param length length of the ray
  10438. */
  10439. constructor(
  10440. /** origin point */
  10441. origin: Vector3,
  10442. /** direction */
  10443. direction: Vector3,
  10444. /** length of the ray */
  10445. length?: number);
  10446. /**
  10447. * Checks if the ray intersects a box
  10448. * This does not account for the ray lenght by design to improve perfs.
  10449. * @param minimum bound of the box
  10450. * @param maximum bound of the box
  10451. * @param intersectionTreshold extra extend to be added to the box in all direction
  10452. * @returns if the box was hit
  10453. */
  10454. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10455. /**
  10456. * Checks if the ray intersects a box
  10457. * This does not account for the ray lenght by design to improve perfs.
  10458. * @param box the bounding box to check
  10459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10460. * @returns if the box was hit
  10461. */
  10462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10463. /**
  10464. * If the ray hits a sphere
  10465. * @param sphere the bounding sphere to check
  10466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10467. * @returns true if it hits the sphere
  10468. */
  10469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10470. /**
  10471. * If the ray hits a triange
  10472. * @param vertex0 triangle vertex
  10473. * @param vertex1 triangle vertex
  10474. * @param vertex2 triangle vertex
  10475. * @returns intersection information if hit
  10476. */
  10477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10478. /**
  10479. * Checks if ray intersects a plane
  10480. * @param plane the plane to check
  10481. * @returns the distance away it was hit
  10482. */
  10483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10484. /**
  10485. * Calculate the intercept of a ray on a given axis
  10486. * @param axis to check 'x' | 'y' | 'z'
  10487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10489. */
  10490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10491. /**
  10492. * Checks if ray intersects a mesh
  10493. * @param mesh the mesh to check
  10494. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10495. * @returns picking info of the intersecton
  10496. */
  10497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10498. /**
  10499. * Checks if ray intersects a mesh
  10500. * @param meshes the meshes to check
  10501. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10502. * @param results array to store result in
  10503. * @returns Array of picking infos
  10504. */
  10505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10506. private _comparePickingInfo;
  10507. private static smallnum;
  10508. private static rayl;
  10509. /**
  10510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10511. * @param sega the first point of the segment to test the intersection against
  10512. * @param segb the second point of the segment to test the intersection against
  10513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10515. */
  10516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10517. /**
  10518. * Update the ray from viewport position
  10519. * @param x position
  10520. * @param y y position
  10521. * @param viewportWidth viewport width
  10522. * @param viewportHeight viewport height
  10523. * @param world world matrix
  10524. * @param view view matrix
  10525. * @param projection projection matrix
  10526. * @returns this ray updated
  10527. */
  10528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10529. /**
  10530. * Creates a ray with origin and direction of 0,0,0
  10531. * @returns the new ray
  10532. */
  10533. static Zero(): Ray;
  10534. /**
  10535. * Creates a new ray from screen space and viewport
  10536. * @param x position
  10537. * @param y y position
  10538. * @param viewportWidth viewport width
  10539. * @param viewportHeight viewport height
  10540. * @param world world matrix
  10541. * @param view view matrix
  10542. * @param projection projection matrix
  10543. * @returns new ray
  10544. */
  10545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10546. /**
  10547. * 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
  10548. * transformed to the given world matrix.
  10549. * @param origin The origin point
  10550. * @param end The end point
  10551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10552. * @returns the new ray
  10553. */
  10554. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10555. /**
  10556. * Transforms a ray by a matrix
  10557. * @param ray ray to transform
  10558. * @param matrix matrix to apply
  10559. * @returns the resulting new ray
  10560. */
  10561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10562. /**
  10563. * Transforms a ray by a matrix
  10564. * @param ray ray to transform
  10565. * @param matrix matrix to apply
  10566. * @param result ray to store result in
  10567. */
  10568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10569. /**
  10570. * Unproject a ray from screen space to object space
  10571. * @param sourceX defines the screen space x coordinate to use
  10572. * @param sourceY defines the screen space y coordinate to use
  10573. * @param viewportWidth defines the current width of the viewport
  10574. * @param viewportHeight defines the current height of the viewport
  10575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10576. * @param view defines the view matrix to use
  10577. * @param projection defines the projection matrix to use
  10578. */
  10579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10580. }
  10581. /**
  10582. * Type used to define predicate used to select faces when a mesh intersection is detected
  10583. */
  10584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10585. interface Scene {
  10586. /** @hidden */
  10587. _tempPickingRay: Nullable<Ray>;
  10588. /** @hidden */
  10589. _cachedRayForTransform: Ray;
  10590. /** @hidden */
  10591. _pickWithRayInverseMatrix: Matrix;
  10592. /** @hidden */
  10593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10594. /** @hidden */
  10595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10596. /** @hidden */
  10597. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10598. }
  10599. }
  10600. declare module BABYLON {
  10601. /**
  10602. * Groups all the scene component constants in one place to ease maintenance.
  10603. * @hidden
  10604. */
  10605. export class SceneComponentConstants {
  10606. static readonly NAME_EFFECTLAYER: string;
  10607. static readonly NAME_LAYER: string;
  10608. static readonly NAME_LENSFLARESYSTEM: string;
  10609. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10610. static readonly NAME_PARTICLESYSTEM: string;
  10611. static readonly NAME_GAMEPAD: string;
  10612. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10613. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10614. static readonly NAME_PREPASSRENDERER: string;
  10615. static readonly NAME_DEPTHRENDERER: string;
  10616. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10617. static readonly NAME_SPRITE: string;
  10618. static readonly NAME_OUTLINERENDERER: string;
  10619. static readonly NAME_PROCEDURALTEXTURE: string;
  10620. static readonly NAME_SHADOWGENERATOR: string;
  10621. static readonly NAME_OCTREE: string;
  10622. static readonly NAME_PHYSICSENGINE: string;
  10623. static readonly NAME_AUDIO: string;
  10624. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10625. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10626. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10627. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10628. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10629. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10630. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10631. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10632. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10633. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10634. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10635. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10636. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10637. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10638. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10639. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10640. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10641. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10642. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10643. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10644. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10645. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10646. static readonly STEP_AFTERRENDER_AUDIO: number;
  10647. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10648. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10649. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10650. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10651. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10652. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10653. static readonly STEP_POINTERMOVE_SPRITE: number;
  10654. static readonly STEP_POINTERDOWN_SPRITE: number;
  10655. static readonly STEP_POINTERUP_SPRITE: number;
  10656. }
  10657. /**
  10658. * This represents a scene component.
  10659. *
  10660. * This is used to decouple the dependency the scene is having on the different workloads like
  10661. * layers, post processes...
  10662. */
  10663. export interface ISceneComponent {
  10664. /**
  10665. * The name of the component. Each component must have a unique name.
  10666. */
  10667. name: string;
  10668. /**
  10669. * The scene the component belongs to.
  10670. */
  10671. scene: Scene;
  10672. /**
  10673. * Register the component to one instance of a scene.
  10674. */
  10675. register(): void;
  10676. /**
  10677. * Rebuilds the elements related to this component in case of
  10678. * context lost for instance.
  10679. */
  10680. rebuild(): void;
  10681. /**
  10682. * Disposes the component and the associated ressources.
  10683. */
  10684. dispose(): void;
  10685. }
  10686. /**
  10687. * This represents a SERIALIZABLE scene component.
  10688. *
  10689. * This extends Scene Component to add Serialization methods on top.
  10690. */
  10691. export interface ISceneSerializableComponent extends ISceneComponent {
  10692. /**
  10693. * Adds all the elements from the container to the scene
  10694. * @param container the container holding the elements
  10695. */
  10696. addFromContainer(container: AbstractScene): void;
  10697. /**
  10698. * Removes all the elements in the container from the scene
  10699. * @param container contains the elements to remove
  10700. * @param dispose if the removed element should be disposed (default: false)
  10701. */
  10702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10703. /**
  10704. * Serializes the component data to the specified json object
  10705. * @param serializationObject The object to serialize to
  10706. */
  10707. serialize(serializationObject: any): void;
  10708. }
  10709. /**
  10710. * Strong typing of a Mesh related stage step action
  10711. */
  10712. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10713. /**
  10714. * Strong typing of a Evaluate Sub Mesh related stage step action
  10715. */
  10716. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10717. /**
  10718. * Strong typing of a Active Mesh related stage step action
  10719. */
  10720. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10721. /**
  10722. * Strong typing of a Camera related stage step action
  10723. */
  10724. export type CameraStageAction = (camera: Camera) => void;
  10725. /**
  10726. * Strong typing of a Camera Frame buffer related stage step action
  10727. */
  10728. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10729. /**
  10730. * Strong typing of a Render Target related stage step action
  10731. */
  10732. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10733. /**
  10734. * Strong typing of a RenderingGroup related stage step action
  10735. */
  10736. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10737. /**
  10738. * Strong typing of a Mesh Render related stage step action
  10739. */
  10740. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10741. /**
  10742. * Strong typing of a simple stage step action
  10743. */
  10744. export type SimpleStageAction = () => void;
  10745. /**
  10746. * Strong typing of a render target action.
  10747. */
  10748. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10749. /**
  10750. * Strong typing of a pointer move action.
  10751. */
  10752. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10753. /**
  10754. * Strong typing of a pointer up/down action.
  10755. */
  10756. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10757. /**
  10758. * Representation of a stage in the scene (Basically a list of ordered steps)
  10759. * @hidden
  10760. */
  10761. export class Stage<T extends Function> extends Array<{
  10762. index: number;
  10763. component: ISceneComponent;
  10764. action: T;
  10765. }> {
  10766. /**
  10767. * Hide ctor from the rest of the world.
  10768. * @param items The items to add.
  10769. */
  10770. private constructor();
  10771. /**
  10772. * Creates a new Stage.
  10773. * @returns A new instance of a Stage
  10774. */
  10775. static Create<T extends Function>(): Stage<T>;
  10776. /**
  10777. * Registers a step in an ordered way in the targeted stage.
  10778. * @param index Defines the position to register the step in
  10779. * @param component Defines the component attached to the step
  10780. * @param action Defines the action to launch during the step
  10781. */
  10782. registerStep(index: number, component: ISceneComponent, action: T): void;
  10783. /**
  10784. * Clears all the steps from the stage.
  10785. */
  10786. clear(): void;
  10787. }
  10788. }
  10789. declare module BABYLON {
  10790. interface Scene {
  10791. /** @hidden */
  10792. _pointerOverSprite: Nullable<Sprite>;
  10793. /** @hidden */
  10794. _pickedDownSprite: Nullable<Sprite>;
  10795. /** @hidden */
  10796. _tempSpritePickingRay: Nullable<Ray>;
  10797. /**
  10798. * All of the sprite managers added to this scene
  10799. * @see https://doc.babylonjs.com/babylon101/sprites
  10800. */
  10801. spriteManagers: Array<ISpriteManager>;
  10802. /**
  10803. * An event triggered when sprites rendering is about to start
  10804. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10805. */
  10806. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10807. /**
  10808. * An event triggered when sprites rendering is done
  10809. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10810. */
  10811. onAfterSpritesRenderingObservable: Observable<Scene>;
  10812. /** @hidden */
  10813. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10814. /** Launch a ray to try to pick a sprite in the scene
  10815. * @param x position on screen
  10816. * @param y position on screen
  10817. * @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
  10818. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10819. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10820. * @returns a PickingInfo
  10821. */
  10822. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10823. /** Use the given ray to pick a sprite in the scene
  10824. * @param ray The ray (in world space) to use to pick meshes
  10825. * @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
  10826. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10827. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10828. * @returns a PickingInfo
  10829. */
  10830. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10831. /** @hidden */
  10832. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10833. /** Launch a ray to try to pick sprites in the scene
  10834. * @param x position on screen
  10835. * @param y position on screen
  10836. * @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
  10837. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10838. * @returns a PickingInfo array
  10839. */
  10840. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10841. /** Use the given ray to pick sprites in the scene
  10842. * @param ray The ray (in world space) to use to pick meshes
  10843. * @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
  10844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10845. * @returns a PickingInfo array
  10846. */
  10847. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10848. /**
  10849. * Force the sprite under the pointer
  10850. * @param sprite defines the sprite to use
  10851. */
  10852. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10853. /**
  10854. * Gets the sprite under the pointer
  10855. * @returns a Sprite or null if no sprite is under the pointer
  10856. */
  10857. getPointerOverSprite(): Nullable<Sprite>;
  10858. }
  10859. /**
  10860. * Defines the sprite scene component responsible to manage sprites
  10861. * in a given scene.
  10862. */
  10863. export class SpriteSceneComponent implements ISceneComponent {
  10864. /**
  10865. * The component name helpfull to identify the component in the list of scene components.
  10866. */
  10867. readonly name: string;
  10868. /**
  10869. * The scene the component belongs to.
  10870. */
  10871. scene: Scene;
  10872. /** @hidden */
  10873. private _spritePredicate;
  10874. /**
  10875. * Creates a new instance of the component for the given scene
  10876. * @param scene Defines the scene to register the component in
  10877. */
  10878. constructor(scene: Scene);
  10879. /**
  10880. * Registers the component in a given scene
  10881. */
  10882. register(): void;
  10883. /**
  10884. * Rebuilds the elements related to this component in case of
  10885. * context lost for instance.
  10886. */
  10887. rebuild(): void;
  10888. /**
  10889. * Disposes the component and the associated ressources.
  10890. */
  10891. dispose(): void;
  10892. private _pickSpriteButKeepRay;
  10893. private _pointerMove;
  10894. private _pointerDown;
  10895. private _pointerUp;
  10896. }
  10897. }
  10898. declare module BABYLON {
  10899. /** @hidden */
  10900. export var fogFragmentDeclaration: {
  10901. name: string;
  10902. shader: string;
  10903. };
  10904. }
  10905. declare module BABYLON {
  10906. /** @hidden */
  10907. export var fogFragment: {
  10908. name: string;
  10909. shader: string;
  10910. };
  10911. }
  10912. declare module BABYLON {
  10913. /** @hidden */
  10914. export var spritesPixelShader: {
  10915. name: string;
  10916. shader: string;
  10917. };
  10918. }
  10919. declare module BABYLON {
  10920. /** @hidden */
  10921. export var fogVertexDeclaration: {
  10922. name: string;
  10923. shader: string;
  10924. };
  10925. }
  10926. declare module BABYLON {
  10927. /** @hidden */
  10928. export var spritesVertexShader: {
  10929. name: string;
  10930. shader: string;
  10931. };
  10932. }
  10933. declare module BABYLON {
  10934. /**
  10935. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10936. */
  10937. export interface ISpriteManager extends IDisposable {
  10938. /**
  10939. * Gets manager's name
  10940. */
  10941. name: string;
  10942. /**
  10943. * Restricts the camera to viewing objects with the same layerMask.
  10944. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10945. */
  10946. layerMask: number;
  10947. /**
  10948. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10949. */
  10950. isPickable: boolean;
  10951. /**
  10952. * Gets the hosting scene
  10953. */
  10954. scene: Scene;
  10955. /**
  10956. * Specifies the rendering group id for this mesh (0 by default)
  10957. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10958. */
  10959. renderingGroupId: number;
  10960. /**
  10961. * Defines the list of sprites managed by the manager.
  10962. */
  10963. sprites: Array<Sprite>;
  10964. /**
  10965. * Gets or sets the spritesheet texture
  10966. */
  10967. texture: Texture;
  10968. /** Defines the default width of a cell in the spritesheet */
  10969. cellWidth: number;
  10970. /** Defines the default height of a cell in the spritesheet */
  10971. cellHeight: number;
  10972. /**
  10973. * Tests the intersection of a sprite with a specific ray.
  10974. * @param ray The ray we are sending to test the collision
  10975. * @param camera The camera space we are sending rays in
  10976. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10977. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10978. * @returns picking info or null.
  10979. */
  10980. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10981. /**
  10982. * Intersects the sprites with a ray
  10983. * @param ray defines the ray to intersect with
  10984. * @param camera defines the current active camera
  10985. * @param predicate defines a predicate used to select candidate sprites
  10986. * @returns null if no hit or a PickingInfo array
  10987. */
  10988. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10989. /**
  10990. * Renders the list of sprites on screen.
  10991. */
  10992. render(): void;
  10993. }
  10994. /**
  10995. * Class used to manage multiple sprites on the same spritesheet
  10996. * @see https://doc.babylonjs.com/babylon101/sprites
  10997. */
  10998. export class SpriteManager implements ISpriteManager {
  10999. /** defines the manager's name */
  11000. name: string;
  11001. /** Define the Url to load snippets */
  11002. static SnippetUrl: string;
  11003. /** Snippet ID if the manager was created from the snippet server */
  11004. snippetId: string;
  11005. /** Gets the list of sprites */
  11006. sprites: Sprite[];
  11007. /** Gets or sets the rendering group id (0 by default) */
  11008. renderingGroupId: number;
  11009. /** Gets or sets camera layer mask */
  11010. layerMask: number;
  11011. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11012. fogEnabled: boolean;
  11013. /** Gets or sets a boolean indicating if the sprites are pickable */
  11014. isPickable: boolean;
  11015. /** Defines the default width of a cell in the spritesheet */
  11016. cellWidth: number;
  11017. /** Defines the default height of a cell in the spritesheet */
  11018. cellHeight: number;
  11019. /** Associative array from JSON sprite data file */
  11020. private _cellData;
  11021. /** Array of sprite names from JSON sprite data file */
  11022. private _spriteMap;
  11023. /** True when packed cell data from JSON file is ready*/
  11024. private _packedAndReady;
  11025. private _textureContent;
  11026. private _useInstancing;
  11027. /**
  11028. * An event triggered when the manager is disposed.
  11029. */
  11030. onDisposeObservable: Observable<SpriteManager>;
  11031. private _onDisposeObserver;
  11032. /**
  11033. * Callback called when the manager is disposed
  11034. */
  11035. set onDispose(callback: () => void);
  11036. private _capacity;
  11037. private _fromPacked;
  11038. private _spriteTexture;
  11039. private _epsilon;
  11040. private _scene;
  11041. private _vertexData;
  11042. private _buffer;
  11043. private _vertexBuffers;
  11044. private _spriteBuffer;
  11045. private _indexBuffer;
  11046. private _effectBase;
  11047. private _effectFog;
  11048. private _vertexBufferSize;
  11049. /**
  11050. * Gets or sets the unique id of the sprite
  11051. */
  11052. uniqueId: number;
  11053. /**
  11054. * Gets the array of sprites
  11055. */
  11056. get children(): Sprite[];
  11057. /**
  11058. * Gets the hosting scene
  11059. */
  11060. get scene(): Scene;
  11061. /**
  11062. * Gets the capacity of the manager
  11063. */
  11064. get capacity(): number;
  11065. /**
  11066. * Gets or sets the spritesheet texture
  11067. */
  11068. get texture(): Texture;
  11069. set texture(value: Texture);
  11070. private _blendMode;
  11071. /**
  11072. * Blend mode use to render the particle, it can be any of
  11073. * the static Constants.ALPHA_x properties provided in this class.
  11074. * Default value is Constants.ALPHA_COMBINE
  11075. */
  11076. get blendMode(): number;
  11077. set blendMode(blendMode: number);
  11078. /** Disables writing to the depth buffer when rendering the sprites.
  11079. * It can be handy to disable depth writing when using textures without alpha channel
  11080. * and setting some specific blend modes.
  11081. */
  11082. disableDepthWrite: boolean;
  11083. /**
  11084. * Creates a new sprite manager
  11085. * @param name defines the manager's name
  11086. * @param imgUrl defines the sprite sheet url
  11087. * @param capacity defines the maximum allowed number of sprites
  11088. * @param cellSize defines the size of a sprite cell
  11089. * @param scene defines the hosting scene
  11090. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11091. * @param samplingMode defines the smapling mode to use with spritesheet
  11092. * @param fromPacked set to false; do not alter
  11093. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11094. */
  11095. constructor(
  11096. /** defines the manager's name */
  11097. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11098. /**
  11099. * Returns the string "SpriteManager"
  11100. * @returns "SpriteManager"
  11101. */
  11102. getClassName(): string;
  11103. private _makePacked;
  11104. private _appendSpriteVertex;
  11105. private _checkTextureAlpha;
  11106. /**
  11107. * Intersects the sprites with a ray
  11108. * @param ray defines the ray to intersect with
  11109. * @param camera defines the current active camera
  11110. * @param predicate defines a predicate used to select candidate sprites
  11111. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11112. * @returns null if no hit or a PickingInfo
  11113. */
  11114. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11115. /**
  11116. * Intersects the sprites with a ray
  11117. * @param ray defines the ray to intersect with
  11118. * @param camera defines the current active camera
  11119. * @param predicate defines a predicate used to select candidate sprites
  11120. * @returns null if no hit or a PickingInfo array
  11121. */
  11122. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11123. /**
  11124. * Render all child sprites
  11125. */
  11126. render(): void;
  11127. /**
  11128. * Release associated resources
  11129. */
  11130. dispose(): void;
  11131. /**
  11132. * Serializes the sprite manager to a JSON object
  11133. * @param serializeTexture defines if the texture must be serialized as well
  11134. * @returns the JSON object
  11135. */
  11136. serialize(serializeTexture?: boolean): any;
  11137. /**
  11138. * Parses a JSON object to create a new sprite manager.
  11139. * @param parsedManager The JSON object to parse
  11140. * @param scene The scene to create the sprite managerin
  11141. * @param rootUrl The root url to use to load external dependencies like texture
  11142. * @returns the new sprite manager
  11143. */
  11144. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11145. /**
  11146. * Creates a sprite manager from a snippet saved in a remote file
  11147. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11148. * @param url defines the url to load from
  11149. * @param scene defines the hosting scene
  11150. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11151. * @returns a promise that will resolve to the new sprite manager
  11152. */
  11153. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11154. /**
  11155. * Creates a sprite manager from a snippet saved by the sprite editor
  11156. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11157. * @param scene defines the hosting scene
  11158. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11159. * @returns a promise that will resolve to the new sprite manager
  11160. */
  11161. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11162. }
  11163. }
  11164. declare module BABYLON {
  11165. /** Interface used by value gradients (color, factor, ...) */
  11166. export interface IValueGradient {
  11167. /**
  11168. * Gets or sets the gradient value (between 0 and 1)
  11169. */
  11170. gradient: number;
  11171. }
  11172. /** Class used to store color4 gradient */
  11173. export class ColorGradient implements IValueGradient {
  11174. /**
  11175. * Gets or sets the gradient value (between 0 and 1)
  11176. */
  11177. gradient: number;
  11178. /**
  11179. * Gets or sets first associated color
  11180. */
  11181. color1: Color4;
  11182. /**
  11183. * Gets or sets second associated color
  11184. */
  11185. color2?: Color4 | undefined;
  11186. /**
  11187. * Creates a new color4 gradient
  11188. * @param gradient gets or sets the gradient value (between 0 and 1)
  11189. * @param color1 gets or sets first associated color
  11190. * @param color2 gets or sets first second color
  11191. */
  11192. constructor(
  11193. /**
  11194. * Gets or sets the gradient value (between 0 and 1)
  11195. */
  11196. gradient: number,
  11197. /**
  11198. * Gets or sets first associated color
  11199. */
  11200. color1: Color4,
  11201. /**
  11202. * Gets or sets second associated color
  11203. */
  11204. color2?: Color4 | undefined);
  11205. /**
  11206. * Will get a color picked randomly between color1 and color2.
  11207. * If color2 is undefined then color1 will be used
  11208. * @param result defines the target Color4 to store the result in
  11209. */
  11210. getColorToRef(result: Color4): void;
  11211. }
  11212. /** Class used to store color 3 gradient */
  11213. export class Color3Gradient implements IValueGradient {
  11214. /**
  11215. * Gets or sets the gradient value (between 0 and 1)
  11216. */
  11217. gradient: number;
  11218. /**
  11219. * Gets or sets the associated color
  11220. */
  11221. color: Color3;
  11222. /**
  11223. * Creates a new color3 gradient
  11224. * @param gradient gets or sets the gradient value (between 0 and 1)
  11225. * @param color gets or sets associated color
  11226. */
  11227. constructor(
  11228. /**
  11229. * Gets or sets the gradient value (between 0 and 1)
  11230. */
  11231. gradient: number,
  11232. /**
  11233. * Gets or sets the associated color
  11234. */
  11235. color: Color3);
  11236. }
  11237. /** Class used to store factor gradient */
  11238. export class FactorGradient implements IValueGradient {
  11239. /**
  11240. * Gets or sets the gradient value (between 0 and 1)
  11241. */
  11242. gradient: number;
  11243. /**
  11244. * Gets or sets first associated factor
  11245. */
  11246. factor1: number;
  11247. /**
  11248. * Gets or sets second associated factor
  11249. */
  11250. factor2?: number | undefined;
  11251. /**
  11252. * Creates a new factor gradient
  11253. * @param gradient gets or sets the gradient value (between 0 and 1)
  11254. * @param factor1 gets or sets first associated factor
  11255. * @param factor2 gets or sets second associated factor
  11256. */
  11257. constructor(
  11258. /**
  11259. * Gets or sets the gradient value (between 0 and 1)
  11260. */
  11261. gradient: number,
  11262. /**
  11263. * Gets or sets first associated factor
  11264. */
  11265. factor1: number,
  11266. /**
  11267. * Gets or sets second associated factor
  11268. */
  11269. factor2?: number | undefined);
  11270. /**
  11271. * Will get a number picked randomly between factor1 and factor2.
  11272. * If factor2 is undefined then factor1 will be used
  11273. * @returns the picked number
  11274. */
  11275. getFactor(): number;
  11276. }
  11277. /**
  11278. * Helper used to simplify some generic gradient tasks
  11279. */
  11280. export class GradientHelper {
  11281. /**
  11282. * Gets the current gradient from an array of IValueGradient
  11283. * @param ratio defines the current ratio to get
  11284. * @param gradients defines the array of IValueGradient
  11285. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11286. */
  11287. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11288. }
  11289. }
  11290. declare module BABYLON {
  11291. interface ThinEngine {
  11292. /**
  11293. * Creates a raw texture
  11294. * @param data defines the data to store in the texture
  11295. * @param width defines the width of the texture
  11296. * @param height defines the height of the texture
  11297. * @param format defines the format of the data
  11298. * @param generateMipMaps defines if the engine should generate the mip levels
  11299. * @param invertY defines if data must be stored with Y axis inverted
  11300. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11301. * @param compression defines the compression used (null by default)
  11302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11303. * @returns the raw texture inside an InternalTexture
  11304. */
  11305. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11306. /**
  11307. * Update a raw texture
  11308. * @param texture defines the texture to update
  11309. * @param data defines the data to store in the texture
  11310. * @param format defines the format of the data
  11311. * @param invertY defines if data must be stored with Y axis inverted
  11312. */
  11313. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11314. /**
  11315. * Update a raw texture
  11316. * @param texture defines the texture to update
  11317. * @param data defines the data to store in the texture
  11318. * @param format defines the format of the data
  11319. * @param invertY defines if data must be stored with Y axis inverted
  11320. * @param compression defines the compression used (null by default)
  11321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11322. */
  11323. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11324. /**
  11325. * Creates a new raw cube texture
  11326. * @param data defines the array of data to use to create each face
  11327. * @param size defines the size of the textures
  11328. * @param format defines the format of the data
  11329. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11330. * @param generateMipMaps defines if the engine should generate the mip levels
  11331. * @param invertY defines if data must be stored with Y axis inverted
  11332. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11333. * @param compression defines the compression used (null by default)
  11334. * @returns the cube texture as an InternalTexture
  11335. */
  11336. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11337. /**
  11338. * Update a raw cube texture
  11339. * @param texture defines the texture to udpdate
  11340. * @param data defines the data to store
  11341. * @param format defines the data format
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. * @param invertY defines if data must be stored with Y axis inverted
  11344. */
  11345. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11346. /**
  11347. * Update a raw cube texture
  11348. * @param texture defines the texture to udpdate
  11349. * @param data defines the data to store
  11350. * @param format defines the data format
  11351. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param compression defines the compression used (null by default)
  11354. */
  11355. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11356. /**
  11357. * Update a raw cube texture
  11358. * @param texture defines the texture to udpdate
  11359. * @param data defines the data to store
  11360. * @param format defines the data format
  11361. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11362. * @param invertY defines if data must be stored with Y axis inverted
  11363. * @param compression defines the compression used (null by default)
  11364. * @param level defines which level of the texture to update
  11365. */
  11366. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11367. /**
  11368. * Creates a new raw cube texture from a specified url
  11369. * @param url defines the url where the data is located
  11370. * @param scene defines the current scene
  11371. * @param size defines the size of the textures
  11372. * @param format defines the format of the data
  11373. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11374. * @param noMipmap defines if the engine should avoid generating the mip levels
  11375. * @param callback defines a callback used to extract texture data from loaded data
  11376. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11377. * @param onLoad defines a callback called when texture is loaded
  11378. * @param onError defines a callback called if there is an error
  11379. * @returns the cube texture as an InternalTexture
  11380. */
  11381. 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;
  11382. /**
  11383. * Creates a new raw cube texture from a specified url
  11384. * @param url defines the url where the data is located
  11385. * @param scene defines the current scene
  11386. * @param size defines the size of the textures
  11387. * @param format defines the format of the data
  11388. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11389. * @param noMipmap defines if the engine should avoid generating the mip levels
  11390. * @param callback defines a callback used to extract texture data from loaded data
  11391. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11392. * @param onLoad defines a callback called when texture is loaded
  11393. * @param onError defines a callback called if there is an error
  11394. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11395. * @param invertY defines if data must be stored with Y axis inverted
  11396. * @returns the cube texture as an InternalTexture
  11397. */
  11398. 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;
  11399. /**
  11400. * Creates a new raw 3D texture
  11401. * @param data defines the data used to create the texture
  11402. * @param width defines the width of the texture
  11403. * @param height defines the height of the texture
  11404. * @param depth defines the depth of the texture
  11405. * @param format defines the format of the texture
  11406. * @param generateMipMaps defines if the engine must generate mip levels
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11409. * @param compression defines the compressed used (can be null)
  11410. * @param textureType defines the compressed used (can be null)
  11411. * @returns a new raw 3D texture (stored in an InternalTexture)
  11412. */
  11413. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11414. /**
  11415. * Update a raw 3D texture
  11416. * @param texture defines the texture to update
  11417. * @param data defines the data to store
  11418. * @param format defines the data format
  11419. * @param invertY defines if data must be stored with Y axis inverted
  11420. */
  11421. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11422. /**
  11423. * Update a raw 3D texture
  11424. * @param texture defines the texture to update
  11425. * @param data defines the data to store
  11426. * @param format defines the data format
  11427. * @param invertY defines if data must be stored with Y axis inverted
  11428. * @param compression defines the used compression (can be null)
  11429. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11430. */
  11431. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11432. /**
  11433. * Creates a new raw 2D array texture
  11434. * @param data defines the data used to create the texture
  11435. * @param width defines the width of the texture
  11436. * @param height defines the height of the texture
  11437. * @param depth defines the number of layers of the texture
  11438. * @param format defines the format of the texture
  11439. * @param generateMipMaps defines if the engine must generate mip levels
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11442. * @param compression defines the compressed used (can be null)
  11443. * @param textureType defines the compressed used (can be null)
  11444. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11445. */
  11446. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11447. /**
  11448. * Update a raw 2D array texture
  11449. * @param texture defines the texture to update
  11450. * @param data defines the data to store
  11451. * @param format defines the data format
  11452. * @param invertY defines if data must be stored with Y axis inverted
  11453. */
  11454. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11455. /**
  11456. * Update a raw 2D array texture
  11457. * @param texture defines the texture to update
  11458. * @param data defines the data to store
  11459. * @param format defines the data format
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. * @param compression defines the used compression (can be null)
  11462. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11463. */
  11464. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11465. }
  11466. }
  11467. declare module BABYLON {
  11468. /**
  11469. * Raw texture can help creating a texture directly from an array of data.
  11470. * This can be super useful if you either get the data from an uncompressed source or
  11471. * if you wish to create your texture pixel by pixel.
  11472. */
  11473. export class RawTexture extends Texture {
  11474. /**
  11475. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11476. */
  11477. format: number;
  11478. /**
  11479. * Instantiates a new RawTexture.
  11480. * Raw texture can help creating a texture directly from an array of data.
  11481. * This can be super useful if you either get the data from an uncompressed source or
  11482. * if you wish to create your texture pixel by pixel.
  11483. * @param data define the array of data to use to create the texture
  11484. * @param width define the width of the texture
  11485. * @param height define the height of the texture
  11486. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11487. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11488. * @param generateMipMaps define whether mip maps should be generated or not
  11489. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11490. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11491. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11492. */
  11493. constructor(data: ArrayBufferView, width: number, height: number,
  11494. /**
  11495. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11496. */
  11497. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11498. /**
  11499. * Updates the texture underlying data.
  11500. * @param data Define the new data of the texture
  11501. */
  11502. update(data: ArrayBufferView): void;
  11503. /**
  11504. * Creates a luminance texture from some data.
  11505. * @param data Define the texture data
  11506. * @param width Define the width of the texture
  11507. * @param height Define the height of the texture
  11508. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11512. * @returns the luminance texture
  11513. */
  11514. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11515. /**
  11516. * Creates a luminance alpha texture from some data.
  11517. * @param data Define the texture data
  11518. * @param width Define the width of the texture
  11519. * @param height Define the height of the texture
  11520. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11524. * @returns the luminance alpha texture
  11525. */
  11526. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11527. /**
  11528. * Creates an alpha texture from some data.
  11529. * @param data Define the texture data
  11530. * @param width Define the width of the texture
  11531. * @param height Define the height of the texture
  11532. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11536. * @returns the alpha texture
  11537. */
  11538. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11539. /**
  11540. * Creates a RGB texture from some data.
  11541. * @param data Define the texture data
  11542. * @param width Define the width of the texture
  11543. * @param height Define the height of the texture
  11544. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11548. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11549. * @returns the RGB alpha texture
  11550. */
  11551. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11552. /**
  11553. * Creates a RGBA texture from some data.
  11554. * @param data Define the texture data
  11555. * @param width Define the width of the texture
  11556. * @param height Define the height of the texture
  11557. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11558. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11559. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11560. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11561. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11562. * @returns the RGBA texture
  11563. */
  11564. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11565. /**
  11566. * Creates a R texture from some data.
  11567. * @param data Define the texture data
  11568. * @param width Define the width of the texture
  11569. * @param height Define the height of the texture
  11570. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11571. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11572. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11573. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11574. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11575. * @returns the R texture
  11576. */
  11577. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11578. }
  11579. }
  11580. declare module BABYLON {
  11581. interface ThinEngine {
  11582. /**
  11583. * Update a dynamic index buffer
  11584. * @param indexBuffer defines the target index buffer
  11585. * @param indices defines the data to update
  11586. * @param offset defines the offset in the target index buffer where update should start
  11587. */
  11588. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11589. /**
  11590. * Updates a dynamic vertex buffer.
  11591. * @param vertexBuffer the vertex buffer to update
  11592. * @param data the data used to update the vertex buffer
  11593. * @param byteOffset the byte offset of the data
  11594. * @param byteLength the byte length of the data
  11595. */
  11596. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11597. }
  11598. }
  11599. declare module BABYLON {
  11600. interface AbstractScene {
  11601. /**
  11602. * The list of procedural textures added to the scene
  11603. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11604. */
  11605. proceduralTextures: Array<ProceduralTexture>;
  11606. }
  11607. /**
  11608. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11609. * in a given scene.
  11610. */
  11611. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11612. /**
  11613. * The component name helpfull to identify the component in the list of scene components.
  11614. */
  11615. readonly name: string;
  11616. /**
  11617. * The scene the component belongs to.
  11618. */
  11619. scene: Scene;
  11620. /**
  11621. * Creates a new instance of the component for the given scene
  11622. * @param scene Defines the scene to register the component in
  11623. */
  11624. constructor(scene: Scene);
  11625. /**
  11626. * Registers the component in a given scene
  11627. */
  11628. register(): void;
  11629. /**
  11630. * Rebuilds the elements related to this component in case of
  11631. * context lost for instance.
  11632. */
  11633. rebuild(): void;
  11634. /**
  11635. * Disposes the component and the associated ressources.
  11636. */
  11637. dispose(): void;
  11638. private _beforeClear;
  11639. }
  11640. }
  11641. declare module BABYLON {
  11642. interface ThinEngine {
  11643. /**
  11644. * Creates a new render target cube texture
  11645. * @param size defines the size of the texture
  11646. * @param options defines the options used to create the texture
  11647. * @returns a new render target cube texture stored in an InternalTexture
  11648. */
  11649. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11650. }
  11651. }
  11652. declare module BABYLON {
  11653. /** @hidden */
  11654. export var proceduralVertexShader: {
  11655. name: string;
  11656. shader: string;
  11657. };
  11658. }
  11659. declare module BABYLON {
  11660. /**
  11661. * 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.
  11662. * This is the base class of any Procedural texture and contains most of the shareable code.
  11663. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11664. */
  11665. export class ProceduralTexture extends Texture {
  11666. /**
  11667. * Define if the texture is enabled or not (disabled texture will not render)
  11668. */
  11669. isEnabled: boolean;
  11670. /**
  11671. * Define if the texture must be cleared before rendering (default is true)
  11672. */
  11673. autoClear: boolean;
  11674. /**
  11675. * Callback called when the texture is generated
  11676. */
  11677. onGenerated: () => void;
  11678. /**
  11679. * Event raised when the texture is generated
  11680. */
  11681. onGeneratedObservable: Observable<ProceduralTexture>;
  11682. /** @hidden */
  11683. _generateMipMaps: boolean;
  11684. /** @hidden **/
  11685. _effect: Effect;
  11686. /** @hidden */
  11687. _textures: {
  11688. [key: string]: Texture;
  11689. };
  11690. /** @hidden */
  11691. protected _fallbackTexture: Nullable<Texture>;
  11692. private _size;
  11693. private _currentRefreshId;
  11694. private _frameId;
  11695. private _refreshRate;
  11696. private _vertexBuffers;
  11697. private _indexBuffer;
  11698. private _uniforms;
  11699. private _samplers;
  11700. private _fragment;
  11701. private _floats;
  11702. private _ints;
  11703. private _floatsArrays;
  11704. private _colors3;
  11705. private _colors4;
  11706. private _vectors2;
  11707. private _vectors3;
  11708. private _matrices;
  11709. private _fallbackTextureUsed;
  11710. private _fullEngine;
  11711. private _cachedDefines;
  11712. private _contentUpdateId;
  11713. private _contentData;
  11714. /**
  11715. * Instantiates a new procedural texture.
  11716. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11717. * This is the base class of any Procedural texture and contains most of the shareable code.
  11718. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11719. * @param name Define the name of the texture
  11720. * @param size Define the size of the texture to create
  11721. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11722. * @param scene Define the scene the texture belongs to
  11723. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11724. * @param generateMipMaps Define if the texture should creates mip maps or not
  11725. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11726. */
  11727. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11728. /**
  11729. * The effect that is created when initializing the post process.
  11730. * @returns The created effect corresponding the the postprocess.
  11731. */
  11732. getEffect(): Effect;
  11733. /**
  11734. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11735. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11736. */
  11737. getContent(): Nullable<ArrayBufferView>;
  11738. private _createIndexBuffer;
  11739. /** @hidden */
  11740. _rebuild(): void;
  11741. /**
  11742. * Resets the texture in order to recreate its associated resources.
  11743. * This can be called in case of context loss
  11744. */
  11745. reset(): void;
  11746. protected _getDefines(): string;
  11747. /**
  11748. * Is the texture ready to be used ? (rendered at least once)
  11749. * @returns true if ready, otherwise, false.
  11750. */
  11751. isReady(): boolean;
  11752. /**
  11753. * Resets the refresh counter of the texture and start bak from scratch.
  11754. * Could be useful to regenerate the texture if it is setup to render only once.
  11755. */
  11756. resetRefreshCounter(): void;
  11757. /**
  11758. * Set the fragment shader to use in order to render the texture.
  11759. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11760. */
  11761. setFragment(fragment: any): void;
  11762. /**
  11763. * Define the refresh rate of the texture or the rendering frequency.
  11764. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11765. */
  11766. get refreshRate(): number;
  11767. set refreshRate(value: number);
  11768. /** @hidden */
  11769. _shouldRender(): boolean;
  11770. /**
  11771. * Get the size the texture is rendering at.
  11772. * @returns the size (texture is always squared)
  11773. */
  11774. getRenderSize(): number;
  11775. /**
  11776. * Resize the texture to new value.
  11777. * @param size Define the new size the texture should have
  11778. * @param generateMipMaps Define whether the new texture should create mip maps
  11779. */
  11780. resize(size: number, generateMipMaps: boolean): void;
  11781. private _checkUniform;
  11782. /**
  11783. * Set a texture in the shader program used to render.
  11784. * @param name Define the name of the uniform samplers as defined in the shader
  11785. * @param texture Define the texture to bind to this sampler
  11786. * @return the texture itself allowing "fluent" like uniform updates
  11787. */
  11788. setTexture(name: string, texture: Texture): ProceduralTexture;
  11789. /**
  11790. * Set a float in the shader.
  11791. * @param name Define the name of the uniform as defined in the shader
  11792. * @param value Define the value to give to the uniform
  11793. * @return the texture itself allowing "fluent" like uniform updates
  11794. */
  11795. setFloat(name: string, value: number): ProceduralTexture;
  11796. /**
  11797. * Set a int in the shader.
  11798. * @param name Define the name of the uniform as defined in the shader
  11799. * @param value Define the value to give to the uniform
  11800. * @return the texture itself allowing "fluent" like uniform updates
  11801. */
  11802. setInt(name: string, value: number): ProceduralTexture;
  11803. /**
  11804. * Set an array of floats in the shader.
  11805. * @param name Define the name of the uniform as defined in the shader
  11806. * @param value Define the value to give to the uniform
  11807. * @return the texture itself allowing "fluent" like uniform updates
  11808. */
  11809. setFloats(name: string, value: number[]): ProceduralTexture;
  11810. /**
  11811. * Set a vec3 in the shader from a Color3.
  11812. * @param name Define the name of the uniform as defined in the shader
  11813. * @param value Define the value to give to the uniform
  11814. * @return the texture itself allowing "fluent" like uniform updates
  11815. */
  11816. setColor3(name: string, value: Color3): ProceduralTexture;
  11817. /**
  11818. * Set a vec4 in the shader from a Color4.
  11819. * @param name Define the name of the uniform as defined in the shader
  11820. * @param value Define the value to give to the uniform
  11821. * @return the texture itself allowing "fluent" like uniform updates
  11822. */
  11823. setColor4(name: string, value: Color4): ProceduralTexture;
  11824. /**
  11825. * Set a vec2 in the shader from a Vector2.
  11826. * @param name Define the name of the uniform as defined in the shader
  11827. * @param value Define the value to give to the uniform
  11828. * @return the texture itself allowing "fluent" like uniform updates
  11829. */
  11830. setVector2(name: string, value: Vector2): ProceduralTexture;
  11831. /**
  11832. * Set a vec3 in the shader from a Vector3.
  11833. * @param name Define the name of the uniform as defined in the shader
  11834. * @param value Define the value to give to the uniform
  11835. * @return the texture itself allowing "fluent" like uniform updates
  11836. */
  11837. setVector3(name: string, value: Vector3): ProceduralTexture;
  11838. /**
  11839. * Set a mat4 in the shader from a MAtrix.
  11840. * @param name Define the name of the uniform as defined in the shader
  11841. * @param value Define the value to give to the uniform
  11842. * @return the texture itself allowing "fluent" like uniform updates
  11843. */
  11844. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11845. /**
  11846. * Render the texture to its associated render target.
  11847. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11848. */
  11849. render(useCameraPostProcess?: boolean): void;
  11850. /**
  11851. * Clone the texture.
  11852. * @returns the cloned texture
  11853. */
  11854. clone(): ProceduralTexture;
  11855. /**
  11856. * Dispose the texture and release its asoociated resources.
  11857. */
  11858. dispose(): void;
  11859. }
  11860. }
  11861. declare module BABYLON {
  11862. /**
  11863. * This represents the base class for particle system in Babylon.
  11864. * 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.
  11865. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11866. * @example https://doc.babylonjs.com/babylon101/particles
  11867. */
  11868. export class BaseParticleSystem {
  11869. /**
  11870. * Source color is added to the destination color without alpha affecting the result
  11871. */
  11872. static BLENDMODE_ONEONE: number;
  11873. /**
  11874. * Blend current color and particle color using particle’s alpha
  11875. */
  11876. static BLENDMODE_STANDARD: number;
  11877. /**
  11878. * Add current color and particle color multiplied by particle’s alpha
  11879. */
  11880. static BLENDMODE_ADD: number;
  11881. /**
  11882. * Multiply current color with particle color
  11883. */
  11884. static BLENDMODE_MULTIPLY: number;
  11885. /**
  11886. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11887. */
  11888. static BLENDMODE_MULTIPLYADD: number;
  11889. /**
  11890. * List of animations used by the particle system.
  11891. */
  11892. animations: Animation[];
  11893. /**
  11894. * Gets or sets the unique id of the particle system
  11895. */
  11896. uniqueId: number;
  11897. /**
  11898. * The id of the Particle system.
  11899. */
  11900. id: string;
  11901. /**
  11902. * The friendly name of the Particle system.
  11903. */
  11904. name: string;
  11905. /**
  11906. * Snippet ID if the particle system was created from the snippet server
  11907. */
  11908. snippetId: string;
  11909. /**
  11910. * The rendering group used by the Particle system to chose when to render.
  11911. */
  11912. renderingGroupId: number;
  11913. /**
  11914. * The emitter represents the Mesh or position we are attaching the particle system to.
  11915. */
  11916. emitter: Nullable<AbstractMesh | Vector3>;
  11917. /**
  11918. * The maximum number of particles to emit per frame
  11919. */
  11920. emitRate: number;
  11921. /**
  11922. * If you want to launch only a few particles at once, that can be done, as well.
  11923. */
  11924. manualEmitCount: number;
  11925. /**
  11926. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11927. */
  11928. updateSpeed: number;
  11929. /**
  11930. * The amount of time the particle system is running (depends of the overall update speed).
  11931. */
  11932. targetStopDuration: number;
  11933. /**
  11934. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11935. */
  11936. disposeOnStop: boolean;
  11937. /**
  11938. * Minimum power of emitting particles.
  11939. */
  11940. minEmitPower: number;
  11941. /**
  11942. * Maximum power of emitting particles.
  11943. */
  11944. maxEmitPower: number;
  11945. /**
  11946. * Minimum life time of emitting particles.
  11947. */
  11948. minLifeTime: number;
  11949. /**
  11950. * Maximum life time of emitting particles.
  11951. */
  11952. maxLifeTime: number;
  11953. /**
  11954. * Minimum Size of emitting particles.
  11955. */
  11956. minSize: number;
  11957. /**
  11958. * Maximum Size of emitting particles.
  11959. */
  11960. maxSize: number;
  11961. /**
  11962. * Minimum scale of emitting particles on X axis.
  11963. */
  11964. minScaleX: number;
  11965. /**
  11966. * Maximum scale of emitting particles on X axis.
  11967. */
  11968. maxScaleX: number;
  11969. /**
  11970. * Minimum scale of emitting particles on Y axis.
  11971. */
  11972. minScaleY: number;
  11973. /**
  11974. * Maximum scale of emitting particles on Y axis.
  11975. */
  11976. maxScaleY: number;
  11977. /**
  11978. * Gets or sets the minimal initial rotation in radians.
  11979. */
  11980. minInitialRotation: number;
  11981. /**
  11982. * Gets or sets the maximal initial rotation in radians.
  11983. */
  11984. maxInitialRotation: number;
  11985. /**
  11986. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11987. */
  11988. minAngularSpeed: number;
  11989. /**
  11990. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11991. */
  11992. maxAngularSpeed: number;
  11993. /**
  11994. * The texture used to render each particle. (this can be a spritesheet)
  11995. */
  11996. particleTexture: Nullable<BaseTexture>;
  11997. /**
  11998. * The layer mask we are rendering the particles through.
  11999. */
  12000. layerMask: number;
  12001. /**
  12002. * This can help using your own shader to render the particle system.
  12003. * The according effect will be created
  12004. */
  12005. customShader: any;
  12006. /**
  12007. * By default particle system starts as soon as they are created. This prevents the
  12008. * automatic start to happen and let you decide when to start emitting particles.
  12009. */
  12010. preventAutoStart: boolean;
  12011. private _noiseTexture;
  12012. /**
  12013. * Gets or sets a texture used to add random noise to particle positions
  12014. */
  12015. get noiseTexture(): Nullable<ProceduralTexture>;
  12016. set noiseTexture(value: Nullable<ProceduralTexture>);
  12017. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12018. noiseStrength: Vector3;
  12019. /**
  12020. * Callback triggered when the particle animation is ending.
  12021. */
  12022. onAnimationEnd: Nullable<() => void>;
  12023. /**
  12024. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12025. */
  12026. blendMode: number;
  12027. /**
  12028. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12029. * to override the particles.
  12030. */
  12031. forceDepthWrite: boolean;
  12032. /** 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 */
  12033. preWarmCycles: number;
  12034. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12035. preWarmStepOffset: number;
  12036. /**
  12037. * 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)
  12038. */
  12039. spriteCellChangeSpeed: number;
  12040. /**
  12041. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12042. */
  12043. startSpriteCellID: number;
  12044. /**
  12045. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12046. */
  12047. endSpriteCellID: number;
  12048. /**
  12049. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12050. */
  12051. spriteCellWidth: number;
  12052. /**
  12053. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12054. */
  12055. spriteCellHeight: number;
  12056. /**
  12057. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12058. */
  12059. spriteRandomStartCell: boolean;
  12060. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12061. translationPivot: Vector2;
  12062. /** @hidden */
  12063. protected _isAnimationSheetEnabled: boolean;
  12064. /**
  12065. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12066. */
  12067. beginAnimationOnStart: boolean;
  12068. /**
  12069. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12070. */
  12071. beginAnimationFrom: number;
  12072. /**
  12073. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12074. */
  12075. beginAnimationTo: number;
  12076. /**
  12077. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12078. */
  12079. beginAnimationLoop: boolean;
  12080. /**
  12081. * Gets or sets a world offset applied to all particles
  12082. */
  12083. worldOffset: Vector3;
  12084. /**
  12085. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12086. */
  12087. get isAnimationSheetEnabled(): boolean;
  12088. set isAnimationSheetEnabled(value: boolean);
  12089. /**
  12090. * Get hosting scene
  12091. * @returns the scene
  12092. */
  12093. getScene(): Nullable<Scene>;
  12094. /**
  12095. * You can use gravity if you want to give an orientation to your particles.
  12096. */
  12097. gravity: Vector3;
  12098. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12099. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12100. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12101. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12102. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12103. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12104. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12105. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12106. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12107. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12108. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12109. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12110. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12111. /**
  12112. * Defines the delay in milliseconds before starting the system (0 by default)
  12113. */
  12114. startDelay: number;
  12115. /**
  12116. * Gets the current list of drag gradients.
  12117. * You must use addDragGradient and removeDragGradient to udpate this list
  12118. * @returns the list of drag gradients
  12119. */
  12120. getDragGradients(): Nullable<Array<FactorGradient>>;
  12121. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12122. limitVelocityDamping: number;
  12123. /**
  12124. * Gets the current list of limit velocity gradients.
  12125. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12126. * @returns the list of limit velocity gradients
  12127. */
  12128. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12129. /**
  12130. * Gets the current list of color gradients.
  12131. * You must use addColorGradient and removeColorGradient to udpate this list
  12132. * @returns the list of color gradients
  12133. */
  12134. getColorGradients(): Nullable<Array<ColorGradient>>;
  12135. /**
  12136. * Gets the current list of size gradients.
  12137. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12138. * @returns the list of size gradients
  12139. */
  12140. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12141. /**
  12142. * Gets the current list of color remap gradients.
  12143. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12144. * @returns the list of color remap gradients
  12145. */
  12146. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12147. /**
  12148. * Gets the current list of alpha remap gradients.
  12149. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12150. * @returns the list of alpha remap gradients
  12151. */
  12152. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12153. /**
  12154. * Gets the current list of life time gradients.
  12155. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12156. * @returns the list of life time gradients
  12157. */
  12158. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12159. /**
  12160. * Gets the current list of angular speed gradients.
  12161. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12162. * @returns the list of angular speed gradients
  12163. */
  12164. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12165. /**
  12166. * Gets the current list of velocity gradients.
  12167. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12168. * @returns the list of velocity gradients
  12169. */
  12170. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12171. /**
  12172. * Gets the current list of start size gradients.
  12173. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12174. * @returns the list of start size gradients
  12175. */
  12176. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12177. /**
  12178. * Gets the current list of emit rate gradients.
  12179. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12180. * @returns the list of emit rate gradients
  12181. */
  12182. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12183. /**
  12184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12185. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12186. */
  12187. get direction1(): Vector3;
  12188. set direction1(value: Vector3);
  12189. /**
  12190. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12191. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12192. */
  12193. get direction2(): Vector3;
  12194. set direction2(value: Vector3);
  12195. /**
  12196. * 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.
  12197. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12198. */
  12199. get minEmitBox(): Vector3;
  12200. set minEmitBox(value: Vector3);
  12201. /**
  12202. * 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.
  12203. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12204. */
  12205. get maxEmitBox(): Vector3;
  12206. set maxEmitBox(value: Vector3);
  12207. /**
  12208. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12209. */
  12210. color1: Color4;
  12211. /**
  12212. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12213. */
  12214. color2: Color4;
  12215. /**
  12216. * Color the particle will have at the end of its lifetime
  12217. */
  12218. colorDead: Color4;
  12219. /**
  12220. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12221. */
  12222. textureMask: Color4;
  12223. /**
  12224. * The particle emitter type defines the emitter used by the particle system.
  12225. * It can be for example box, sphere, or cone...
  12226. */
  12227. particleEmitterType: IParticleEmitterType;
  12228. /** @hidden */
  12229. _isSubEmitter: boolean;
  12230. /**
  12231. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12232. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12233. */
  12234. billboardMode: number;
  12235. protected _isBillboardBased: boolean;
  12236. /**
  12237. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12238. */
  12239. get isBillboardBased(): boolean;
  12240. set isBillboardBased(value: boolean);
  12241. /**
  12242. * The scene the particle system belongs to.
  12243. */
  12244. protected _scene: Nullable<Scene>;
  12245. /**
  12246. * The engine the particle system belongs to.
  12247. */
  12248. protected _engine: ThinEngine;
  12249. /**
  12250. * Local cache of defines for image processing.
  12251. */
  12252. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12253. /**
  12254. * Default configuration related to image processing available in the standard Material.
  12255. */
  12256. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12257. /**
  12258. * Gets the image processing configuration used either in this material.
  12259. */
  12260. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12261. /**
  12262. * Sets the Default image processing configuration used either in the this material.
  12263. *
  12264. * If sets to null, the scene one is in use.
  12265. */
  12266. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12267. /**
  12268. * Attaches a new image processing configuration to the Standard Material.
  12269. * @param configuration
  12270. */
  12271. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12272. /** @hidden */
  12273. protected _reset(): void;
  12274. /** @hidden */
  12275. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12276. /**
  12277. * Instantiates a particle system.
  12278. * 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.
  12279. * @param name The name of the particle system
  12280. */
  12281. constructor(name: string);
  12282. /**
  12283. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12284. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12285. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @returns the emitter
  12287. */
  12288. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12289. /**
  12290. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12291. * @param radius The radius of the hemisphere to emit from
  12292. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12293. * @returns the emitter
  12294. */
  12295. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12296. /**
  12297. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12298. * @param radius The radius of the sphere to emit from
  12299. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12300. * @returns the emitter
  12301. */
  12302. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12303. /**
  12304. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12305. * @param radius The radius of the sphere to emit from
  12306. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12307. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @returns the emitter
  12309. */
  12310. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12311. /**
  12312. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12313. * @param radius The radius of the emission cylinder
  12314. * @param height The height of the emission cylinder
  12315. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12316. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12317. * @returns the emitter
  12318. */
  12319. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12320. /**
  12321. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12322. * @param radius The radius of the cylinder to emit from
  12323. * @param height The height of the emission cylinder
  12324. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12325. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12326. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @returns the emitter
  12328. */
  12329. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12330. /**
  12331. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12332. * @param radius The radius of the cone to emit from
  12333. * @param angle The base angle of the cone
  12334. * @returns the emitter
  12335. */
  12336. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12337. /**
  12338. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12339. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12340. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12342. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @returns the emitter
  12344. */
  12345. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12346. }
  12347. }
  12348. declare module BABYLON {
  12349. /**
  12350. * Type of sub emitter
  12351. */
  12352. export enum SubEmitterType {
  12353. /**
  12354. * Attached to the particle over it's lifetime
  12355. */
  12356. ATTACHED = 0,
  12357. /**
  12358. * Created when the particle dies
  12359. */
  12360. END = 1
  12361. }
  12362. /**
  12363. * Sub emitter class used to emit particles from an existing particle
  12364. */
  12365. export class SubEmitter {
  12366. /**
  12367. * the particle system to be used by the sub emitter
  12368. */
  12369. particleSystem: ParticleSystem;
  12370. /**
  12371. * Type of the submitter (Default: END)
  12372. */
  12373. type: SubEmitterType;
  12374. /**
  12375. * 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)
  12376. * Note: This only is supported when using an emitter of type Mesh
  12377. */
  12378. inheritDirection: boolean;
  12379. /**
  12380. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12381. */
  12382. inheritedVelocityAmount: number;
  12383. /**
  12384. * Creates a sub emitter
  12385. * @param particleSystem the particle system to be used by the sub emitter
  12386. */
  12387. constructor(
  12388. /**
  12389. * the particle system to be used by the sub emitter
  12390. */
  12391. particleSystem: ParticleSystem);
  12392. /**
  12393. * Clones the sub emitter
  12394. * @returns the cloned sub emitter
  12395. */
  12396. clone(): SubEmitter;
  12397. /**
  12398. * Serialize current object to a JSON object
  12399. * @returns the serialized object
  12400. */
  12401. serialize(): any;
  12402. /** @hidden */
  12403. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12404. /**
  12405. * Creates a new SubEmitter from a serialized JSON version
  12406. * @param serializationObject defines the JSON object to read from
  12407. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12408. * @param rootUrl defines the rootUrl for data loading
  12409. * @returns a new SubEmitter
  12410. */
  12411. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12412. /** Release associated resources */
  12413. dispose(): void;
  12414. }
  12415. }
  12416. declare module BABYLON {
  12417. /** @hidden */
  12418. export var imageProcessingDeclaration: {
  12419. name: string;
  12420. shader: string;
  12421. };
  12422. }
  12423. declare module BABYLON {
  12424. /** @hidden */
  12425. export var imageProcessingFunctions: {
  12426. name: string;
  12427. shader: string;
  12428. };
  12429. }
  12430. declare module BABYLON {
  12431. /** @hidden */
  12432. export var particlesPixelShader: {
  12433. name: string;
  12434. shader: string;
  12435. };
  12436. }
  12437. declare module BABYLON {
  12438. /** @hidden */
  12439. export var particlesVertexShader: {
  12440. name: string;
  12441. shader: string;
  12442. };
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * Interface used to define entities containing multiple clip planes
  12447. */
  12448. export interface IClipPlanesHolder {
  12449. /**
  12450. * Gets or sets the active clipplane 1
  12451. */
  12452. clipPlane: Nullable<Plane>;
  12453. /**
  12454. * Gets or sets the active clipplane 2
  12455. */
  12456. clipPlane2: Nullable<Plane>;
  12457. /**
  12458. * Gets or sets the active clipplane 3
  12459. */
  12460. clipPlane3: Nullable<Plane>;
  12461. /**
  12462. * Gets or sets the active clipplane 4
  12463. */
  12464. clipPlane4: Nullable<Plane>;
  12465. /**
  12466. * Gets or sets the active clipplane 5
  12467. */
  12468. clipPlane5: Nullable<Plane>;
  12469. /**
  12470. * Gets or sets the active clipplane 6
  12471. */
  12472. clipPlane6: Nullable<Plane>;
  12473. }
  12474. }
  12475. declare module BABYLON {
  12476. /**
  12477. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12478. *
  12479. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12480. *
  12481. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12482. */
  12483. export class ThinMaterialHelper {
  12484. /**
  12485. * Binds the clip plane information from the holder to the effect.
  12486. * @param effect The effect we are binding the data to
  12487. * @param holder The entity containing the clip plane information
  12488. */
  12489. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12490. }
  12491. }
  12492. declare module BABYLON {
  12493. interface ThinEngine {
  12494. /**
  12495. * Sets alpha constants used by some alpha blending modes
  12496. * @param r defines the red component
  12497. * @param g defines the green component
  12498. * @param b defines the blue component
  12499. * @param a defines the alpha component
  12500. */
  12501. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12502. /**
  12503. * Sets the current alpha mode
  12504. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12505. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12506. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12507. */
  12508. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12509. /**
  12510. * Gets the current alpha mode
  12511. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12512. * @returns the current alpha mode
  12513. */
  12514. getAlphaMode(): number;
  12515. /**
  12516. * Sets the current alpha equation
  12517. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12518. */
  12519. setAlphaEquation(equation: number): void;
  12520. /**
  12521. * Gets the current alpha equation.
  12522. * @returns the current alpha equation
  12523. */
  12524. getAlphaEquation(): number;
  12525. }
  12526. }
  12527. declare module BABYLON {
  12528. /**
  12529. * This represents a particle system in Babylon.
  12530. * 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.
  12531. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12532. * @example https://doc.babylonjs.com/babylon101/particles
  12533. */
  12534. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12535. /**
  12536. * Billboard mode will only apply to Y axis
  12537. */
  12538. static readonly BILLBOARDMODE_Y: number;
  12539. /**
  12540. * Billboard mode will apply to all axes
  12541. */
  12542. static readonly BILLBOARDMODE_ALL: number;
  12543. /**
  12544. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12545. */
  12546. static readonly BILLBOARDMODE_STRETCHED: number;
  12547. /**
  12548. * This function can be defined to provide custom update for active particles.
  12549. * This function will be called instead of regular update (age, position, color, etc.).
  12550. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12551. */
  12552. updateFunction: (particles: Particle[]) => void;
  12553. private _emitterWorldMatrix;
  12554. /**
  12555. * This function can be defined to specify initial direction for every new particle.
  12556. * It by default use the emitterType defined function
  12557. */
  12558. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12559. /**
  12560. * This function can be defined to specify initial position for every new particle.
  12561. * It by default use the emitterType defined function
  12562. */
  12563. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12564. /**
  12565. * @hidden
  12566. */
  12567. _inheritedVelocityOffset: Vector3;
  12568. /**
  12569. * An event triggered when the system is disposed
  12570. */
  12571. onDisposeObservable: Observable<IParticleSystem>;
  12572. private _onDisposeObserver;
  12573. /**
  12574. * Sets a callback that will be triggered when the system is disposed
  12575. */
  12576. set onDispose(callback: () => void);
  12577. private _particles;
  12578. private _epsilon;
  12579. private _capacity;
  12580. private _stockParticles;
  12581. private _newPartsExcess;
  12582. private _vertexData;
  12583. private _vertexBuffer;
  12584. private _vertexBuffers;
  12585. private _spriteBuffer;
  12586. private _indexBuffer;
  12587. private _effect;
  12588. private _customEffect;
  12589. private _cachedDefines;
  12590. private _scaledColorStep;
  12591. private _colorDiff;
  12592. private _scaledDirection;
  12593. private _scaledGravity;
  12594. private _currentRenderId;
  12595. private _alive;
  12596. private _useInstancing;
  12597. private _started;
  12598. private _stopped;
  12599. private _actualFrame;
  12600. private _scaledUpdateSpeed;
  12601. private _vertexBufferSize;
  12602. /** @hidden */
  12603. _currentEmitRateGradient: Nullable<FactorGradient>;
  12604. /** @hidden */
  12605. _currentEmitRate1: number;
  12606. /** @hidden */
  12607. _currentEmitRate2: number;
  12608. /** @hidden */
  12609. _currentStartSizeGradient: Nullable<FactorGradient>;
  12610. /** @hidden */
  12611. _currentStartSize1: number;
  12612. /** @hidden */
  12613. _currentStartSize2: number;
  12614. private readonly _rawTextureWidth;
  12615. private _rampGradientsTexture;
  12616. private _useRampGradients;
  12617. /** Gets or sets a matrix to use to compute projection */
  12618. defaultProjectionMatrix: Matrix;
  12619. /** Gets or sets a matrix to use to compute view */
  12620. defaultViewMatrix: Matrix;
  12621. /** Gets or sets a boolean indicating that ramp gradients must be used
  12622. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12623. */
  12624. get useRampGradients(): boolean;
  12625. set useRampGradients(value: boolean);
  12626. /**
  12627. * 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.
  12628. * 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: [])
  12629. */
  12630. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12631. private _subEmitters;
  12632. /**
  12633. * @hidden
  12634. * If the particle systems emitter should be disposed when the particle system is disposed
  12635. */
  12636. _disposeEmitterOnDispose: boolean;
  12637. /**
  12638. * The current active Sub-systems, this property is used by the root particle system only.
  12639. */
  12640. activeSubSystems: Array<ParticleSystem>;
  12641. /**
  12642. * Specifies if the particles are updated in emitter local space or world space
  12643. */
  12644. isLocal: boolean;
  12645. private _rootParticleSystem;
  12646. /**
  12647. * Gets the current list of active particles
  12648. */
  12649. get particles(): Particle[];
  12650. /**
  12651. * Gets the number of particles active at the same time.
  12652. * @returns The number of active particles.
  12653. */
  12654. getActiveCount(): number;
  12655. /**
  12656. * Returns the string "ParticleSystem"
  12657. * @returns a string containing the class name
  12658. */
  12659. getClassName(): string;
  12660. /**
  12661. * Gets a boolean indicating that the system is stopping
  12662. * @returns true if the system is currently stopping
  12663. */
  12664. isStopping(): boolean;
  12665. /**
  12666. * Gets the custom effect used to render the particles
  12667. * @param blendMode Blend mode for which the effect should be retrieved
  12668. * @returns The effect
  12669. */
  12670. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12671. /**
  12672. * Sets the custom effect used to render the particles
  12673. * @param effect The effect to set
  12674. * @param blendMode Blend mode for which the effect should be set
  12675. */
  12676. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12677. /** @hidden */
  12678. private _onBeforeDrawParticlesObservable;
  12679. /**
  12680. * Observable that will be called just before the particles are drawn
  12681. */
  12682. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12683. /**
  12684. * Gets the name of the particle vertex shader
  12685. */
  12686. get vertexShaderName(): string;
  12687. /**
  12688. * Instantiates a particle system.
  12689. * 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.
  12690. * @param name The name of the particle system
  12691. * @param capacity The max number of particles alive at the same time
  12692. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12693. * @param customEffect a custom effect used to change the way particles are rendered by default
  12694. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12695. * @param epsilon Offset used to render the particles
  12696. */
  12697. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12698. private _addFactorGradient;
  12699. private _removeFactorGradient;
  12700. /**
  12701. * Adds a new life time gradient
  12702. * @param gradient defines the gradient to use (between 0 and 1)
  12703. * @param factor defines the life time factor to affect to the specified gradient
  12704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12705. * @returns the current particle system
  12706. */
  12707. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12708. /**
  12709. * Remove a specific life time gradient
  12710. * @param gradient defines the gradient to remove
  12711. * @returns the current particle system
  12712. */
  12713. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12714. /**
  12715. * Adds a new size gradient
  12716. * @param gradient defines the gradient to use (between 0 and 1)
  12717. * @param factor defines the size factor to affect to the specified gradient
  12718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12719. * @returns the current particle system
  12720. */
  12721. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12722. /**
  12723. * Remove a specific size gradient
  12724. * @param gradient defines the gradient to remove
  12725. * @returns the current particle system
  12726. */
  12727. removeSizeGradient(gradient: number): IParticleSystem;
  12728. /**
  12729. * Adds a new color remap gradient
  12730. * @param gradient defines the gradient to use (between 0 and 1)
  12731. * @param min defines the color remap minimal range
  12732. * @param max defines the color remap maximal range
  12733. * @returns the current particle system
  12734. */
  12735. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12736. /**
  12737. * Remove a specific color remap gradient
  12738. * @param gradient defines the gradient to remove
  12739. * @returns the current particle system
  12740. */
  12741. removeColorRemapGradient(gradient: number): IParticleSystem;
  12742. /**
  12743. * Adds a new alpha remap gradient
  12744. * @param gradient defines the gradient to use (between 0 and 1)
  12745. * @param min defines the alpha remap minimal range
  12746. * @param max defines the alpha remap maximal range
  12747. * @returns the current particle system
  12748. */
  12749. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12750. /**
  12751. * Remove a specific alpha remap gradient
  12752. * @param gradient defines the gradient to remove
  12753. * @returns the current particle system
  12754. */
  12755. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12756. /**
  12757. * Adds a new angular speed gradient
  12758. * @param gradient defines the gradient to use (between 0 and 1)
  12759. * @param factor defines the angular speed to affect to the specified gradient
  12760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12761. * @returns the current particle system
  12762. */
  12763. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12764. /**
  12765. * Remove a specific angular speed gradient
  12766. * @param gradient defines the gradient to remove
  12767. * @returns the current particle system
  12768. */
  12769. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12770. /**
  12771. * Adds a new velocity gradient
  12772. * @param gradient defines the gradient to use (between 0 and 1)
  12773. * @param factor defines the velocity to affect to the specified gradient
  12774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12775. * @returns the current particle system
  12776. */
  12777. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12778. /**
  12779. * Remove a specific velocity gradient
  12780. * @param gradient defines the gradient to remove
  12781. * @returns the current particle system
  12782. */
  12783. removeVelocityGradient(gradient: number): IParticleSystem;
  12784. /**
  12785. * Adds a new limit velocity gradient
  12786. * @param gradient defines the gradient to use (between 0 and 1)
  12787. * @param factor defines the limit velocity value to affect to the specified gradient
  12788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12789. * @returns the current particle system
  12790. */
  12791. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12792. /**
  12793. * Remove a specific limit velocity gradient
  12794. * @param gradient defines the gradient to remove
  12795. * @returns the current particle system
  12796. */
  12797. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12798. /**
  12799. * Adds a new drag gradient
  12800. * @param gradient defines the gradient to use (between 0 and 1)
  12801. * @param factor defines the drag value to affect to the specified gradient
  12802. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12803. * @returns the current particle system
  12804. */
  12805. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12806. /**
  12807. * Remove a specific drag gradient
  12808. * @param gradient defines the gradient to remove
  12809. * @returns the current particle system
  12810. */
  12811. removeDragGradient(gradient: number): IParticleSystem;
  12812. /**
  12813. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12814. * @param gradient defines the gradient to use (between 0 and 1)
  12815. * @param factor defines the emit rate value to affect to the specified gradient
  12816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12817. * @returns the current particle system
  12818. */
  12819. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12820. /**
  12821. * Remove a specific emit rate gradient
  12822. * @param gradient defines the gradient to remove
  12823. * @returns the current particle system
  12824. */
  12825. removeEmitRateGradient(gradient: number): IParticleSystem;
  12826. /**
  12827. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12828. * @param gradient defines the gradient to use (between 0 and 1)
  12829. * @param factor defines the start size value to affect to the specified gradient
  12830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12831. * @returns the current particle system
  12832. */
  12833. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12834. /**
  12835. * Remove a specific start size gradient
  12836. * @param gradient defines the gradient to remove
  12837. * @returns the current particle system
  12838. */
  12839. removeStartSizeGradient(gradient: number): IParticleSystem;
  12840. private _createRampGradientTexture;
  12841. /**
  12842. * Gets the current list of ramp gradients.
  12843. * You must use addRampGradient and removeRampGradient to udpate this list
  12844. * @returns the list of ramp gradients
  12845. */
  12846. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12847. /** Force the system to rebuild all gradients that need to be resync */
  12848. forceRefreshGradients(): void;
  12849. private _syncRampGradientTexture;
  12850. /**
  12851. * Adds a new ramp gradient used to remap particle colors
  12852. * @param gradient defines the gradient to use (between 0 and 1)
  12853. * @param color defines the color to affect to the specified gradient
  12854. * @returns the current particle system
  12855. */
  12856. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12857. /**
  12858. * Remove a specific ramp gradient
  12859. * @param gradient defines the gradient to remove
  12860. * @returns the current particle system
  12861. */
  12862. removeRampGradient(gradient: number): ParticleSystem;
  12863. /**
  12864. * Adds a new color gradient
  12865. * @param gradient defines the gradient to use (between 0 and 1)
  12866. * @param color1 defines the color to affect to the specified gradient
  12867. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12868. * @returns this particle system
  12869. */
  12870. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12871. /**
  12872. * Remove a specific color gradient
  12873. * @param gradient defines the gradient to remove
  12874. * @returns this particle system
  12875. */
  12876. removeColorGradient(gradient: number): IParticleSystem;
  12877. private _fetchR;
  12878. protected _reset(): void;
  12879. private _resetEffect;
  12880. private _createVertexBuffers;
  12881. private _createIndexBuffer;
  12882. /**
  12883. * Gets the maximum number of particles active at the same time.
  12884. * @returns The max number of active particles.
  12885. */
  12886. getCapacity(): number;
  12887. /**
  12888. * Gets whether there are still active particles in the system.
  12889. * @returns True if it is alive, otherwise false.
  12890. */
  12891. isAlive(): boolean;
  12892. /**
  12893. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12894. * @returns True if it has been started, otherwise false.
  12895. */
  12896. isStarted(): boolean;
  12897. private _prepareSubEmitterInternalArray;
  12898. /**
  12899. * Starts the particle system and begins to emit
  12900. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12901. */
  12902. start(delay?: number): void;
  12903. /**
  12904. * Stops the particle system.
  12905. * @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.
  12906. */
  12907. stop(stopSubEmitters?: boolean): void;
  12908. /**
  12909. * Remove all active particles
  12910. */
  12911. reset(): void;
  12912. /**
  12913. * @hidden (for internal use only)
  12914. */
  12915. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12916. /**
  12917. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12918. * Its lifetime will start back at 0.
  12919. */
  12920. recycleParticle: (particle: Particle) => void;
  12921. private _stopSubEmitters;
  12922. private _createParticle;
  12923. private _removeFromRoot;
  12924. private _emitFromParticle;
  12925. private _update;
  12926. /** @hidden */
  12927. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12928. /** @hidden */
  12929. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12930. /**
  12931. * Fill the defines array according to the current settings of the particle system
  12932. * @param defines Array to be updated
  12933. * @param blendMode blend mode to take into account when updating the array
  12934. */
  12935. fillDefines(defines: Array<string>, blendMode: number): void;
  12936. /**
  12937. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12938. * @param uniforms Uniforms array to fill
  12939. * @param attributes Attributes array to fill
  12940. * @param samplers Samplers array to fill
  12941. */
  12942. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12943. /** @hidden */
  12944. private _getEffect;
  12945. /**
  12946. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12947. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12948. */
  12949. animate(preWarmOnly?: boolean): void;
  12950. private _appendParticleVertices;
  12951. /**
  12952. * Rebuilds the particle system.
  12953. */
  12954. rebuild(): void;
  12955. /**
  12956. * Is this system ready to be used/rendered
  12957. * @return true if the system is ready
  12958. */
  12959. isReady(): boolean;
  12960. private _render;
  12961. /**
  12962. * Renders the particle system in its current state.
  12963. * @returns the current number of particles
  12964. */
  12965. render(): number;
  12966. /**
  12967. * Disposes the particle system and free the associated resources
  12968. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12969. */
  12970. dispose(disposeTexture?: boolean): void;
  12971. /**
  12972. * Clones the particle system.
  12973. * @param name The name of the cloned object
  12974. * @param newEmitter The new emitter to use
  12975. * @returns the cloned particle system
  12976. */
  12977. clone(name: string, newEmitter: any): ParticleSystem;
  12978. /**
  12979. * Serializes the particle system to a JSON object
  12980. * @param serializeTexture defines if the texture must be serialized as well
  12981. * @returns the JSON object
  12982. */
  12983. serialize(serializeTexture?: boolean): any;
  12984. /** @hidden */
  12985. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12986. /** @hidden */
  12987. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  12988. /**
  12989. * Parses a JSON object to create a particle system.
  12990. * @param parsedParticleSystem The JSON object to parse
  12991. * @param sceneOrEngine The scene or the engine to create the particle system in
  12992. * @param rootUrl The root url to use to load external dependencies like texture
  12993. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12994. * @returns the Parsed particle system
  12995. */
  12996. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12997. }
  12998. }
  12999. declare module BABYLON {
  13000. /**
  13001. * A particle represents one of the element emitted by a particle system.
  13002. * This is mainly define by its coordinates, direction, velocity and age.
  13003. */
  13004. export class Particle {
  13005. /**
  13006. * The particle system the particle belongs to.
  13007. */
  13008. particleSystem: ParticleSystem;
  13009. private static _Count;
  13010. /**
  13011. * Unique ID of the particle
  13012. */
  13013. id: number;
  13014. /**
  13015. * The world position of the particle in the scene.
  13016. */
  13017. position: Vector3;
  13018. /**
  13019. * The world direction of the particle in the scene.
  13020. */
  13021. direction: Vector3;
  13022. /**
  13023. * The color of the particle.
  13024. */
  13025. color: Color4;
  13026. /**
  13027. * The color change of the particle per step.
  13028. */
  13029. colorStep: Color4;
  13030. /**
  13031. * Defines how long will the life of the particle be.
  13032. */
  13033. lifeTime: number;
  13034. /**
  13035. * The current age of the particle.
  13036. */
  13037. age: number;
  13038. /**
  13039. * The current size of the particle.
  13040. */
  13041. size: number;
  13042. /**
  13043. * The current scale of the particle.
  13044. */
  13045. scale: Vector2;
  13046. /**
  13047. * The current angle of the particle.
  13048. */
  13049. angle: number;
  13050. /**
  13051. * Defines how fast is the angle changing.
  13052. */
  13053. angularSpeed: number;
  13054. /**
  13055. * Defines the cell index used by the particle to be rendered from a sprite.
  13056. */
  13057. cellIndex: number;
  13058. /**
  13059. * The information required to support color remapping
  13060. */
  13061. remapData: Vector4;
  13062. /** @hidden */
  13063. _randomCellOffset?: number;
  13064. /** @hidden */
  13065. _initialDirection: Nullable<Vector3>;
  13066. /** @hidden */
  13067. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13068. /** @hidden */
  13069. _initialStartSpriteCellID: number;
  13070. /** @hidden */
  13071. _initialEndSpriteCellID: number;
  13072. /** @hidden */
  13073. _currentColorGradient: Nullable<ColorGradient>;
  13074. /** @hidden */
  13075. _currentColor1: Color4;
  13076. /** @hidden */
  13077. _currentColor2: Color4;
  13078. /** @hidden */
  13079. _currentSizeGradient: Nullable<FactorGradient>;
  13080. /** @hidden */
  13081. _currentSize1: number;
  13082. /** @hidden */
  13083. _currentSize2: number;
  13084. /** @hidden */
  13085. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13086. /** @hidden */
  13087. _currentAngularSpeed1: number;
  13088. /** @hidden */
  13089. _currentAngularSpeed2: number;
  13090. /** @hidden */
  13091. _currentVelocityGradient: Nullable<FactorGradient>;
  13092. /** @hidden */
  13093. _currentVelocity1: number;
  13094. /** @hidden */
  13095. _currentVelocity2: number;
  13096. /** @hidden */
  13097. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13098. /** @hidden */
  13099. _currentLimitVelocity1: number;
  13100. /** @hidden */
  13101. _currentLimitVelocity2: number;
  13102. /** @hidden */
  13103. _currentDragGradient: Nullable<FactorGradient>;
  13104. /** @hidden */
  13105. _currentDrag1: number;
  13106. /** @hidden */
  13107. _currentDrag2: number;
  13108. /** @hidden */
  13109. _randomNoiseCoordinates1: Vector3;
  13110. /** @hidden */
  13111. _randomNoiseCoordinates2: Vector3;
  13112. /** @hidden */
  13113. _localPosition?: Vector3;
  13114. /**
  13115. * Creates a new instance Particle
  13116. * @param particleSystem the particle system the particle belongs to
  13117. */
  13118. constructor(
  13119. /**
  13120. * The particle system the particle belongs to.
  13121. */
  13122. particleSystem: ParticleSystem);
  13123. private updateCellInfoFromSystem;
  13124. /**
  13125. * Defines how the sprite cell index is updated for the particle
  13126. */
  13127. updateCellIndex(): void;
  13128. /** @hidden */
  13129. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13130. /** @hidden */
  13131. _inheritParticleInfoToSubEmitters(): void;
  13132. /** @hidden */
  13133. _reset(): void;
  13134. /**
  13135. * Copy the properties of particle to another one.
  13136. * @param other the particle to copy the information to.
  13137. */
  13138. copyTo(other: Particle): void;
  13139. }
  13140. }
  13141. declare module BABYLON {
  13142. /**
  13143. * Particle emitter represents a volume emitting particles.
  13144. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13145. */
  13146. export interface IParticleEmitterType {
  13147. /**
  13148. * Called by the particle System when the direction is computed for the created particle.
  13149. * @param worldMatrix is the world matrix of the particle system
  13150. * @param directionToUpdate is the direction vector to update with the result
  13151. * @param particle is the particle we are computed the direction for
  13152. * @param isLocal defines if the direction should be set in local space
  13153. */
  13154. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13155. /**
  13156. * Called by the particle System when the position is computed for the created particle.
  13157. * @param worldMatrix is the world matrix of the particle system
  13158. * @param positionToUpdate is the position vector to update with the result
  13159. * @param particle is the particle we are computed the position for
  13160. * @param isLocal defines if the position should be set in local space
  13161. */
  13162. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13163. /**
  13164. * Clones the current emitter and returns a copy of it
  13165. * @returns the new emitter
  13166. */
  13167. clone(): IParticleEmitterType;
  13168. /**
  13169. * Called by the GPUParticleSystem to setup the update shader
  13170. * @param effect defines the update shader
  13171. */
  13172. applyToShader(effect: Effect): void;
  13173. /**
  13174. * Returns a string to use to update the GPU particles update shader
  13175. * @returns the effect defines string
  13176. */
  13177. getEffectDefines(): string;
  13178. /**
  13179. * Returns a string representing the class name
  13180. * @returns a string containing the class name
  13181. */
  13182. getClassName(): string;
  13183. /**
  13184. * Serializes the particle system to a JSON object.
  13185. * @returns the JSON object
  13186. */
  13187. serialize(): any;
  13188. /**
  13189. * Parse properties from a JSON object
  13190. * @param serializationObject defines the JSON object
  13191. * @param scene defines the hosting scene
  13192. */
  13193. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13194. }
  13195. }
  13196. declare module BABYLON {
  13197. /**
  13198. * Particle emitter emitting particles from the inside of a box.
  13199. * It emits the particles randomly between 2 given directions.
  13200. */
  13201. export class BoxParticleEmitter implements IParticleEmitterType {
  13202. /**
  13203. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13204. */
  13205. direction1: Vector3;
  13206. /**
  13207. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13208. */
  13209. direction2: Vector3;
  13210. /**
  13211. * 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.
  13212. */
  13213. minEmitBox: Vector3;
  13214. /**
  13215. * 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.
  13216. */
  13217. maxEmitBox: Vector3;
  13218. /**
  13219. * Creates a new instance BoxParticleEmitter
  13220. */
  13221. constructor();
  13222. /**
  13223. * Called by the particle System when the direction is computed for the created particle.
  13224. * @param worldMatrix is the world matrix of the particle system
  13225. * @param directionToUpdate is the direction vector to update with the result
  13226. * @param particle is the particle we are computed the direction for
  13227. * @param isLocal defines if the direction should be set in local space
  13228. */
  13229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13230. /**
  13231. * Called by the particle System when the position is computed for the created particle.
  13232. * @param worldMatrix is the world matrix of the particle system
  13233. * @param positionToUpdate is the position vector to update with the result
  13234. * @param particle is the particle we are computed the position for
  13235. * @param isLocal defines if the position should be set in local space
  13236. */
  13237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13238. /**
  13239. * Clones the current emitter and returns a copy of it
  13240. * @returns the new emitter
  13241. */
  13242. clone(): BoxParticleEmitter;
  13243. /**
  13244. * Called by the GPUParticleSystem to setup the update shader
  13245. * @param effect defines the update shader
  13246. */
  13247. applyToShader(effect: Effect): void;
  13248. /**
  13249. * Returns a string to use to update the GPU particles update shader
  13250. * @returns a string containng the defines string
  13251. */
  13252. getEffectDefines(): string;
  13253. /**
  13254. * Returns the string "BoxParticleEmitter"
  13255. * @returns a string containing the class name
  13256. */
  13257. getClassName(): string;
  13258. /**
  13259. * Serializes the particle system to a JSON object.
  13260. * @returns the JSON object
  13261. */
  13262. serialize(): any;
  13263. /**
  13264. * Parse properties from a JSON object
  13265. * @param serializationObject defines the JSON object
  13266. */
  13267. parse(serializationObject: any): void;
  13268. }
  13269. }
  13270. declare module BABYLON {
  13271. /**
  13272. * Particle emitter emitting particles from the inside of a cone.
  13273. * It emits the particles alongside the cone volume from the base to the particle.
  13274. * The emission direction might be randomized.
  13275. */
  13276. export class ConeParticleEmitter implements IParticleEmitterType {
  13277. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13278. directionRandomizer: number;
  13279. private _radius;
  13280. private _angle;
  13281. private _height;
  13282. /**
  13283. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13284. */
  13285. radiusRange: number;
  13286. /**
  13287. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13288. */
  13289. heightRange: number;
  13290. /**
  13291. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13292. */
  13293. emitFromSpawnPointOnly: boolean;
  13294. /**
  13295. * Gets or sets the radius of the emission cone
  13296. */
  13297. get radius(): number;
  13298. set radius(value: number);
  13299. /**
  13300. * Gets or sets the angle of the emission cone
  13301. */
  13302. get angle(): number;
  13303. set angle(value: number);
  13304. private _buildHeight;
  13305. /**
  13306. * Creates a new instance ConeParticleEmitter
  13307. * @param radius the radius of the emission cone (1 by default)
  13308. * @param angle the cone base angle (PI by default)
  13309. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13310. */
  13311. constructor(radius?: number, angle?: number,
  13312. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13313. directionRandomizer?: number);
  13314. /**
  13315. * Called by the particle System when the direction is computed for the created particle.
  13316. * @param worldMatrix is the world matrix of the particle system
  13317. * @param directionToUpdate is the direction vector to update with the result
  13318. * @param particle is the particle we are computed the direction for
  13319. * @param isLocal defines if the direction should be set in local space
  13320. */
  13321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13322. /**
  13323. * Called by the particle System when the position is computed for the created particle.
  13324. * @param worldMatrix is the world matrix of the particle system
  13325. * @param positionToUpdate is the position vector to update with the result
  13326. * @param particle is the particle we are computed the position for
  13327. * @param isLocal defines if the position should be set in local space
  13328. */
  13329. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13330. /**
  13331. * Clones the current emitter and returns a copy of it
  13332. * @returns the new emitter
  13333. */
  13334. clone(): ConeParticleEmitter;
  13335. /**
  13336. * Called by the GPUParticleSystem to setup the update shader
  13337. * @param effect defines the update shader
  13338. */
  13339. applyToShader(effect: Effect): void;
  13340. /**
  13341. * Returns a string to use to update the GPU particles update shader
  13342. * @returns a string containng the defines string
  13343. */
  13344. getEffectDefines(): string;
  13345. /**
  13346. * Returns the string "ConeParticleEmitter"
  13347. * @returns a string containing the class name
  13348. */
  13349. getClassName(): string;
  13350. /**
  13351. * Serializes the particle system to a JSON object.
  13352. * @returns the JSON object
  13353. */
  13354. serialize(): any;
  13355. /**
  13356. * Parse properties from a JSON object
  13357. * @param serializationObject defines the JSON object
  13358. */
  13359. parse(serializationObject: any): void;
  13360. }
  13361. }
  13362. declare module BABYLON {
  13363. /**
  13364. * Particle emitter emitting particles from the inside of a cylinder.
  13365. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13366. */
  13367. export class CylinderParticleEmitter implements IParticleEmitterType {
  13368. /**
  13369. * The radius of the emission cylinder.
  13370. */
  13371. radius: number;
  13372. /**
  13373. * The height of the emission cylinder.
  13374. */
  13375. height: number;
  13376. /**
  13377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13378. */
  13379. radiusRange: number;
  13380. /**
  13381. * How much to randomize the particle direction [0-1].
  13382. */
  13383. directionRandomizer: number;
  13384. /**
  13385. * Creates a new instance CylinderParticleEmitter
  13386. * @param radius the radius of the emission cylinder (1 by default)
  13387. * @param height the height of the emission cylinder (1 by default)
  13388. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13389. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13390. */
  13391. constructor(
  13392. /**
  13393. * The radius of the emission cylinder.
  13394. */
  13395. radius?: number,
  13396. /**
  13397. * The height of the emission cylinder.
  13398. */
  13399. height?: number,
  13400. /**
  13401. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13402. */
  13403. radiusRange?: number,
  13404. /**
  13405. * How much to randomize the particle direction [0-1].
  13406. */
  13407. directionRandomizer?: number);
  13408. /**
  13409. * Called by the particle System when the direction is computed for the created particle.
  13410. * @param worldMatrix is the world matrix of the particle system
  13411. * @param directionToUpdate is the direction vector to update with the result
  13412. * @param particle is the particle we are computed the direction for
  13413. * @param isLocal defines if the direction should be set in local space
  13414. */
  13415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13416. /**
  13417. * Called by the particle System when the position is computed for the created particle.
  13418. * @param worldMatrix is the world matrix of the particle system
  13419. * @param positionToUpdate is the position vector to update with the result
  13420. * @param particle is the particle we are computed the position for
  13421. * @param isLocal defines if the position should be set in local space
  13422. */
  13423. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13424. /**
  13425. * Clones the current emitter and returns a copy of it
  13426. * @returns the new emitter
  13427. */
  13428. clone(): CylinderParticleEmitter;
  13429. /**
  13430. * Called by the GPUParticleSystem to setup the update shader
  13431. * @param effect defines the update shader
  13432. */
  13433. applyToShader(effect: Effect): void;
  13434. /**
  13435. * Returns a string to use to update the GPU particles update shader
  13436. * @returns a string containng the defines string
  13437. */
  13438. getEffectDefines(): string;
  13439. /**
  13440. * Returns the string "CylinderParticleEmitter"
  13441. * @returns a string containing the class name
  13442. */
  13443. getClassName(): string;
  13444. /**
  13445. * Serializes the particle system to a JSON object.
  13446. * @returns the JSON object
  13447. */
  13448. serialize(): any;
  13449. /**
  13450. * Parse properties from a JSON object
  13451. * @param serializationObject defines the JSON object
  13452. */
  13453. parse(serializationObject: any): void;
  13454. }
  13455. /**
  13456. * Particle emitter emitting particles from the inside of a cylinder.
  13457. * It emits the particles randomly between two vectors.
  13458. */
  13459. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13460. /**
  13461. * The min limit of the emission direction.
  13462. */
  13463. direction1: Vector3;
  13464. /**
  13465. * The max limit of the emission direction.
  13466. */
  13467. direction2: Vector3;
  13468. /**
  13469. * Creates a new instance CylinderDirectedParticleEmitter
  13470. * @param radius the radius of the emission cylinder (1 by default)
  13471. * @param height the height of the emission cylinder (1 by default)
  13472. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13473. * @param direction1 the min limit of the emission direction (up vector by default)
  13474. * @param direction2 the max limit of the emission direction (up vector by default)
  13475. */
  13476. constructor(radius?: number, height?: number, radiusRange?: number,
  13477. /**
  13478. * The min limit of the emission direction.
  13479. */
  13480. direction1?: Vector3,
  13481. /**
  13482. * The max limit of the emission direction.
  13483. */
  13484. direction2?: Vector3);
  13485. /**
  13486. * Called by the particle System when the direction is computed for the created particle.
  13487. * @param worldMatrix is the world matrix of the particle system
  13488. * @param directionToUpdate is the direction vector to update with the result
  13489. * @param particle is the particle we are computed the direction for
  13490. */
  13491. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13492. /**
  13493. * Clones the current emitter and returns a copy of it
  13494. * @returns the new emitter
  13495. */
  13496. clone(): CylinderDirectedParticleEmitter;
  13497. /**
  13498. * Called by the GPUParticleSystem to setup the update shader
  13499. * @param effect defines the update shader
  13500. */
  13501. applyToShader(effect: Effect): void;
  13502. /**
  13503. * Returns a string to use to update the GPU particles update shader
  13504. * @returns a string containng the defines string
  13505. */
  13506. getEffectDefines(): string;
  13507. /**
  13508. * Returns the string "CylinderDirectedParticleEmitter"
  13509. * @returns a string containing the class name
  13510. */
  13511. getClassName(): string;
  13512. /**
  13513. * Serializes the particle system to a JSON object.
  13514. * @returns the JSON object
  13515. */
  13516. serialize(): any;
  13517. /**
  13518. * Parse properties from a JSON object
  13519. * @param serializationObject defines the JSON object
  13520. */
  13521. parse(serializationObject: any): void;
  13522. }
  13523. }
  13524. declare module BABYLON {
  13525. /**
  13526. * Particle emitter emitting particles from the inside of a hemisphere.
  13527. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13528. */
  13529. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13530. /**
  13531. * The radius of the emission hemisphere.
  13532. */
  13533. radius: number;
  13534. /**
  13535. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13536. */
  13537. radiusRange: number;
  13538. /**
  13539. * How much to randomize the particle direction [0-1].
  13540. */
  13541. directionRandomizer: number;
  13542. /**
  13543. * Creates a new instance HemisphericParticleEmitter
  13544. * @param radius the radius of the emission hemisphere (1 by default)
  13545. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13546. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13547. */
  13548. constructor(
  13549. /**
  13550. * The radius of the emission hemisphere.
  13551. */
  13552. radius?: number,
  13553. /**
  13554. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13555. */
  13556. radiusRange?: number,
  13557. /**
  13558. * How much to randomize the particle direction [0-1].
  13559. */
  13560. directionRandomizer?: number);
  13561. /**
  13562. * Called by the particle System when the direction is computed for the created particle.
  13563. * @param worldMatrix is the world matrix of the particle system
  13564. * @param directionToUpdate is the direction vector to update with the result
  13565. * @param particle is the particle we are computed the direction for
  13566. * @param isLocal defines if the direction should be set in local space
  13567. */
  13568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13569. /**
  13570. * Called by the particle System when the position is computed for the created particle.
  13571. * @param worldMatrix is the world matrix of the particle system
  13572. * @param positionToUpdate is the position vector to update with the result
  13573. * @param particle is the particle we are computed the position for
  13574. * @param isLocal defines if the position should be set in local space
  13575. */
  13576. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13577. /**
  13578. * Clones the current emitter and returns a copy of it
  13579. * @returns the new emitter
  13580. */
  13581. clone(): HemisphericParticleEmitter;
  13582. /**
  13583. * Called by the GPUParticleSystem to setup the update shader
  13584. * @param effect defines the update shader
  13585. */
  13586. applyToShader(effect: Effect): void;
  13587. /**
  13588. * Returns a string to use to update the GPU particles update shader
  13589. * @returns a string containng the defines string
  13590. */
  13591. getEffectDefines(): string;
  13592. /**
  13593. * Returns the string "HemisphericParticleEmitter"
  13594. * @returns a string containing the class name
  13595. */
  13596. getClassName(): string;
  13597. /**
  13598. * Serializes the particle system to a JSON object.
  13599. * @returns the JSON object
  13600. */
  13601. serialize(): any;
  13602. /**
  13603. * Parse properties from a JSON object
  13604. * @param serializationObject defines the JSON object
  13605. */
  13606. parse(serializationObject: any): void;
  13607. }
  13608. }
  13609. declare module BABYLON {
  13610. /**
  13611. * Particle emitter emitting particles from a point.
  13612. * It emits the particles randomly between 2 given directions.
  13613. */
  13614. export class PointParticleEmitter implements IParticleEmitterType {
  13615. /**
  13616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13617. */
  13618. direction1: Vector3;
  13619. /**
  13620. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13621. */
  13622. direction2: Vector3;
  13623. /**
  13624. * Creates a new instance PointParticleEmitter
  13625. */
  13626. constructor();
  13627. /**
  13628. * Called by the particle System when the direction is computed for the created particle.
  13629. * @param worldMatrix is the world matrix of the particle system
  13630. * @param directionToUpdate is the direction vector to update with the result
  13631. * @param particle is the particle we are computed the direction for
  13632. * @param isLocal defines if the direction should be set in local space
  13633. */
  13634. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13635. /**
  13636. * Called by the particle System when the position is computed for the created particle.
  13637. * @param worldMatrix is the world matrix of the particle system
  13638. * @param positionToUpdate is the position vector to update with the result
  13639. * @param particle is the particle we are computed the position for
  13640. * @param isLocal defines if the position should be set in local space
  13641. */
  13642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13643. /**
  13644. * Clones the current emitter and returns a copy of it
  13645. * @returns the new emitter
  13646. */
  13647. clone(): PointParticleEmitter;
  13648. /**
  13649. * Called by the GPUParticleSystem to setup the update shader
  13650. * @param effect defines the update shader
  13651. */
  13652. applyToShader(effect: Effect): void;
  13653. /**
  13654. * Returns a string to use to update the GPU particles update shader
  13655. * @returns a string containng the defines string
  13656. */
  13657. getEffectDefines(): string;
  13658. /**
  13659. * Returns the string "PointParticleEmitter"
  13660. * @returns a string containing the class name
  13661. */
  13662. getClassName(): string;
  13663. /**
  13664. * Serializes the particle system to a JSON object.
  13665. * @returns the JSON object
  13666. */
  13667. serialize(): any;
  13668. /**
  13669. * Parse properties from a JSON object
  13670. * @param serializationObject defines the JSON object
  13671. */
  13672. parse(serializationObject: any): void;
  13673. }
  13674. }
  13675. declare module BABYLON {
  13676. /**
  13677. * Particle emitter emitting particles from the inside of a sphere.
  13678. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13679. */
  13680. export class SphereParticleEmitter implements IParticleEmitterType {
  13681. /**
  13682. * The radius of the emission sphere.
  13683. */
  13684. radius: number;
  13685. /**
  13686. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13687. */
  13688. radiusRange: number;
  13689. /**
  13690. * How much to randomize the particle direction [0-1].
  13691. */
  13692. directionRandomizer: number;
  13693. /**
  13694. * Creates a new instance SphereParticleEmitter
  13695. * @param radius the radius of the emission sphere (1 by default)
  13696. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13697. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13698. */
  13699. constructor(
  13700. /**
  13701. * The radius of the emission sphere.
  13702. */
  13703. radius?: number,
  13704. /**
  13705. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13706. */
  13707. radiusRange?: number,
  13708. /**
  13709. * How much to randomize the particle direction [0-1].
  13710. */
  13711. directionRandomizer?: number);
  13712. /**
  13713. * Called by the particle System when the direction is computed for the created particle.
  13714. * @param worldMatrix is the world matrix of the particle system
  13715. * @param directionToUpdate is the direction vector to update with the result
  13716. * @param particle is the particle we are computed the direction for
  13717. * @param isLocal defines if the direction should be set in local space
  13718. */
  13719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13720. /**
  13721. * Called by the particle System when the position is computed for the created particle.
  13722. * @param worldMatrix is the world matrix of the particle system
  13723. * @param positionToUpdate is the position vector to update with the result
  13724. * @param particle is the particle we are computed the position for
  13725. * @param isLocal defines if the position should be set in local space
  13726. */
  13727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13728. /**
  13729. * Clones the current emitter and returns a copy of it
  13730. * @returns the new emitter
  13731. */
  13732. clone(): SphereParticleEmitter;
  13733. /**
  13734. * Called by the GPUParticleSystem to setup the update shader
  13735. * @param effect defines the update shader
  13736. */
  13737. applyToShader(effect: Effect): void;
  13738. /**
  13739. * Returns a string to use to update the GPU particles update shader
  13740. * @returns a string containng the defines string
  13741. */
  13742. getEffectDefines(): string;
  13743. /**
  13744. * Returns the string "SphereParticleEmitter"
  13745. * @returns a string containing the class name
  13746. */
  13747. getClassName(): string;
  13748. /**
  13749. * Serializes the particle system to a JSON object.
  13750. * @returns the JSON object
  13751. */
  13752. serialize(): any;
  13753. /**
  13754. * Parse properties from a JSON object
  13755. * @param serializationObject defines the JSON object
  13756. */
  13757. parse(serializationObject: any): void;
  13758. }
  13759. /**
  13760. * Particle emitter emitting particles from the inside of a sphere.
  13761. * It emits the particles randomly between two vectors.
  13762. */
  13763. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13764. /**
  13765. * The min limit of the emission direction.
  13766. */
  13767. direction1: Vector3;
  13768. /**
  13769. * The max limit of the emission direction.
  13770. */
  13771. direction2: Vector3;
  13772. /**
  13773. * Creates a new instance SphereDirectedParticleEmitter
  13774. * @param radius the radius of the emission sphere (1 by default)
  13775. * @param direction1 the min limit of the emission direction (up vector by default)
  13776. * @param direction2 the max limit of the emission direction (up vector by default)
  13777. */
  13778. constructor(radius?: number,
  13779. /**
  13780. * The min limit of the emission direction.
  13781. */
  13782. direction1?: Vector3,
  13783. /**
  13784. * The max limit of the emission direction.
  13785. */
  13786. direction2?: Vector3);
  13787. /**
  13788. * Called by the particle System when the direction is computed for the created particle.
  13789. * @param worldMatrix is the world matrix of the particle system
  13790. * @param directionToUpdate is the direction vector to update with the result
  13791. * @param particle is the particle we are computed the direction for
  13792. */
  13793. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13794. /**
  13795. * Clones the current emitter and returns a copy of it
  13796. * @returns the new emitter
  13797. */
  13798. clone(): SphereDirectedParticleEmitter;
  13799. /**
  13800. * Called by the GPUParticleSystem to setup the update shader
  13801. * @param effect defines the update shader
  13802. */
  13803. applyToShader(effect: Effect): void;
  13804. /**
  13805. * Returns a string to use to update the GPU particles update shader
  13806. * @returns a string containng the defines string
  13807. */
  13808. getEffectDefines(): string;
  13809. /**
  13810. * Returns the string "SphereDirectedParticleEmitter"
  13811. * @returns a string containing the class name
  13812. */
  13813. getClassName(): string;
  13814. /**
  13815. * Serializes the particle system to a JSON object.
  13816. * @returns the JSON object
  13817. */
  13818. serialize(): any;
  13819. /**
  13820. * Parse properties from a JSON object
  13821. * @param serializationObject defines the JSON object
  13822. */
  13823. parse(serializationObject: any): void;
  13824. }
  13825. }
  13826. declare module BABYLON {
  13827. /**
  13828. * Particle emitter emitting particles from a custom list of positions.
  13829. */
  13830. export class CustomParticleEmitter implements IParticleEmitterType {
  13831. /**
  13832. * Gets or sets the position generator that will create the inital position of each particle.
  13833. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13834. */
  13835. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13836. /**
  13837. * Gets or sets the destination generator that will create the final destination of each particle.
  13838. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13839. */
  13840. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13841. /**
  13842. * Creates a new instance CustomParticleEmitter
  13843. */
  13844. constructor();
  13845. /**
  13846. * Called by the particle System when the direction is computed for the created particle.
  13847. * @param worldMatrix is the world matrix of the particle system
  13848. * @param directionToUpdate is the direction vector to update with the result
  13849. * @param particle is the particle we are computed the direction for
  13850. * @param isLocal defines if the direction should be set in local space
  13851. */
  13852. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13853. /**
  13854. * Called by the particle System when the position is computed for the created particle.
  13855. * @param worldMatrix is the world matrix of the particle system
  13856. * @param positionToUpdate is the position vector to update with the result
  13857. * @param particle is the particle we are computed the position for
  13858. * @param isLocal defines if the position should be set in local space
  13859. */
  13860. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13861. /**
  13862. * Clones the current emitter and returns a copy of it
  13863. * @returns the new emitter
  13864. */
  13865. clone(): CustomParticleEmitter;
  13866. /**
  13867. * Called by the GPUParticleSystem to setup the update shader
  13868. * @param effect defines the update shader
  13869. */
  13870. applyToShader(effect: Effect): void;
  13871. /**
  13872. * Returns a string to use to update the GPU particles update shader
  13873. * @returns a string containng the defines string
  13874. */
  13875. getEffectDefines(): string;
  13876. /**
  13877. * Returns the string "PointParticleEmitter"
  13878. * @returns a string containing the class name
  13879. */
  13880. getClassName(): string;
  13881. /**
  13882. * Serializes the particle system to a JSON object.
  13883. * @returns the JSON object
  13884. */
  13885. serialize(): any;
  13886. /**
  13887. * Parse properties from a JSON object
  13888. * @param serializationObject defines the JSON object
  13889. */
  13890. parse(serializationObject: any): void;
  13891. }
  13892. }
  13893. declare module BABYLON {
  13894. /**
  13895. * Particle emitter emitting particles from the inside of a box.
  13896. * It emits the particles randomly between 2 given directions.
  13897. */
  13898. export class MeshParticleEmitter implements IParticleEmitterType {
  13899. private _indices;
  13900. private _positions;
  13901. private _normals;
  13902. private _storedNormal;
  13903. private _mesh;
  13904. /**
  13905. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13906. */
  13907. direction1: Vector3;
  13908. /**
  13909. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13910. */
  13911. direction2: Vector3;
  13912. /**
  13913. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13914. */
  13915. useMeshNormalsForDirection: boolean;
  13916. /** Defines the mesh to use as source */
  13917. get mesh(): Nullable<AbstractMesh>;
  13918. set mesh(value: Nullable<AbstractMesh>);
  13919. /**
  13920. * Creates a new instance MeshParticleEmitter
  13921. * @param mesh defines the mesh to use as source
  13922. */
  13923. constructor(mesh?: Nullable<AbstractMesh>);
  13924. /**
  13925. * Called by the particle System when the direction is computed for the created particle.
  13926. * @param worldMatrix is the world matrix of the particle system
  13927. * @param directionToUpdate is the direction vector to update with the result
  13928. * @param particle is the particle we are computed the direction for
  13929. * @param isLocal defines if the direction should be set in local space
  13930. */
  13931. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13932. /**
  13933. * Called by the particle System when the position is computed for the created particle.
  13934. * @param worldMatrix is the world matrix of the particle system
  13935. * @param positionToUpdate is the position vector to update with the result
  13936. * @param particle is the particle we are computed the position for
  13937. * @param isLocal defines if the position should be set in local space
  13938. */
  13939. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13940. /**
  13941. * Clones the current emitter and returns a copy of it
  13942. * @returns the new emitter
  13943. */
  13944. clone(): MeshParticleEmitter;
  13945. /**
  13946. * Called by the GPUParticleSystem to setup the update shader
  13947. * @param effect defines the update shader
  13948. */
  13949. applyToShader(effect: Effect): void;
  13950. /**
  13951. * Returns a string to use to update the GPU particles update shader
  13952. * @returns a string containng the defines string
  13953. */
  13954. getEffectDefines(): string;
  13955. /**
  13956. * Returns the string "BoxParticleEmitter"
  13957. * @returns a string containing the class name
  13958. */
  13959. getClassName(): string;
  13960. /**
  13961. * Serializes the particle system to a JSON object.
  13962. * @returns the JSON object
  13963. */
  13964. serialize(): any;
  13965. /**
  13966. * Parse properties from a JSON object
  13967. * @param serializationObject defines the JSON object
  13968. * @param scene defines the hosting scene
  13969. */
  13970. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13971. }
  13972. }
  13973. declare module BABYLON {
  13974. /**
  13975. * Interface representing a particle system in Babylon.js.
  13976. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13977. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13978. */
  13979. export interface IParticleSystem {
  13980. /**
  13981. * List of animations used by the particle system.
  13982. */
  13983. animations: Animation[];
  13984. /**
  13985. * The id of the Particle system.
  13986. */
  13987. id: string;
  13988. /**
  13989. * The name of the Particle system.
  13990. */
  13991. name: string;
  13992. /**
  13993. * The emitter represents the Mesh or position we are attaching the particle system to.
  13994. */
  13995. emitter: Nullable<AbstractMesh | Vector3>;
  13996. /**
  13997. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13998. */
  13999. isBillboardBased: boolean;
  14000. /**
  14001. * The rendering group used by the Particle system to chose when to render.
  14002. */
  14003. renderingGroupId: number;
  14004. /**
  14005. * The layer mask we are rendering the particles through.
  14006. */
  14007. layerMask: number;
  14008. /**
  14009. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14010. */
  14011. updateSpeed: number;
  14012. /**
  14013. * The amount of time the particle system is running (depends of the overall update speed).
  14014. */
  14015. targetStopDuration: number;
  14016. /**
  14017. * The texture used to render each particle. (this can be a spritesheet)
  14018. */
  14019. particleTexture: Nullable<BaseTexture>;
  14020. /**
  14021. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14022. */
  14023. blendMode: number;
  14024. /**
  14025. * Minimum life time of emitting particles.
  14026. */
  14027. minLifeTime: number;
  14028. /**
  14029. * Maximum life time of emitting particles.
  14030. */
  14031. maxLifeTime: number;
  14032. /**
  14033. * Minimum Size of emitting particles.
  14034. */
  14035. minSize: number;
  14036. /**
  14037. * Maximum Size of emitting particles.
  14038. */
  14039. maxSize: number;
  14040. /**
  14041. * Minimum scale of emitting particles on X axis.
  14042. */
  14043. minScaleX: number;
  14044. /**
  14045. * Maximum scale of emitting particles on X axis.
  14046. */
  14047. maxScaleX: number;
  14048. /**
  14049. * Minimum scale of emitting particles on Y axis.
  14050. */
  14051. minScaleY: number;
  14052. /**
  14053. * Maximum scale of emitting particles on Y axis.
  14054. */
  14055. maxScaleY: number;
  14056. /**
  14057. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14058. */
  14059. color1: Color4;
  14060. /**
  14061. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14062. */
  14063. color2: Color4;
  14064. /**
  14065. * Color the particle will have at the end of its lifetime.
  14066. */
  14067. colorDead: Color4;
  14068. /**
  14069. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14070. */
  14071. emitRate: number;
  14072. /**
  14073. * You can use gravity if you want to give an orientation to your particles.
  14074. */
  14075. gravity: Vector3;
  14076. /**
  14077. * Minimum power of emitting particles.
  14078. */
  14079. minEmitPower: number;
  14080. /**
  14081. * Maximum power of emitting particles.
  14082. */
  14083. maxEmitPower: number;
  14084. /**
  14085. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14086. */
  14087. minAngularSpeed: number;
  14088. /**
  14089. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14090. */
  14091. maxAngularSpeed: number;
  14092. /**
  14093. * Gets or sets the minimal initial rotation in radians.
  14094. */
  14095. minInitialRotation: number;
  14096. /**
  14097. * Gets or sets the maximal initial rotation in radians.
  14098. */
  14099. maxInitialRotation: number;
  14100. /**
  14101. * The particle emitter type defines the emitter used by the particle system.
  14102. * It can be for example box, sphere, or cone...
  14103. */
  14104. particleEmitterType: Nullable<IParticleEmitterType>;
  14105. /**
  14106. * Defines the delay in milliseconds before starting the system (0 by default)
  14107. */
  14108. startDelay: number;
  14109. /**
  14110. * 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
  14111. */
  14112. preWarmCycles: number;
  14113. /**
  14114. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14115. */
  14116. preWarmStepOffset: number;
  14117. /**
  14118. * 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)
  14119. */
  14120. spriteCellChangeSpeed: number;
  14121. /**
  14122. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14123. */
  14124. startSpriteCellID: number;
  14125. /**
  14126. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14127. */
  14128. endSpriteCellID: number;
  14129. /**
  14130. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14131. */
  14132. spriteCellWidth: number;
  14133. /**
  14134. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14135. */
  14136. spriteCellHeight: number;
  14137. /**
  14138. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14139. */
  14140. spriteRandomStartCell: boolean;
  14141. /**
  14142. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14143. */
  14144. isAnimationSheetEnabled: boolean;
  14145. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14146. translationPivot: Vector2;
  14147. /**
  14148. * Gets or sets a texture used to add random noise to particle positions
  14149. */
  14150. noiseTexture: Nullable<BaseTexture>;
  14151. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14152. noiseStrength: Vector3;
  14153. /**
  14154. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14155. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14156. */
  14157. billboardMode: number;
  14158. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14159. limitVelocityDamping: number;
  14160. /**
  14161. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14162. */
  14163. beginAnimationOnStart: boolean;
  14164. /**
  14165. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14166. */
  14167. beginAnimationFrom: number;
  14168. /**
  14169. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14170. */
  14171. beginAnimationTo: number;
  14172. /**
  14173. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14174. */
  14175. beginAnimationLoop: boolean;
  14176. /**
  14177. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14178. */
  14179. disposeOnStop: boolean;
  14180. /**
  14181. * Specifies if the particles are updated in emitter local space or world space
  14182. */
  14183. isLocal: boolean;
  14184. /** Snippet ID if the particle system was created from the snippet server */
  14185. snippetId: string;
  14186. /** Gets or sets a matrix to use to compute projection */
  14187. defaultProjectionMatrix: Matrix;
  14188. /**
  14189. * Gets the maximum number of particles active at the same time.
  14190. * @returns The max number of active particles.
  14191. */
  14192. getCapacity(): number;
  14193. /**
  14194. * Gets the number of particles active at the same time.
  14195. * @returns The number of active particles.
  14196. */
  14197. getActiveCount(): number;
  14198. /**
  14199. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14200. * @returns True if it has been started, otherwise false.
  14201. */
  14202. isStarted(): boolean;
  14203. /**
  14204. * Animates the particle system for this frame.
  14205. */
  14206. animate(): void;
  14207. /**
  14208. * Renders the particle system in its current state.
  14209. * @returns the current number of particles
  14210. */
  14211. render(): number;
  14212. /**
  14213. * Dispose the particle system and frees its associated resources.
  14214. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14215. */
  14216. dispose(disposeTexture?: boolean): void;
  14217. /**
  14218. * An event triggered when the system is disposed
  14219. */
  14220. onDisposeObservable: Observable<IParticleSystem>;
  14221. /**
  14222. * Clones the particle system.
  14223. * @param name The name of the cloned object
  14224. * @param newEmitter The new emitter to use
  14225. * @returns the cloned particle system
  14226. */
  14227. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14228. /**
  14229. * Serializes the particle system to a JSON object
  14230. * @param serializeTexture defines if the texture must be serialized as well
  14231. * @returns the JSON object
  14232. */
  14233. serialize(serializeTexture: boolean): any;
  14234. /**
  14235. * Rebuild the particle system
  14236. */
  14237. rebuild(): void;
  14238. /** Force the system to rebuild all gradients that need to be resync */
  14239. forceRefreshGradients(): void;
  14240. /**
  14241. * Starts the particle system and begins to emit
  14242. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14243. */
  14244. start(delay?: number): void;
  14245. /**
  14246. * Stops the particle system.
  14247. */
  14248. stop(): void;
  14249. /**
  14250. * Remove all active particles
  14251. */
  14252. reset(): void;
  14253. /**
  14254. * Gets a boolean indicating that the system is stopping
  14255. * @returns true if the system is currently stopping
  14256. */
  14257. isStopping(): boolean;
  14258. /**
  14259. * Is this system ready to be used/rendered
  14260. * @return true if the system is ready
  14261. */
  14262. isReady(): boolean;
  14263. /**
  14264. * Returns the string "ParticleSystem"
  14265. * @returns a string containing the class name
  14266. */
  14267. getClassName(): string;
  14268. /**
  14269. * Gets the custom effect used to render the particles
  14270. * @param blendMode Blend mode for which the effect should be retrieved
  14271. * @returns The effect
  14272. */
  14273. getCustomEffect(blendMode: number): Nullable<Effect>;
  14274. /**
  14275. * Sets the custom effect used to render the particles
  14276. * @param effect The effect to set
  14277. * @param blendMode Blend mode for which the effect should be set
  14278. */
  14279. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14280. /**
  14281. * Fill the defines array according to the current settings of the particle system
  14282. * @param defines Array to be updated
  14283. * @param blendMode blend mode to take into account when updating the array
  14284. */
  14285. fillDefines(defines: Array<string>, blendMode: number): void;
  14286. /**
  14287. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14288. * @param uniforms Uniforms array to fill
  14289. * @param attributes Attributes array to fill
  14290. * @param samplers Samplers array to fill
  14291. */
  14292. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14293. /**
  14294. * Observable that will be called just before the particles are drawn
  14295. */
  14296. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14297. /**
  14298. * Gets the name of the particle vertex shader
  14299. */
  14300. vertexShaderName: string;
  14301. /**
  14302. * Adds a new color gradient
  14303. * @param gradient defines the gradient to use (between 0 and 1)
  14304. * @param color1 defines the color to affect to the specified gradient
  14305. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14306. * @returns the current particle system
  14307. */
  14308. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14309. /**
  14310. * Remove a specific color gradient
  14311. * @param gradient defines the gradient to remove
  14312. * @returns the current particle system
  14313. */
  14314. removeColorGradient(gradient: number): IParticleSystem;
  14315. /**
  14316. * Adds a new size gradient
  14317. * @param gradient defines the gradient to use (between 0 and 1)
  14318. * @param factor defines the size factor to affect to the specified gradient
  14319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14320. * @returns the current particle system
  14321. */
  14322. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14323. /**
  14324. * Remove a specific size gradient
  14325. * @param gradient defines the gradient to remove
  14326. * @returns the current particle system
  14327. */
  14328. removeSizeGradient(gradient: number): IParticleSystem;
  14329. /**
  14330. * Gets the current list of color gradients.
  14331. * You must use addColorGradient and removeColorGradient to udpate this list
  14332. * @returns the list of color gradients
  14333. */
  14334. getColorGradients(): Nullable<Array<ColorGradient>>;
  14335. /**
  14336. * Gets the current list of size gradients.
  14337. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14338. * @returns the list of size gradients
  14339. */
  14340. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14341. /**
  14342. * Gets the current list of angular speed gradients.
  14343. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14344. * @returns the list of angular speed gradients
  14345. */
  14346. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14347. /**
  14348. * Adds a new angular speed gradient
  14349. * @param gradient defines the gradient to use (between 0 and 1)
  14350. * @param factor defines the angular speed to affect to the specified gradient
  14351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14352. * @returns the current particle system
  14353. */
  14354. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14355. /**
  14356. * Remove a specific angular speed gradient
  14357. * @param gradient defines the gradient to remove
  14358. * @returns the current particle system
  14359. */
  14360. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14361. /**
  14362. * Gets the current list of velocity gradients.
  14363. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14364. * @returns the list of velocity gradients
  14365. */
  14366. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14367. /**
  14368. * Adds a new velocity gradient
  14369. * @param gradient defines the gradient to use (between 0 and 1)
  14370. * @param factor defines the velocity to affect to the specified gradient
  14371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14372. * @returns the current particle system
  14373. */
  14374. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14375. /**
  14376. * Remove a specific velocity gradient
  14377. * @param gradient defines the gradient to remove
  14378. * @returns the current particle system
  14379. */
  14380. removeVelocityGradient(gradient: number): IParticleSystem;
  14381. /**
  14382. * Gets the current list of limit velocity gradients.
  14383. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14384. * @returns the list of limit velocity gradients
  14385. */
  14386. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14387. /**
  14388. * Adds a new limit velocity gradient
  14389. * @param gradient defines the gradient to use (between 0 and 1)
  14390. * @param factor defines the limit velocity to affect to the specified gradient
  14391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14392. * @returns the current particle system
  14393. */
  14394. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14395. /**
  14396. * Remove a specific limit velocity gradient
  14397. * @param gradient defines the gradient to remove
  14398. * @returns the current particle system
  14399. */
  14400. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14401. /**
  14402. * Adds a new drag gradient
  14403. * @param gradient defines the gradient to use (between 0 and 1)
  14404. * @param factor defines the drag to affect to the specified gradient
  14405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14406. * @returns the current particle system
  14407. */
  14408. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14409. /**
  14410. * Remove a specific drag gradient
  14411. * @param gradient defines the gradient to remove
  14412. * @returns the current particle system
  14413. */
  14414. removeDragGradient(gradient: number): IParticleSystem;
  14415. /**
  14416. * Gets the current list of drag gradients.
  14417. * You must use addDragGradient and removeDragGradient to udpate this list
  14418. * @returns the list of drag gradients
  14419. */
  14420. getDragGradients(): Nullable<Array<FactorGradient>>;
  14421. /**
  14422. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14423. * @param gradient defines the gradient to use (between 0 and 1)
  14424. * @param factor defines the emit rate to affect to the specified gradient
  14425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14426. * @returns the current particle system
  14427. */
  14428. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14429. /**
  14430. * Remove a specific emit rate gradient
  14431. * @param gradient defines the gradient to remove
  14432. * @returns the current particle system
  14433. */
  14434. removeEmitRateGradient(gradient: number): IParticleSystem;
  14435. /**
  14436. * Gets the current list of emit rate gradients.
  14437. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14438. * @returns the list of emit rate gradients
  14439. */
  14440. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14441. /**
  14442. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14443. * @param gradient defines the gradient to use (between 0 and 1)
  14444. * @param factor defines the start size to affect to the specified gradient
  14445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14446. * @returns the current particle system
  14447. */
  14448. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14449. /**
  14450. * Remove a specific start size gradient
  14451. * @param gradient defines the gradient to remove
  14452. * @returns the current particle system
  14453. */
  14454. removeStartSizeGradient(gradient: number): IParticleSystem;
  14455. /**
  14456. * Gets the current list of start size gradients.
  14457. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14458. * @returns the list of start size gradients
  14459. */
  14460. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14461. /**
  14462. * Adds a new life time gradient
  14463. * @param gradient defines the gradient to use (between 0 and 1)
  14464. * @param factor defines the life time factor to affect to the specified gradient
  14465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14466. * @returns the current particle system
  14467. */
  14468. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14469. /**
  14470. * Remove a specific life time gradient
  14471. * @param gradient defines the gradient to remove
  14472. * @returns the current particle system
  14473. */
  14474. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14475. /**
  14476. * Gets the current list of life time gradients.
  14477. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14478. * @returns the list of life time gradients
  14479. */
  14480. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14481. /**
  14482. * Gets the current list of color gradients.
  14483. * You must use addColorGradient and removeColorGradient to udpate this list
  14484. * @returns the list of color gradients
  14485. */
  14486. getColorGradients(): Nullable<Array<ColorGradient>>;
  14487. /**
  14488. * Adds a new ramp gradient used to remap particle colors
  14489. * @param gradient defines the gradient to use (between 0 and 1)
  14490. * @param color defines the color to affect to the specified gradient
  14491. * @returns the current particle system
  14492. */
  14493. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14494. /**
  14495. * Gets the current list of ramp gradients.
  14496. * You must use addRampGradient and removeRampGradient to udpate this list
  14497. * @returns the list of ramp gradients
  14498. */
  14499. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14500. /** Gets or sets a boolean indicating that ramp gradients must be used
  14501. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14502. */
  14503. useRampGradients: boolean;
  14504. /**
  14505. * Adds a new color remap gradient
  14506. * @param gradient defines the gradient to use (between 0 and 1)
  14507. * @param min defines the color remap minimal range
  14508. * @param max defines the color remap maximal range
  14509. * @returns the current particle system
  14510. */
  14511. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14512. /**
  14513. * Gets the current list of color remap gradients.
  14514. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14515. * @returns the list of color remap gradients
  14516. */
  14517. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14518. /**
  14519. * Adds a new alpha remap gradient
  14520. * @param gradient defines the gradient to use (between 0 and 1)
  14521. * @param min defines the alpha remap minimal range
  14522. * @param max defines the alpha remap maximal range
  14523. * @returns the current particle system
  14524. */
  14525. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14526. /**
  14527. * Gets the current list of alpha remap gradients.
  14528. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14529. * @returns the list of alpha remap gradients
  14530. */
  14531. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14532. /**
  14533. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14534. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14535. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14536. * @returns the emitter
  14537. */
  14538. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14539. /**
  14540. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14541. * @param radius The radius of the hemisphere to emit from
  14542. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14543. * @returns the emitter
  14544. */
  14545. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14546. /**
  14547. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14548. * @param radius The radius of the sphere to emit from
  14549. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14550. * @returns the emitter
  14551. */
  14552. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14553. /**
  14554. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14555. * @param radius The radius of the sphere to emit from
  14556. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14557. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14558. * @returns the emitter
  14559. */
  14560. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14561. /**
  14562. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14563. * @param radius The radius of the emission cylinder
  14564. * @param height The height of the emission cylinder
  14565. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14566. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14567. * @returns the emitter
  14568. */
  14569. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14570. /**
  14571. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14572. * @param radius The radius of the cylinder to emit from
  14573. * @param height The height of the emission cylinder
  14574. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14575. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14576. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14577. * @returns the emitter
  14578. */
  14579. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14580. /**
  14581. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14582. * @param radius The radius of the cone to emit from
  14583. * @param angle The base angle of the cone
  14584. * @returns the emitter
  14585. */
  14586. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14587. /**
  14588. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14589. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14590. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14591. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14592. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14593. * @returns the emitter
  14594. */
  14595. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14596. /**
  14597. * Get hosting scene
  14598. * @returns the scene
  14599. */
  14600. getScene(): Nullable<Scene>;
  14601. }
  14602. }
  14603. declare module BABYLON {
  14604. /**
  14605. * 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.
  14606. * @see https://doc.babylonjs.com/how_to/transformnode
  14607. */
  14608. export class TransformNode extends Node {
  14609. /**
  14610. * Object will not rotate to face the camera
  14611. */
  14612. static BILLBOARDMODE_NONE: number;
  14613. /**
  14614. * Object will rotate to face the camera but only on the x axis
  14615. */
  14616. static BILLBOARDMODE_X: number;
  14617. /**
  14618. * Object will rotate to face the camera but only on the y axis
  14619. */
  14620. static BILLBOARDMODE_Y: number;
  14621. /**
  14622. * Object will rotate to face the camera but only on the z axis
  14623. */
  14624. static BILLBOARDMODE_Z: number;
  14625. /**
  14626. * Object will rotate to face the camera
  14627. */
  14628. static BILLBOARDMODE_ALL: number;
  14629. /**
  14630. * Object will rotate to face the camera's position instead of orientation
  14631. */
  14632. static BILLBOARDMODE_USE_POSITION: number;
  14633. private static _TmpRotation;
  14634. private static _TmpScaling;
  14635. private static _TmpTranslation;
  14636. private _forward;
  14637. private _forwardInverted;
  14638. private _up;
  14639. private _right;
  14640. private _rightInverted;
  14641. private _position;
  14642. private _rotation;
  14643. private _rotationQuaternion;
  14644. protected _scaling: Vector3;
  14645. protected _isDirty: boolean;
  14646. private _transformToBoneReferal;
  14647. private _isAbsoluteSynced;
  14648. private _billboardMode;
  14649. /**
  14650. * Gets or sets the billboard mode. Default is 0.
  14651. *
  14652. * | Value | Type | Description |
  14653. * | --- | --- | --- |
  14654. * | 0 | BILLBOARDMODE_NONE | |
  14655. * | 1 | BILLBOARDMODE_X | |
  14656. * | 2 | BILLBOARDMODE_Y | |
  14657. * | 4 | BILLBOARDMODE_Z | |
  14658. * | 7 | BILLBOARDMODE_ALL | |
  14659. *
  14660. */
  14661. get billboardMode(): number;
  14662. set billboardMode(value: number);
  14663. private _preserveParentRotationForBillboard;
  14664. /**
  14665. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14666. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14667. */
  14668. get preserveParentRotationForBillboard(): boolean;
  14669. set preserveParentRotationForBillboard(value: boolean);
  14670. /**
  14671. * 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
  14672. */
  14673. scalingDeterminant: number;
  14674. private _infiniteDistance;
  14675. /**
  14676. * Gets or sets the distance of the object to max, often used by skybox
  14677. */
  14678. get infiniteDistance(): boolean;
  14679. set infiniteDistance(value: boolean);
  14680. /**
  14681. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14682. * By default the system will update normals to compensate
  14683. */
  14684. ignoreNonUniformScaling: boolean;
  14685. /**
  14686. * 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
  14687. */
  14688. reIntegrateRotationIntoRotationQuaternion: boolean;
  14689. /** @hidden */
  14690. _poseMatrix: Nullable<Matrix>;
  14691. /** @hidden */
  14692. _localMatrix: Matrix;
  14693. private _usePivotMatrix;
  14694. private _absolutePosition;
  14695. private _absoluteScaling;
  14696. private _absoluteRotationQuaternion;
  14697. private _pivotMatrix;
  14698. private _pivotMatrixInverse;
  14699. protected _postMultiplyPivotMatrix: boolean;
  14700. protected _isWorldMatrixFrozen: boolean;
  14701. /** @hidden */
  14702. _indexInSceneTransformNodesArray: number;
  14703. /**
  14704. * An event triggered after the world matrix is updated
  14705. */
  14706. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14707. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14708. /**
  14709. * Gets a string identifying the name of the class
  14710. * @returns "TransformNode" string
  14711. */
  14712. getClassName(): string;
  14713. /**
  14714. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14715. */
  14716. get position(): Vector3;
  14717. set position(newPosition: Vector3);
  14718. /**
  14719. * 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)).
  14720. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14721. */
  14722. get rotation(): Vector3;
  14723. set rotation(newRotation: Vector3);
  14724. /**
  14725. * 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)).
  14726. */
  14727. get scaling(): Vector3;
  14728. set scaling(newScaling: Vector3);
  14729. /**
  14730. * 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).
  14731. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14732. */
  14733. get rotationQuaternion(): Nullable<Quaternion>;
  14734. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14735. /**
  14736. * The forward direction of that transform in world space.
  14737. */
  14738. get forward(): Vector3;
  14739. /**
  14740. * The up direction of that transform in world space.
  14741. */
  14742. get up(): Vector3;
  14743. /**
  14744. * The right direction of that transform in world space.
  14745. */
  14746. get right(): Vector3;
  14747. /**
  14748. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14749. * @param matrix the matrix to copy the pose from
  14750. * @returns this TransformNode.
  14751. */
  14752. updatePoseMatrix(matrix: Matrix): TransformNode;
  14753. /**
  14754. * Returns the mesh Pose matrix.
  14755. * @returns the pose matrix
  14756. */
  14757. getPoseMatrix(): Matrix;
  14758. /** @hidden */
  14759. _isSynchronized(): boolean;
  14760. /** @hidden */
  14761. _initCache(): void;
  14762. /**
  14763. * Flag the transform node as dirty (Forcing it to update everything)
  14764. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14765. * @returns this transform node
  14766. */
  14767. markAsDirty(property: string): TransformNode;
  14768. /**
  14769. * Returns the current mesh absolute position.
  14770. * Returns a Vector3.
  14771. */
  14772. get absolutePosition(): Vector3;
  14773. /**
  14774. * Returns the current mesh absolute scaling.
  14775. * Returns a Vector3.
  14776. */
  14777. get absoluteScaling(): Vector3;
  14778. /**
  14779. * Returns the current mesh absolute rotation.
  14780. * Returns a Quaternion.
  14781. */
  14782. get absoluteRotationQuaternion(): Quaternion;
  14783. /**
  14784. * Sets a new matrix to apply before all other transformation
  14785. * @param matrix defines the transform matrix
  14786. * @returns the current TransformNode
  14787. */
  14788. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14789. /**
  14790. * Sets a new pivot matrix to the current node
  14791. * @param matrix defines the new pivot matrix to use
  14792. * @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
  14793. * @returns the current TransformNode
  14794. */
  14795. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14796. /**
  14797. * Returns the mesh pivot matrix.
  14798. * Default : Identity.
  14799. * @returns the matrix
  14800. */
  14801. getPivotMatrix(): Matrix;
  14802. /**
  14803. * Instantiate (when possible) or clone that node with its hierarchy
  14804. * @param newParent defines the new parent to use for the instance (or clone)
  14805. * @param options defines options to configure how copy is done
  14806. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14807. * @returns an instance (or a clone) of the current node with its hiearchy
  14808. */
  14809. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14810. doNotInstantiate: boolean;
  14811. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14812. /**
  14813. * Prevents the World matrix to be computed any longer
  14814. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14815. * @returns the TransformNode.
  14816. */
  14817. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14818. /**
  14819. * Allows back the World matrix computation.
  14820. * @returns the TransformNode.
  14821. */
  14822. unfreezeWorldMatrix(): this;
  14823. /**
  14824. * True if the World matrix has been frozen.
  14825. */
  14826. get isWorldMatrixFrozen(): boolean;
  14827. /**
  14828. * Retuns the mesh absolute position in the World.
  14829. * @returns a Vector3.
  14830. */
  14831. getAbsolutePosition(): Vector3;
  14832. /**
  14833. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14834. * @param absolutePosition the absolute position to set
  14835. * @returns the TransformNode.
  14836. */
  14837. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14838. /**
  14839. * Sets the mesh position in its local space.
  14840. * @param vector3 the position to set in localspace
  14841. * @returns the TransformNode.
  14842. */
  14843. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14844. /**
  14845. * Returns the mesh position in the local space from the current World matrix values.
  14846. * @returns a new Vector3.
  14847. */
  14848. getPositionExpressedInLocalSpace(): Vector3;
  14849. /**
  14850. * Translates the mesh along the passed Vector3 in its local space.
  14851. * @param vector3 the distance to translate in localspace
  14852. * @returns the TransformNode.
  14853. */
  14854. locallyTranslate(vector3: Vector3): TransformNode;
  14855. private static _lookAtVectorCache;
  14856. /**
  14857. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14858. * @param targetPoint the position (must be in same space as current mesh) to look at
  14859. * @param yawCor optional yaw (y-axis) correction in radians
  14860. * @param pitchCor optional pitch (x-axis) correction in radians
  14861. * @param rollCor optional roll (z-axis) correction in radians
  14862. * @param space the choosen space of the target
  14863. * @returns the TransformNode.
  14864. */
  14865. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14866. /**
  14867. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14868. * This Vector3 is expressed in the World space.
  14869. * @param localAxis axis to rotate
  14870. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14871. */
  14872. getDirection(localAxis: Vector3): Vector3;
  14873. /**
  14874. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14875. * localAxis is expressed in the mesh local space.
  14876. * result is computed in the Wordl space from the mesh World matrix.
  14877. * @param localAxis axis to rotate
  14878. * @param result the resulting transformnode
  14879. * @returns this TransformNode.
  14880. */
  14881. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14882. /**
  14883. * Sets this transform node rotation to the given local axis.
  14884. * @param localAxis the axis in local space
  14885. * @param yawCor optional yaw (y-axis) correction in radians
  14886. * @param pitchCor optional pitch (x-axis) correction in radians
  14887. * @param rollCor optional roll (z-axis) correction in radians
  14888. * @returns this TransformNode
  14889. */
  14890. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14891. /**
  14892. * Sets a new pivot point to the current node
  14893. * @param point defines the new pivot point to use
  14894. * @param space defines if the point is in world or local space (local by default)
  14895. * @returns the current TransformNode
  14896. */
  14897. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14898. /**
  14899. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14900. * @returns the pivot point
  14901. */
  14902. getPivotPoint(): Vector3;
  14903. /**
  14904. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14905. * @param result the vector3 to store the result
  14906. * @returns this TransformNode.
  14907. */
  14908. getPivotPointToRef(result: Vector3): TransformNode;
  14909. /**
  14910. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14911. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14912. */
  14913. getAbsolutePivotPoint(): Vector3;
  14914. /**
  14915. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14916. * @param result vector3 to store the result
  14917. * @returns this TransformNode.
  14918. */
  14919. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14920. /**
  14921. * Defines the passed node as the parent of the current node.
  14922. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14923. * @see https://doc.babylonjs.com/how_to/parenting
  14924. * @param node the node ot set as the parent
  14925. * @returns this TransformNode.
  14926. */
  14927. setParent(node: Nullable<Node>): TransformNode;
  14928. private _nonUniformScaling;
  14929. /**
  14930. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14931. */
  14932. get nonUniformScaling(): boolean;
  14933. /** @hidden */
  14934. _updateNonUniformScalingState(value: boolean): boolean;
  14935. /**
  14936. * Attach the current TransformNode to another TransformNode associated with a bone
  14937. * @param bone Bone affecting the TransformNode
  14938. * @param affectedTransformNode TransformNode associated with the bone
  14939. * @returns this object
  14940. */
  14941. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14942. /**
  14943. * Detach the transform node if its associated with a bone
  14944. * @returns this object
  14945. */
  14946. detachFromBone(): TransformNode;
  14947. private static _rotationAxisCache;
  14948. /**
  14949. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14950. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14951. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14952. * The passed axis is also normalized.
  14953. * @param axis the axis to rotate around
  14954. * @param amount the amount to rotate in radians
  14955. * @param space Space to rotate in (Default: local)
  14956. * @returns the TransformNode.
  14957. */
  14958. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14959. /**
  14960. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14961. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14962. * The passed axis is also normalized. .
  14963. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14964. * @param point the point to rotate around
  14965. * @param axis the axis to rotate around
  14966. * @param amount the amount to rotate in radians
  14967. * @returns the TransformNode
  14968. */
  14969. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14970. /**
  14971. * Translates the mesh along the axis vector for the passed distance in the given space.
  14972. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14973. * @param axis the axis to translate in
  14974. * @param distance the distance to translate
  14975. * @param space Space to rotate in (Default: local)
  14976. * @returns the TransformNode.
  14977. */
  14978. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14979. /**
  14980. * Adds a rotation step to the mesh current rotation.
  14981. * x, y, z are Euler angles expressed in radians.
  14982. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14983. * This means this rotation is made in the mesh local space only.
  14984. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14985. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14986. * ```javascript
  14987. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14988. * ```
  14989. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14990. * 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.
  14991. * @param x Rotation to add
  14992. * @param y Rotation to add
  14993. * @param z Rotation to add
  14994. * @returns the TransformNode.
  14995. */
  14996. addRotation(x: number, y: number, z: number): TransformNode;
  14997. /**
  14998. * @hidden
  14999. */
  15000. protected _getEffectiveParent(): Nullable<Node>;
  15001. /**
  15002. * Computes the world matrix of the node
  15003. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15004. * @returns the world matrix
  15005. */
  15006. computeWorldMatrix(force?: boolean): Matrix;
  15007. /**
  15008. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15009. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15010. */
  15011. resetLocalMatrix(independentOfChildren?: boolean): void;
  15012. protected _afterComputeWorldMatrix(): void;
  15013. /**
  15014. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15015. * @param func callback function to add
  15016. *
  15017. * @returns the TransformNode.
  15018. */
  15019. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15020. /**
  15021. * Removes a registered callback function.
  15022. * @param func callback function to remove
  15023. * @returns the TransformNode.
  15024. */
  15025. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15026. /**
  15027. * Gets the position of the current mesh in camera space
  15028. * @param camera defines the camera to use
  15029. * @returns a position
  15030. */
  15031. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15032. /**
  15033. * Returns the distance from the mesh to the active camera
  15034. * @param camera defines the camera to use
  15035. * @returns the distance
  15036. */
  15037. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15038. /**
  15039. * Clone the current transform node
  15040. * @param name Name of the new clone
  15041. * @param newParent New parent for the clone
  15042. * @param doNotCloneChildren Do not clone children hierarchy
  15043. * @returns the new transform node
  15044. */
  15045. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15046. /**
  15047. * Serializes the objects information.
  15048. * @param currentSerializationObject defines the object to serialize in
  15049. * @returns the serialized object
  15050. */
  15051. serialize(currentSerializationObject?: any): any;
  15052. /**
  15053. * Returns a new TransformNode object parsed from the source provided.
  15054. * @param parsedTransformNode is the source.
  15055. * @param scene the scne the object belongs to
  15056. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15057. * @returns a new TransformNode object parsed from the source provided.
  15058. */
  15059. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15060. /**
  15061. * Get all child-transformNodes of this node
  15062. * @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
  15063. * @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
  15064. * @returns an array of TransformNode
  15065. */
  15066. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15067. /**
  15068. * Releases resources associated with this transform node.
  15069. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15070. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15071. */
  15072. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15073. /**
  15074. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15075. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15076. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15077. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15078. * @returns the current mesh
  15079. */
  15080. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15081. private _syncAbsoluteScalingAndRotation;
  15082. }
  15083. }
  15084. declare module BABYLON {
  15085. /**
  15086. * Class used to override all child animations of a given target
  15087. */
  15088. export class AnimationPropertiesOverride {
  15089. /**
  15090. * Gets or sets a value indicating if animation blending must be used
  15091. */
  15092. enableBlending: boolean;
  15093. /**
  15094. * Gets or sets the blending speed to use when enableBlending is true
  15095. */
  15096. blendingSpeed: number;
  15097. /**
  15098. * Gets or sets the default loop mode to use
  15099. */
  15100. loopMode: number;
  15101. }
  15102. }
  15103. declare module BABYLON {
  15104. /**
  15105. * Class used to store bone information
  15106. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15107. */
  15108. export class Bone extends Node {
  15109. /**
  15110. * defines the bone name
  15111. */
  15112. name: string;
  15113. private static _tmpVecs;
  15114. private static _tmpQuat;
  15115. private static _tmpMats;
  15116. /**
  15117. * Gets the list of child bones
  15118. */
  15119. children: Bone[];
  15120. /** Gets the animations associated with this bone */
  15121. animations: Animation[];
  15122. /**
  15123. * Gets or sets bone length
  15124. */
  15125. length: number;
  15126. /**
  15127. * @hidden Internal only
  15128. * Set this value to map this bone to a different index in the transform matrices
  15129. * Set this value to -1 to exclude the bone from the transform matrices
  15130. */
  15131. _index: Nullable<number>;
  15132. private _skeleton;
  15133. private _localMatrix;
  15134. private _restPose;
  15135. private _bindPose;
  15136. private _baseMatrix;
  15137. private _absoluteTransform;
  15138. private _invertedAbsoluteTransform;
  15139. private _parent;
  15140. private _scalingDeterminant;
  15141. private _worldTransform;
  15142. private _localScaling;
  15143. private _localRotation;
  15144. private _localPosition;
  15145. private _needToDecompose;
  15146. private _needToCompose;
  15147. /** @hidden */
  15148. _linkedTransformNode: Nullable<TransformNode>;
  15149. /** @hidden */
  15150. _waitingTransformNodeId: Nullable<string>;
  15151. /** @hidden */
  15152. get _matrix(): Matrix;
  15153. /** @hidden */
  15154. set _matrix(value: Matrix);
  15155. /**
  15156. * Create a new bone
  15157. * @param name defines the bone name
  15158. * @param skeleton defines the parent skeleton
  15159. * @param parentBone defines the parent (can be null if the bone is the root)
  15160. * @param localMatrix defines the local matrix
  15161. * @param restPose defines the rest pose matrix
  15162. * @param baseMatrix defines the base matrix
  15163. * @param index defines index of the bone in the hiearchy
  15164. */
  15165. constructor(
  15166. /**
  15167. * defines the bone name
  15168. */
  15169. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15170. /**
  15171. * Gets the current object class name.
  15172. * @return the class name
  15173. */
  15174. getClassName(): string;
  15175. /**
  15176. * Gets the parent skeleton
  15177. * @returns a skeleton
  15178. */
  15179. getSkeleton(): Skeleton;
  15180. /**
  15181. * Gets parent bone
  15182. * @returns a bone or null if the bone is the root of the bone hierarchy
  15183. */
  15184. getParent(): Nullable<Bone>;
  15185. /**
  15186. * Returns an array containing the root bones
  15187. * @returns an array containing the root bones
  15188. */
  15189. getChildren(): Array<Bone>;
  15190. /**
  15191. * Gets the node index in matrix array generated for rendering
  15192. * @returns the node index
  15193. */
  15194. getIndex(): number;
  15195. /**
  15196. * Sets the parent bone
  15197. * @param parent defines the parent (can be null if the bone is the root)
  15198. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15199. */
  15200. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15201. /**
  15202. * Gets the local matrix
  15203. * @returns a matrix
  15204. */
  15205. getLocalMatrix(): Matrix;
  15206. /**
  15207. * Gets the base matrix (initial matrix which remains unchanged)
  15208. * @returns a matrix
  15209. */
  15210. getBaseMatrix(): Matrix;
  15211. /**
  15212. * Gets the rest pose matrix
  15213. * @returns a matrix
  15214. */
  15215. getRestPose(): Matrix;
  15216. /**
  15217. * Sets the rest pose matrix
  15218. * @param matrix the local-space rest pose to set for this bone
  15219. */
  15220. setRestPose(matrix: Matrix): void;
  15221. /**
  15222. * Gets the bind pose matrix
  15223. * @returns the bind pose matrix
  15224. */
  15225. getBindPose(): Matrix;
  15226. /**
  15227. * Sets the bind pose matrix
  15228. * @param matrix the local-space bind pose to set for this bone
  15229. */
  15230. setBindPose(matrix: Matrix): void;
  15231. /**
  15232. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15233. */
  15234. getWorldMatrix(): Matrix;
  15235. /**
  15236. * Sets the local matrix to rest pose matrix
  15237. */
  15238. returnToRest(): void;
  15239. /**
  15240. * Gets the inverse of the absolute transform matrix.
  15241. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15242. * @returns a matrix
  15243. */
  15244. getInvertedAbsoluteTransform(): Matrix;
  15245. /**
  15246. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15247. * @returns a matrix
  15248. */
  15249. getAbsoluteTransform(): Matrix;
  15250. /**
  15251. * Links with the given transform node.
  15252. * The local matrix of this bone is copied from the transform node every frame.
  15253. * @param transformNode defines the transform node to link to
  15254. */
  15255. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15256. /**
  15257. * Gets the node used to drive the bone's transformation
  15258. * @returns a transform node or null
  15259. */
  15260. getTransformNode(): Nullable<TransformNode>;
  15261. /** Gets or sets current position (in local space) */
  15262. get position(): Vector3;
  15263. set position(newPosition: Vector3);
  15264. /** Gets or sets current rotation (in local space) */
  15265. get rotation(): Vector3;
  15266. set rotation(newRotation: Vector3);
  15267. /** Gets or sets current rotation quaternion (in local space) */
  15268. get rotationQuaternion(): Quaternion;
  15269. set rotationQuaternion(newRotation: Quaternion);
  15270. /** Gets or sets current scaling (in local space) */
  15271. get scaling(): Vector3;
  15272. set scaling(newScaling: Vector3);
  15273. /**
  15274. * Gets the animation properties override
  15275. */
  15276. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15277. private _decompose;
  15278. private _compose;
  15279. /**
  15280. * Update the base and local matrices
  15281. * @param matrix defines the new base or local matrix
  15282. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15283. * @param updateLocalMatrix defines if the local matrix should be updated
  15284. */
  15285. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15286. /** @hidden */
  15287. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15288. /**
  15289. * Flag the bone as dirty (Forcing it to update everything)
  15290. */
  15291. markAsDirty(): void;
  15292. /** @hidden */
  15293. _markAsDirtyAndCompose(): void;
  15294. private _markAsDirtyAndDecompose;
  15295. /**
  15296. * Translate the bone in local or world space
  15297. * @param vec The amount to translate the bone
  15298. * @param space The space that the translation is in
  15299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15300. */
  15301. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15302. /**
  15303. * Set the postion of the bone in local or world space
  15304. * @param position The position to set the bone
  15305. * @param space The space that the position is in
  15306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15307. */
  15308. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15309. /**
  15310. * Set the absolute position of the bone (world space)
  15311. * @param position The position to set the bone
  15312. * @param mesh The mesh that this bone is attached to
  15313. */
  15314. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15315. /**
  15316. * Scale the bone on the x, y and z axes (in local space)
  15317. * @param x The amount to scale the bone on the x axis
  15318. * @param y The amount to scale the bone on the y axis
  15319. * @param z The amount to scale the bone on the z axis
  15320. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15321. */
  15322. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15323. /**
  15324. * Set the bone scaling in local space
  15325. * @param scale defines the scaling vector
  15326. */
  15327. setScale(scale: Vector3): void;
  15328. /**
  15329. * Gets the current scaling in local space
  15330. * @returns the current scaling vector
  15331. */
  15332. getScale(): Vector3;
  15333. /**
  15334. * Gets the current scaling in local space and stores it in a target vector
  15335. * @param result defines the target vector
  15336. */
  15337. getScaleToRef(result: Vector3): void;
  15338. /**
  15339. * Set the yaw, pitch, and roll of the bone in local or world space
  15340. * @param yaw The rotation of the bone on the y axis
  15341. * @param pitch The rotation of the bone on the x axis
  15342. * @param roll The rotation of the bone on the z axis
  15343. * @param space The space that the axes of rotation are in
  15344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15345. */
  15346. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15347. /**
  15348. * Add a rotation to the bone on an axis in local or world space
  15349. * @param axis The axis to rotate the bone on
  15350. * @param amount The amount to rotate the bone
  15351. * @param space The space that the axis is in
  15352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15353. */
  15354. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15355. /**
  15356. * Set the rotation of the bone to a particular axis angle in local or world space
  15357. * @param axis The axis to rotate the bone on
  15358. * @param angle The angle that the bone should be rotated to
  15359. * @param space The space that the axis is in
  15360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15361. */
  15362. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15363. /**
  15364. * Set the euler rotation of the bone in local of world space
  15365. * @param rotation The euler rotation that the bone should be set to
  15366. * @param space The space that the rotation is in
  15367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15368. */
  15369. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15370. /**
  15371. * Set the quaternion rotation of the bone in local of world space
  15372. * @param quat The quaternion rotation that the bone should be set to
  15373. * @param space The space that the rotation is in
  15374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15375. */
  15376. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15377. /**
  15378. * Set the rotation matrix of the bone in local of world space
  15379. * @param rotMat The rotation matrix that the bone should be set to
  15380. * @param space The space that the rotation is in
  15381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15382. */
  15383. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15384. private _rotateWithMatrix;
  15385. private _getNegativeRotationToRef;
  15386. /**
  15387. * Get the position of the bone in local or world space
  15388. * @param space The space that the returned position is in
  15389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15390. * @returns The position of the bone
  15391. */
  15392. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15393. /**
  15394. * Copy the position of the bone to a vector3 in local or world space
  15395. * @param space The space that the returned position is in
  15396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15397. * @param result The vector3 to copy the position to
  15398. */
  15399. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15400. /**
  15401. * Get the absolute position of the bone (world space)
  15402. * @param mesh The mesh that this bone is attached to
  15403. * @returns The absolute position of the bone
  15404. */
  15405. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15406. /**
  15407. * Copy the absolute position of the bone (world space) to the result param
  15408. * @param mesh The mesh that this bone is attached to
  15409. * @param result The vector3 to copy the absolute position to
  15410. */
  15411. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15412. /**
  15413. * Compute the absolute transforms of this bone and its children
  15414. */
  15415. computeAbsoluteTransforms(): void;
  15416. /**
  15417. * Get the world direction from an axis that is in the local space of the bone
  15418. * @param localAxis The local direction that is used to compute the world direction
  15419. * @param mesh The mesh that this bone is attached to
  15420. * @returns The world direction
  15421. */
  15422. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15423. /**
  15424. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15425. * @param localAxis The local direction that is used to compute the world direction
  15426. * @param mesh The mesh that this bone is attached to
  15427. * @param result The vector3 that the world direction will be copied to
  15428. */
  15429. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15430. /**
  15431. * Get the euler rotation of the bone in local or world space
  15432. * @param space The space that the rotation should be in
  15433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15434. * @returns The euler rotation
  15435. */
  15436. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15437. /**
  15438. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15439. * @param space The space that the rotation should be in
  15440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15441. * @param result The vector3 that the rotation should be copied to
  15442. */
  15443. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15444. /**
  15445. * Get the quaternion rotation of the bone in either local or world space
  15446. * @param space The space that the rotation should be in
  15447. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15448. * @returns The quaternion rotation
  15449. */
  15450. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15451. /**
  15452. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15453. * @param space The space that the rotation should be in
  15454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15455. * @param result The quaternion that the rotation should be copied to
  15456. */
  15457. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15458. /**
  15459. * Get the rotation matrix of the bone in local or world space
  15460. * @param space The space that the rotation should be in
  15461. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15462. * @returns The rotation matrix
  15463. */
  15464. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15465. /**
  15466. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15467. * @param space The space that the rotation should be in
  15468. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15469. * @param result The quaternion that the rotation should be copied to
  15470. */
  15471. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15472. /**
  15473. * Get the world position of a point that is in the local space of the bone
  15474. * @param position The local position
  15475. * @param mesh The mesh that this bone is attached to
  15476. * @returns The world position
  15477. */
  15478. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15479. /**
  15480. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15481. * @param position The local position
  15482. * @param mesh The mesh that this bone is attached to
  15483. * @param result The vector3 that the world position should be copied to
  15484. */
  15485. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15486. /**
  15487. * Get the local position of a point that is in world space
  15488. * @param position The world position
  15489. * @param mesh The mesh that this bone is attached to
  15490. * @returns The local position
  15491. */
  15492. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15493. /**
  15494. * Get the local position of a point that is in world space and copy it to the result param
  15495. * @param position The world position
  15496. * @param mesh The mesh that this bone is attached to
  15497. * @param result The vector3 that the local position should be copied to
  15498. */
  15499. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15500. }
  15501. }
  15502. declare module BABYLON {
  15503. /**
  15504. * Defines a runtime animation
  15505. */
  15506. export class RuntimeAnimation {
  15507. private _events;
  15508. /**
  15509. * The current frame of the runtime animation
  15510. */
  15511. private _currentFrame;
  15512. /**
  15513. * The animation used by the runtime animation
  15514. */
  15515. private _animation;
  15516. /**
  15517. * The target of the runtime animation
  15518. */
  15519. private _target;
  15520. /**
  15521. * The initiating animatable
  15522. */
  15523. private _host;
  15524. /**
  15525. * The original value of the runtime animation
  15526. */
  15527. private _originalValue;
  15528. /**
  15529. * The original blend value of the runtime animation
  15530. */
  15531. private _originalBlendValue;
  15532. /**
  15533. * The offsets cache of the runtime animation
  15534. */
  15535. private _offsetsCache;
  15536. /**
  15537. * The high limits cache of the runtime animation
  15538. */
  15539. private _highLimitsCache;
  15540. /**
  15541. * Specifies if the runtime animation has been stopped
  15542. */
  15543. private _stopped;
  15544. /**
  15545. * The blending factor of the runtime animation
  15546. */
  15547. private _blendingFactor;
  15548. /**
  15549. * The BabylonJS scene
  15550. */
  15551. private _scene;
  15552. /**
  15553. * The current value of the runtime animation
  15554. */
  15555. private _currentValue;
  15556. /** @hidden */
  15557. _animationState: _IAnimationState;
  15558. /**
  15559. * The active target of the runtime animation
  15560. */
  15561. private _activeTargets;
  15562. private _currentActiveTarget;
  15563. private _directTarget;
  15564. /**
  15565. * The target path of the runtime animation
  15566. */
  15567. private _targetPath;
  15568. /**
  15569. * The weight of the runtime animation
  15570. */
  15571. private _weight;
  15572. /**
  15573. * The ratio offset of the runtime animation
  15574. */
  15575. private _ratioOffset;
  15576. /**
  15577. * The previous delay of the runtime animation
  15578. */
  15579. private _previousDelay;
  15580. /**
  15581. * The previous ratio of the runtime animation
  15582. */
  15583. private _previousRatio;
  15584. private _enableBlending;
  15585. private _keys;
  15586. private _minFrame;
  15587. private _maxFrame;
  15588. private _minValue;
  15589. private _maxValue;
  15590. private _targetIsArray;
  15591. /**
  15592. * Gets the current frame of the runtime animation
  15593. */
  15594. get currentFrame(): number;
  15595. /**
  15596. * Gets the weight of the runtime animation
  15597. */
  15598. get weight(): number;
  15599. /**
  15600. * Gets the current value of the runtime animation
  15601. */
  15602. get currentValue(): any;
  15603. /**
  15604. * Gets the target path of the runtime animation
  15605. */
  15606. get targetPath(): string;
  15607. /**
  15608. * Gets the actual target of the runtime animation
  15609. */
  15610. get target(): any;
  15611. /**
  15612. * Gets the additive state of the runtime animation
  15613. */
  15614. get isAdditive(): boolean;
  15615. /** @hidden */
  15616. _onLoop: () => void;
  15617. /**
  15618. * Create a new RuntimeAnimation object
  15619. * @param target defines the target of the animation
  15620. * @param animation defines the source animation object
  15621. * @param scene defines the hosting scene
  15622. * @param host defines the initiating Animatable
  15623. */
  15624. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15625. private _preparePath;
  15626. /**
  15627. * Gets the animation from the runtime animation
  15628. */
  15629. get animation(): Animation;
  15630. /**
  15631. * Resets the runtime animation to the beginning
  15632. * @param restoreOriginal defines whether to restore the target property to the original value
  15633. */
  15634. reset(restoreOriginal?: boolean): void;
  15635. /**
  15636. * Specifies if the runtime animation is stopped
  15637. * @returns Boolean specifying if the runtime animation is stopped
  15638. */
  15639. isStopped(): boolean;
  15640. /**
  15641. * Disposes of the runtime animation
  15642. */
  15643. dispose(): void;
  15644. /**
  15645. * Apply the interpolated value to the target
  15646. * @param currentValue defines the value computed by the animation
  15647. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15648. */
  15649. setValue(currentValue: any, weight: number): void;
  15650. private _getOriginalValues;
  15651. private _setValue;
  15652. /**
  15653. * Gets the loop pmode of the runtime animation
  15654. * @returns Loop Mode
  15655. */
  15656. private _getCorrectLoopMode;
  15657. /**
  15658. * Move the current animation to a given frame
  15659. * @param frame defines the frame to move to
  15660. */
  15661. goToFrame(frame: number): void;
  15662. /**
  15663. * @hidden Internal use only
  15664. */
  15665. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15666. /**
  15667. * Execute the current animation
  15668. * @param delay defines the delay to add to the current frame
  15669. * @param from defines the lower bound of the animation range
  15670. * @param to defines the upper bound of the animation range
  15671. * @param loop defines if the current animation must loop
  15672. * @param speedRatio defines the current speed ratio
  15673. * @param weight defines the weight of the animation (default is -1 so no weight)
  15674. * @param onLoop optional callback called when animation loops
  15675. * @returns a boolean indicating if the animation is running
  15676. */
  15677. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15678. }
  15679. }
  15680. declare module BABYLON {
  15681. /**
  15682. * Class used to store an actual running animation
  15683. */
  15684. export class Animatable {
  15685. /** defines the target object */
  15686. target: any;
  15687. /** defines the starting frame number (default is 0) */
  15688. fromFrame: number;
  15689. /** defines the ending frame number (default is 100) */
  15690. toFrame: number;
  15691. /** defines if the animation must loop (default is false) */
  15692. loopAnimation: boolean;
  15693. /** defines a callback to call when animation ends if it is not looping */
  15694. onAnimationEnd?: (() => void) | null | undefined;
  15695. /** defines a callback to call when animation loops */
  15696. onAnimationLoop?: (() => void) | null | undefined;
  15697. /** defines whether the animation should be evaluated additively */
  15698. isAdditive: boolean;
  15699. private _localDelayOffset;
  15700. private _pausedDelay;
  15701. private _runtimeAnimations;
  15702. private _paused;
  15703. private _scene;
  15704. private _speedRatio;
  15705. private _weight;
  15706. private _syncRoot;
  15707. /**
  15708. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15709. * This will only apply for non looping animation (default is true)
  15710. */
  15711. disposeOnEnd: boolean;
  15712. /**
  15713. * Gets a boolean indicating if the animation has started
  15714. */
  15715. animationStarted: boolean;
  15716. /**
  15717. * Observer raised when the animation ends
  15718. */
  15719. onAnimationEndObservable: Observable<Animatable>;
  15720. /**
  15721. * Observer raised when the animation loops
  15722. */
  15723. onAnimationLoopObservable: Observable<Animatable>;
  15724. /**
  15725. * Gets the root Animatable used to synchronize and normalize animations
  15726. */
  15727. get syncRoot(): Nullable<Animatable>;
  15728. /**
  15729. * Gets the current frame of the first RuntimeAnimation
  15730. * Used to synchronize Animatables
  15731. */
  15732. get masterFrame(): number;
  15733. /**
  15734. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15735. */
  15736. get weight(): number;
  15737. set weight(value: number);
  15738. /**
  15739. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15740. */
  15741. get speedRatio(): number;
  15742. set speedRatio(value: number);
  15743. /**
  15744. * Creates a new Animatable
  15745. * @param scene defines the hosting scene
  15746. * @param target defines the target object
  15747. * @param fromFrame defines the starting frame number (default is 0)
  15748. * @param toFrame defines the ending frame number (default is 100)
  15749. * @param loopAnimation defines if the animation must loop (default is false)
  15750. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15751. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15752. * @param animations defines a group of animation to add to the new Animatable
  15753. * @param onAnimationLoop defines a callback to call when animation loops
  15754. * @param isAdditive defines whether the animation should be evaluated additively
  15755. */
  15756. constructor(scene: Scene,
  15757. /** defines the target object */
  15758. target: any,
  15759. /** defines the starting frame number (default is 0) */
  15760. fromFrame?: number,
  15761. /** defines the ending frame number (default is 100) */
  15762. toFrame?: number,
  15763. /** defines if the animation must loop (default is false) */
  15764. loopAnimation?: boolean, speedRatio?: number,
  15765. /** defines a callback to call when animation ends if it is not looping */
  15766. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15767. /** defines a callback to call when animation loops */
  15768. onAnimationLoop?: (() => void) | null | undefined,
  15769. /** defines whether the animation should be evaluated additively */
  15770. isAdditive?: boolean);
  15771. /**
  15772. * Synchronize and normalize current Animatable with a source Animatable
  15773. * This is useful when using animation weights and when animations are not of the same length
  15774. * @param root defines the root Animatable to synchronize with
  15775. * @returns the current Animatable
  15776. */
  15777. syncWith(root: Animatable): Animatable;
  15778. /**
  15779. * Gets the list of runtime animations
  15780. * @returns an array of RuntimeAnimation
  15781. */
  15782. getAnimations(): RuntimeAnimation[];
  15783. /**
  15784. * Adds more animations to the current animatable
  15785. * @param target defines the target of the animations
  15786. * @param animations defines the new animations to add
  15787. */
  15788. appendAnimations(target: any, animations: Animation[]): void;
  15789. /**
  15790. * Gets the source animation for a specific property
  15791. * @param property defines the propertyu to look for
  15792. * @returns null or the source animation for the given property
  15793. */
  15794. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15795. /**
  15796. * Gets the runtime animation for a specific property
  15797. * @param property defines the propertyu to look for
  15798. * @returns null or the runtime animation for the given property
  15799. */
  15800. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15801. /**
  15802. * Resets the animatable to its original state
  15803. */
  15804. reset(): void;
  15805. /**
  15806. * Allows the animatable to blend with current running animations
  15807. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15808. * @param blendingSpeed defines the blending speed to use
  15809. */
  15810. enableBlending(blendingSpeed: number): void;
  15811. /**
  15812. * Disable animation blending
  15813. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15814. */
  15815. disableBlending(): void;
  15816. /**
  15817. * Jump directly to a given frame
  15818. * @param frame defines the frame to jump to
  15819. */
  15820. goToFrame(frame: number): void;
  15821. /**
  15822. * Pause the animation
  15823. */
  15824. pause(): void;
  15825. /**
  15826. * Restart the animation
  15827. */
  15828. restart(): void;
  15829. private _raiseOnAnimationEnd;
  15830. /**
  15831. * Stop and delete the current animation
  15832. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15833. * @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)
  15834. */
  15835. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15836. /**
  15837. * Wait asynchronously for the animation to end
  15838. * @returns a promise which will be fullfilled when the animation ends
  15839. */
  15840. waitAsync(): Promise<Animatable>;
  15841. /** @hidden */
  15842. _animate(delay: number): boolean;
  15843. }
  15844. interface Scene {
  15845. /** @hidden */
  15846. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15847. /** @hidden */
  15848. _processLateAnimationBindingsForMatrices(holder: {
  15849. totalWeight: number;
  15850. totalAdditiveWeight: number;
  15851. animations: RuntimeAnimation[];
  15852. additiveAnimations: RuntimeAnimation[];
  15853. originalValue: Matrix;
  15854. }): any;
  15855. /** @hidden */
  15856. _processLateAnimationBindingsForQuaternions(holder: {
  15857. totalWeight: number;
  15858. totalAdditiveWeight: number;
  15859. animations: RuntimeAnimation[];
  15860. additiveAnimations: RuntimeAnimation[];
  15861. originalValue: Quaternion;
  15862. }, refQuaternion: Quaternion): Quaternion;
  15863. /** @hidden */
  15864. _processLateAnimationBindings(): void;
  15865. /**
  15866. * Will start the animation sequence of a given target
  15867. * @param target defines the target
  15868. * @param from defines from which frame should animation start
  15869. * @param to defines until which frame should animation run.
  15870. * @param weight defines the weight to apply to the animation (1.0 by default)
  15871. * @param loop defines if the animation loops
  15872. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15873. * @param onAnimationEnd defines the function to be executed when the animation ends
  15874. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15875. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15876. * @param onAnimationLoop defines the callback to call when an animation loops
  15877. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15878. * @returns the animatable object created for this animation
  15879. */
  15880. 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;
  15881. /**
  15882. * Will start the animation sequence of a given target
  15883. * @param target defines the target
  15884. * @param from defines from which frame should animation start
  15885. * @param to defines until which frame should animation run.
  15886. * @param loop defines if the animation loops
  15887. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15888. * @param onAnimationEnd defines the function to be executed when the animation ends
  15889. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15890. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15891. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15892. * @param onAnimationLoop defines the callback to call when an animation loops
  15893. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15894. * @returns the animatable object created for this animation
  15895. */
  15896. 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;
  15897. /**
  15898. * Will start the animation sequence of a given target and its hierarchy
  15899. * @param target defines the target
  15900. * @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.
  15901. * @param from defines from which frame should animation start
  15902. * @param to defines until which frame should animation run.
  15903. * @param loop defines if the animation loops
  15904. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15905. * @param onAnimationEnd defines the function to be executed when the animation ends
  15906. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15907. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15908. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15909. * @param onAnimationLoop defines the callback to call when an animation loops
  15910. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15911. * @returns the list of created animatables
  15912. */
  15913. 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[];
  15914. /**
  15915. * Begin a new animation on a given node
  15916. * @param target defines the target where the animation will take place
  15917. * @param animations defines the list of animations to start
  15918. * @param from defines the initial value
  15919. * @param to defines the final value
  15920. * @param loop defines if you want animation to loop (off by default)
  15921. * @param speedRatio defines the speed ratio to apply to all animations
  15922. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15923. * @param onAnimationLoop defines the callback to call when an animation loops
  15924. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15925. * @returns the list of created animatables
  15926. */
  15927. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15928. /**
  15929. * Begin a new animation on a given node and its hierarchy
  15930. * @param target defines the root node where the animation will take place
  15931. * @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.
  15932. * @param animations defines the list of animations to start
  15933. * @param from defines the initial value
  15934. * @param to defines the final value
  15935. * @param loop defines if you want animation to loop (off by default)
  15936. * @param speedRatio defines the speed ratio to apply to all animations
  15937. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15938. * @param onAnimationLoop defines the callback to call when an animation loops
  15939. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15940. * @returns the list of animatables created for all nodes
  15941. */
  15942. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15943. /**
  15944. * Gets the animatable associated with a specific target
  15945. * @param target defines the target of the animatable
  15946. * @returns the required animatable if found
  15947. */
  15948. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15949. /**
  15950. * Gets all animatables associated with a given target
  15951. * @param target defines the target to look animatables for
  15952. * @returns an array of Animatables
  15953. */
  15954. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15955. /**
  15956. * Stops and removes all animations that have been applied to the scene
  15957. */
  15958. stopAllAnimations(): void;
  15959. /**
  15960. * Gets the current delta time used by animation engine
  15961. */
  15962. deltaTime: number;
  15963. }
  15964. interface Bone {
  15965. /**
  15966. * Copy an animation range from another bone
  15967. * @param source defines the source bone
  15968. * @param rangeName defines the range name to copy
  15969. * @param frameOffset defines the frame offset
  15970. * @param rescaleAsRequired defines if rescaling must be applied if required
  15971. * @param skelDimensionsRatio defines the scaling ratio
  15972. * @returns true if operation was successful
  15973. */
  15974. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15975. }
  15976. }
  15977. declare module BABYLON {
  15978. /**
  15979. * Class used to handle skinning animations
  15980. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15981. */
  15982. export class Skeleton implements IAnimatable {
  15983. /** defines the skeleton name */
  15984. name: string;
  15985. /** defines the skeleton Id */
  15986. id: string;
  15987. /**
  15988. * Defines the list of child bones
  15989. */
  15990. bones: Bone[];
  15991. /**
  15992. * Defines an estimate of the dimension of the skeleton at rest
  15993. */
  15994. dimensionsAtRest: Vector3;
  15995. /**
  15996. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15997. */
  15998. needInitialSkinMatrix: boolean;
  15999. /**
  16000. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16001. */
  16002. overrideMesh: Nullable<AbstractMesh>;
  16003. /**
  16004. * Gets the list of animations attached to this skeleton
  16005. */
  16006. animations: Array<Animation>;
  16007. private _scene;
  16008. private _isDirty;
  16009. private _transformMatrices;
  16010. private _transformMatrixTexture;
  16011. private _meshesWithPoseMatrix;
  16012. private _animatables;
  16013. private _identity;
  16014. private _synchronizedWithMesh;
  16015. private _ranges;
  16016. private _lastAbsoluteTransformsUpdateId;
  16017. private _canUseTextureForBones;
  16018. private _uniqueId;
  16019. /** @hidden */
  16020. _numBonesWithLinkedTransformNode: number;
  16021. /** @hidden */
  16022. _hasWaitingData: Nullable<boolean>;
  16023. /** @hidden */
  16024. _waitingOverrideMeshId: Nullable<string>;
  16025. /**
  16026. * Specifies if the skeleton should be serialized
  16027. */
  16028. doNotSerialize: boolean;
  16029. private _useTextureToStoreBoneMatrices;
  16030. /**
  16031. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16032. * Please note that this option is not available if the hardware does not support it
  16033. */
  16034. get useTextureToStoreBoneMatrices(): boolean;
  16035. set useTextureToStoreBoneMatrices(value: boolean);
  16036. private _animationPropertiesOverride;
  16037. /**
  16038. * Gets or sets the animation properties override
  16039. */
  16040. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16041. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16042. /**
  16043. * List of inspectable custom properties (used by the Inspector)
  16044. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16045. */
  16046. inspectableCustomProperties: IInspectable[];
  16047. /**
  16048. * An observable triggered before computing the skeleton's matrices
  16049. */
  16050. onBeforeComputeObservable: Observable<Skeleton>;
  16051. /**
  16052. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16053. */
  16054. get isUsingTextureForMatrices(): boolean;
  16055. /**
  16056. * Gets the unique ID of this skeleton
  16057. */
  16058. get uniqueId(): number;
  16059. /**
  16060. * Creates a new skeleton
  16061. * @param name defines the skeleton name
  16062. * @param id defines the skeleton Id
  16063. * @param scene defines the hosting scene
  16064. */
  16065. constructor(
  16066. /** defines the skeleton name */
  16067. name: string,
  16068. /** defines the skeleton Id */
  16069. id: string, scene: Scene);
  16070. /**
  16071. * Gets the current object class name.
  16072. * @return the class name
  16073. */
  16074. getClassName(): string;
  16075. /**
  16076. * Returns an array containing the root bones
  16077. * @returns an array containing the root bones
  16078. */
  16079. getChildren(): Array<Bone>;
  16080. /**
  16081. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16082. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16083. * @returns a Float32Array containing matrices data
  16084. */
  16085. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16086. /**
  16087. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16088. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16089. * @returns a raw texture containing the data
  16090. */
  16091. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16092. /**
  16093. * Gets the current hosting scene
  16094. * @returns a scene object
  16095. */
  16096. getScene(): Scene;
  16097. /**
  16098. * Gets a string representing the current skeleton data
  16099. * @param fullDetails defines a boolean indicating if we want a verbose version
  16100. * @returns a string representing the current skeleton data
  16101. */
  16102. toString(fullDetails?: boolean): string;
  16103. /**
  16104. * Get bone's index searching by name
  16105. * @param name defines bone's name to search for
  16106. * @return the indice of the bone. Returns -1 if not found
  16107. */
  16108. getBoneIndexByName(name: string): number;
  16109. /**
  16110. * Creater a new animation range
  16111. * @param name defines the name of the range
  16112. * @param from defines the start key
  16113. * @param to defines the end key
  16114. */
  16115. createAnimationRange(name: string, from: number, to: number): void;
  16116. /**
  16117. * Delete a specific animation range
  16118. * @param name defines the name of the range
  16119. * @param deleteFrames defines if frames must be removed as well
  16120. */
  16121. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16122. /**
  16123. * Gets a specific animation range
  16124. * @param name defines the name of the range to look for
  16125. * @returns the requested animation range or null if not found
  16126. */
  16127. getAnimationRange(name: string): Nullable<AnimationRange>;
  16128. /**
  16129. * Gets the list of all animation ranges defined on this skeleton
  16130. * @returns an array
  16131. */
  16132. getAnimationRanges(): Nullable<AnimationRange>[];
  16133. /**
  16134. * Copy animation range from a source skeleton.
  16135. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16136. * @param source defines the source skeleton
  16137. * @param name defines the name of the range to copy
  16138. * @param rescaleAsRequired defines if rescaling must be applied if required
  16139. * @returns true if operation was successful
  16140. */
  16141. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16142. /**
  16143. * Forces the skeleton to go to rest pose
  16144. */
  16145. returnToRest(): void;
  16146. private _getHighestAnimationFrame;
  16147. /**
  16148. * Begin a specific animation range
  16149. * @param name defines the name of the range to start
  16150. * @param loop defines if looping must be turned on (false by default)
  16151. * @param speedRatio defines the speed ratio to apply (1 by default)
  16152. * @param onAnimationEnd defines a callback which will be called when animation will end
  16153. * @returns a new animatable
  16154. */
  16155. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16156. /**
  16157. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16158. * @param skeleton defines the Skeleton containing the animation range to convert
  16159. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16160. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16161. * @returns the original skeleton
  16162. */
  16163. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16164. /** @hidden */
  16165. _markAsDirty(): void;
  16166. /** @hidden */
  16167. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16168. /** @hidden */
  16169. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16170. private _computeTransformMatrices;
  16171. /**
  16172. * Build all resources required to render a skeleton
  16173. */
  16174. prepare(): void;
  16175. /**
  16176. * Gets the list of animatables currently running for this skeleton
  16177. * @returns an array of animatables
  16178. */
  16179. getAnimatables(): IAnimatable[];
  16180. /**
  16181. * Clone the current skeleton
  16182. * @param name defines the name of the new skeleton
  16183. * @param id defines the id of the new skeleton
  16184. * @returns the new skeleton
  16185. */
  16186. clone(name: string, id?: string): Skeleton;
  16187. /**
  16188. * Enable animation blending for this skeleton
  16189. * @param blendingSpeed defines the blending speed to apply
  16190. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16191. */
  16192. enableBlending(blendingSpeed?: number): void;
  16193. /**
  16194. * Releases all resources associated with the current skeleton
  16195. */
  16196. dispose(): void;
  16197. /**
  16198. * Serialize the skeleton in a JSON object
  16199. * @returns a JSON object
  16200. */
  16201. serialize(): any;
  16202. /**
  16203. * Creates a new skeleton from serialized data
  16204. * @param parsedSkeleton defines the serialized data
  16205. * @param scene defines the hosting scene
  16206. * @returns a new skeleton
  16207. */
  16208. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16209. /**
  16210. * Compute all node absolute transforms
  16211. * @param forceUpdate defines if computation must be done even if cache is up to date
  16212. */
  16213. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16214. /**
  16215. * Gets the root pose matrix
  16216. * @returns a matrix
  16217. */
  16218. getPoseMatrix(): Nullable<Matrix>;
  16219. /**
  16220. * Sorts bones per internal index
  16221. */
  16222. sortBones(): void;
  16223. private _sortBones;
  16224. }
  16225. }
  16226. declare module BABYLON {
  16227. /**
  16228. * Creates an instance based on a source mesh.
  16229. */
  16230. export class InstancedMesh extends AbstractMesh {
  16231. private _sourceMesh;
  16232. private _currentLOD;
  16233. /** @hidden */
  16234. _indexInSourceMeshInstanceArray: number;
  16235. constructor(name: string, source: Mesh);
  16236. /**
  16237. * Returns the string "InstancedMesh".
  16238. */
  16239. getClassName(): string;
  16240. /** Gets the list of lights affecting that mesh */
  16241. get lightSources(): Light[];
  16242. _resyncLightSources(): void;
  16243. _resyncLightSource(light: Light): void;
  16244. _removeLightSource(light: Light, dispose: boolean): void;
  16245. /**
  16246. * If the source mesh receives shadows
  16247. */
  16248. get receiveShadows(): boolean;
  16249. /**
  16250. * The material of the source mesh
  16251. */
  16252. get material(): Nullable<Material>;
  16253. /**
  16254. * Visibility of the source mesh
  16255. */
  16256. get visibility(): number;
  16257. /**
  16258. * Skeleton of the source mesh
  16259. */
  16260. get skeleton(): Nullable<Skeleton>;
  16261. /**
  16262. * Rendering ground id of the source mesh
  16263. */
  16264. get renderingGroupId(): number;
  16265. set renderingGroupId(value: number);
  16266. /**
  16267. * Returns the total number of vertices (integer).
  16268. */
  16269. getTotalVertices(): number;
  16270. /**
  16271. * Returns a positive integer : the total number of indices in this mesh geometry.
  16272. * @returns the numner of indices or zero if the mesh has no geometry.
  16273. */
  16274. getTotalIndices(): number;
  16275. /**
  16276. * The source mesh of the instance
  16277. */
  16278. get sourceMesh(): Mesh;
  16279. /**
  16280. * Creates a new InstancedMesh object from the mesh model.
  16281. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16282. * @param name defines the name of the new instance
  16283. * @returns a new InstancedMesh
  16284. */
  16285. createInstance(name: string): InstancedMesh;
  16286. /**
  16287. * Is this node ready to be used/rendered
  16288. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16289. * @return {boolean} is it ready
  16290. */
  16291. isReady(completeCheck?: boolean): boolean;
  16292. /**
  16293. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16294. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16295. * @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.
  16296. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16297. */
  16298. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16299. /**
  16300. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16301. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16302. * The `data` are either a numeric array either a Float32Array.
  16303. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16304. * 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).
  16305. * Note that a new underlying VertexBuffer object is created each call.
  16306. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16307. *
  16308. * Possible `kind` values :
  16309. * - VertexBuffer.PositionKind
  16310. * - VertexBuffer.UVKind
  16311. * - VertexBuffer.UV2Kind
  16312. * - VertexBuffer.UV3Kind
  16313. * - VertexBuffer.UV4Kind
  16314. * - VertexBuffer.UV5Kind
  16315. * - VertexBuffer.UV6Kind
  16316. * - VertexBuffer.ColorKind
  16317. * - VertexBuffer.MatricesIndicesKind
  16318. * - VertexBuffer.MatricesIndicesExtraKind
  16319. * - VertexBuffer.MatricesWeightsKind
  16320. * - VertexBuffer.MatricesWeightsExtraKind
  16321. *
  16322. * Returns the Mesh.
  16323. */
  16324. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16325. /**
  16326. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16327. * If the mesh has no geometry, it is simply returned as it is.
  16328. * The `data` are either a numeric array either a Float32Array.
  16329. * No new underlying VertexBuffer object is created.
  16330. * 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.
  16331. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16332. *
  16333. * Possible `kind` values :
  16334. * - VertexBuffer.PositionKind
  16335. * - VertexBuffer.UVKind
  16336. * - VertexBuffer.UV2Kind
  16337. * - VertexBuffer.UV3Kind
  16338. * - VertexBuffer.UV4Kind
  16339. * - VertexBuffer.UV5Kind
  16340. * - VertexBuffer.UV6Kind
  16341. * - VertexBuffer.ColorKind
  16342. * - VertexBuffer.MatricesIndicesKind
  16343. * - VertexBuffer.MatricesIndicesExtraKind
  16344. * - VertexBuffer.MatricesWeightsKind
  16345. * - VertexBuffer.MatricesWeightsExtraKind
  16346. *
  16347. * Returns the Mesh.
  16348. */
  16349. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16350. /**
  16351. * Sets the mesh indices.
  16352. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16353. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16354. * This method creates a new index buffer each call.
  16355. * Returns the Mesh.
  16356. */
  16357. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16358. /**
  16359. * Boolean : True if the mesh owns the requested kind of data.
  16360. */
  16361. isVerticesDataPresent(kind: string): boolean;
  16362. /**
  16363. * Returns an array of indices (IndicesArray).
  16364. */
  16365. getIndices(): Nullable<IndicesArray>;
  16366. get _positions(): Nullable<Vector3[]>;
  16367. /**
  16368. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16369. * This means the mesh underlying bounding box and sphere are recomputed.
  16370. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16371. * @returns the current mesh
  16372. */
  16373. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16374. /** @hidden */
  16375. _preActivate(): InstancedMesh;
  16376. /** @hidden */
  16377. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16378. /** @hidden */
  16379. _postActivate(): void;
  16380. getWorldMatrix(): Matrix;
  16381. get isAnInstance(): boolean;
  16382. /**
  16383. * Returns the current associated LOD AbstractMesh.
  16384. */
  16385. getLOD(camera: Camera): AbstractMesh;
  16386. /** @hidden */
  16387. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16388. /** @hidden */
  16389. _syncSubMeshes(): InstancedMesh;
  16390. /** @hidden */
  16391. _generatePointsArray(): boolean;
  16392. /** @hidden */
  16393. _updateBoundingInfo(): AbstractMesh;
  16394. /**
  16395. * Creates a new InstancedMesh from the current mesh.
  16396. * - name (string) : the cloned mesh name
  16397. * - newParent (optional Node) : the optional Node to parent the clone to.
  16398. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16399. *
  16400. * Returns the clone.
  16401. */
  16402. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16403. /**
  16404. * Disposes the InstancedMesh.
  16405. * Returns nothing.
  16406. */
  16407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16408. }
  16409. interface Mesh {
  16410. /**
  16411. * Register a custom buffer that will be instanced
  16412. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16413. * @param kind defines the buffer kind
  16414. * @param stride defines the stride in floats
  16415. */
  16416. registerInstancedBuffer(kind: string, stride: number): void;
  16417. /**
  16418. * true to use the edge renderer for all instances of this mesh
  16419. */
  16420. edgesShareWithInstances: boolean;
  16421. /** @hidden */
  16422. _userInstancedBuffersStorage: {
  16423. data: {
  16424. [key: string]: Float32Array;
  16425. };
  16426. sizes: {
  16427. [key: string]: number;
  16428. };
  16429. vertexBuffers: {
  16430. [key: string]: Nullable<VertexBuffer>;
  16431. };
  16432. strides: {
  16433. [key: string]: number;
  16434. };
  16435. };
  16436. }
  16437. interface AbstractMesh {
  16438. /**
  16439. * Object used to store instanced buffers defined by user
  16440. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16441. */
  16442. instancedBuffers: {
  16443. [key: string]: any;
  16444. };
  16445. }
  16446. }
  16447. declare module BABYLON {
  16448. /**
  16449. * Defines the options associated with the creation of a shader material.
  16450. */
  16451. export interface IShaderMaterialOptions {
  16452. /**
  16453. * Does the material work in alpha blend mode
  16454. */
  16455. needAlphaBlending: boolean;
  16456. /**
  16457. * Does the material work in alpha test mode
  16458. */
  16459. needAlphaTesting: boolean;
  16460. /**
  16461. * The list of attribute names used in the shader
  16462. */
  16463. attributes: string[];
  16464. /**
  16465. * The list of unifrom names used in the shader
  16466. */
  16467. uniforms: string[];
  16468. /**
  16469. * The list of UBO names used in the shader
  16470. */
  16471. uniformBuffers: string[];
  16472. /**
  16473. * The list of sampler names used in the shader
  16474. */
  16475. samplers: string[];
  16476. /**
  16477. * The list of defines used in the shader
  16478. */
  16479. defines: string[];
  16480. }
  16481. /**
  16482. * 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.
  16483. *
  16484. * This returned material effects how the mesh will look based on the code in the shaders.
  16485. *
  16486. * @see https://doc.babylonjs.com/how_to/shader_material
  16487. */
  16488. export class ShaderMaterial extends Material {
  16489. private _shaderPath;
  16490. private _options;
  16491. private _textures;
  16492. private _textureArrays;
  16493. private _floats;
  16494. private _ints;
  16495. private _floatsArrays;
  16496. private _colors3;
  16497. private _colors3Arrays;
  16498. private _colors4;
  16499. private _colors4Arrays;
  16500. private _vectors2;
  16501. private _vectors3;
  16502. private _vectors4;
  16503. private _matrices;
  16504. private _matrixArrays;
  16505. private _matrices3x3;
  16506. private _matrices2x2;
  16507. private _vectors2Arrays;
  16508. private _vectors3Arrays;
  16509. private _vectors4Arrays;
  16510. private _cachedWorldViewMatrix;
  16511. private _cachedWorldViewProjectionMatrix;
  16512. private _renderId;
  16513. private _multiview;
  16514. private _cachedDefines;
  16515. /** Define the Url to load snippets */
  16516. static SnippetUrl: string;
  16517. /** Snippet ID if the material was created from the snippet server */
  16518. snippetId: string;
  16519. /**
  16520. * Instantiate a new shader material.
  16521. * 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.
  16522. * This returned material effects how the mesh will look based on the code in the shaders.
  16523. * @see https://doc.babylonjs.com/how_to/shader_material
  16524. * @param name Define the name of the material in the scene
  16525. * @param scene Define the scene the material belongs to
  16526. * @param shaderPath Defines the route to the shader code in one of three ways:
  16527. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16528. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16529. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16530. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16531. * @param options Define the options used to create the shader
  16532. */
  16533. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16534. /**
  16535. * Gets the shader path used to define the shader code
  16536. * It can be modified to trigger a new compilation
  16537. */
  16538. get shaderPath(): any;
  16539. /**
  16540. * Sets the shader path used to define the shader code
  16541. * It can be modified to trigger a new compilation
  16542. */
  16543. set shaderPath(shaderPath: any);
  16544. /**
  16545. * Gets the options used to compile the shader.
  16546. * They can be modified to trigger a new compilation
  16547. */
  16548. get options(): IShaderMaterialOptions;
  16549. /**
  16550. * Gets the current class name of the material e.g. "ShaderMaterial"
  16551. * Mainly use in serialization.
  16552. * @returns the class name
  16553. */
  16554. getClassName(): string;
  16555. /**
  16556. * Specifies if the material will require alpha blending
  16557. * @returns a boolean specifying if alpha blending is needed
  16558. */
  16559. needAlphaBlending(): boolean;
  16560. /**
  16561. * Specifies if this material should be rendered in alpha test mode
  16562. * @returns a boolean specifying if an alpha test is needed.
  16563. */
  16564. needAlphaTesting(): boolean;
  16565. private _checkUniform;
  16566. /**
  16567. * Set a texture in the shader.
  16568. * @param name Define the name of the uniform samplers as defined in the shader
  16569. * @param texture Define the texture to bind to this sampler
  16570. * @return the material itself allowing "fluent" like uniform updates
  16571. */
  16572. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16573. /**
  16574. * Set a texture array in the shader.
  16575. * @param name Define the name of the uniform sampler array as defined in the shader
  16576. * @param textures Define the list of textures to bind to this sampler
  16577. * @return the material itself allowing "fluent" like uniform updates
  16578. */
  16579. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16580. /**
  16581. * Set a float in the shader.
  16582. * @param name Define the name of the uniform as defined in the shader
  16583. * @param value Define the value to give to the uniform
  16584. * @return the material itself allowing "fluent" like uniform updates
  16585. */
  16586. setFloat(name: string, value: number): ShaderMaterial;
  16587. /**
  16588. * Set a int in the shader.
  16589. * @param name Define the name of the uniform as defined in the shader
  16590. * @param value Define the value to give to the uniform
  16591. * @return the material itself allowing "fluent" like uniform updates
  16592. */
  16593. setInt(name: string, value: number): ShaderMaterial;
  16594. /**
  16595. * Set an array of floats in the shader.
  16596. * @param name Define the name of the uniform as defined in the shader
  16597. * @param value Define the value to give to the uniform
  16598. * @return the material itself allowing "fluent" like uniform updates
  16599. */
  16600. setFloats(name: string, value: number[]): ShaderMaterial;
  16601. /**
  16602. * Set a vec3 in the shader from a Color3.
  16603. * @param name Define the name of the uniform as defined in the shader
  16604. * @param value Define the value to give to the uniform
  16605. * @return the material itself allowing "fluent" like uniform updates
  16606. */
  16607. setColor3(name: string, value: Color3): ShaderMaterial;
  16608. /**
  16609. * Set a vec3 array in the shader from a Color3 array.
  16610. * @param name Define the name of the uniform as defined in the shader
  16611. * @param value Define the value to give to the uniform
  16612. * @return the material itself allowing "fluent" like uniform updates
  16613. */
  16614. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16615. /**
  16616. * Set a vec4 in the shader from a Color4.
  16617. * @param name Define the name of the uniform as defined in the shader
  16618. * @param value Define the value to give to the uniform
  16619. * @return the material itself allowing "fluent" like uniform updates
  16620. */
  16621. setColor4(name: string, value: Color4): ShaderMaterial;
  16622. /**
  16623. * Set a vec4 array in the shader from a Color4 array.
  16624. * @param name Define the name of the uniform as defined in the shader
  16625. * @param value Define the value to give to the uniform
  16626. * @return the material itself allowing "fluent" like uniform updates
  16627. */
  16628. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16629. /**
  16630. * Set a vec2 in the shader from a Vector2.
  16631. * @param name Define the name of the uniform as defined in the shader
  16632. * @param value Define the value to give to the uniform
  16633. * @return the material itself allowing "fluent" like uniform updates
  16634. */
  16635. setVector2(name: string, value: Vector2): ShaderMaterial;
  16636. /**
  16637. * Set a vec3 in the shader from a Vector3.
  16638. * @param name Define the name of the uniform as defined in the shader
  16639. * @param value Define the value to give to the uniform
  16640. * @return the material itself allowing "fluent" like uniform updates
  16641. */
  16642. setVector3(name: string, value: Vector3): ShaderMaterial;
  16643. /**
  16644. * Set a vec4 in the shader from a Vector4.
  16645. * @param name Define the name of the uniform as defined in the shader
  16646. * @param value Define the value to give to the uniform
  16647. * @return the material itself allowing "fluent" like uniform updates
  16648. */
  16649. setVector4(name: string, value: Vector4): ShaderMaterial;
  16650. /**
  16651. * Set a mat4 in the shader from a Matrix.
  16652. * @param name Define the name of the uniform as defined in the shader
  16653. * @param value Define the value to give to the uniform
  16654. * @return the material itself allowing "fluent" like uniform updates
  16655. */
  16656. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16657. /**
  16658. * Set a float32Array in the shader from a matrix array.
  16659. * @param name Define the name of the uniform as defined in the shader
  16660. * @param value Define the value to give to the uniform
  16661. * @return the material itself allowing "fluent" like uniform updates
  16662. */
  16663. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16664. /**
  16665. * Set a mat3 in the shader from a Float32Array.
  16666. * @param name Define the name of the uniform as defined in the shader
  16667. * @param value Define the value to give to the uniform
  16668. * @return the material itself allowing "fluent" like uniform updates
  16669. */
  16670. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16671. /**
  16672. * Set a mat2 in the shader from a Float32Array.
  16673. * @param name Define the name of the uniform as defined in the shader
  16674. * @param value Define the value to give to the uniform
  16675. * @return the material itself allowing "fluent" like uniform updates
  16676. */
  16677. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16678. /**
  16679. * Set a vec2 array in the shader from a number array.
  16680. * @param name Define the name of the uniform as defined in the shader
  16681. * @param value Define the value to give to the uniform
  16682. * @return the material itself allowing "fluent" like uniform updates
  16683. */
  16684. setArray2(name: string, value: number[]): ShaderMaterial;
  16685. /**
  16686. * Set a vec3 array in the shader from a number array.
  16687. * @param name Define the name of the uniform as defined in the shader
  16688. * @param value Define the value to give to the uniform
  16689. * @return the material itself allowing "fluent" like uniform updates
  16690. */
  16691. setArray3(name: string, value: number[]): ShaderMaterial;
  16692. /**
  16693. * Set a vec4 array in the shader from a number array.
  16694. * @param name Define the name of the uniform as defined in the shader
  16695. * @param value Define the value to give to the uniform
  16696. * @return the material itself allowing "fluent" like uniform updates
  16697. */
  16698. setArray4(name: string, value: number[]): ShaderMaterial;
  16699. private _checkCache;
  16700. /**
  16701. * Specifies that the submesh is ready to be used
  16702. * @param mesh defines the mesh to check
  16703. * @param subMesh defines which submesh to check
  16704. * @param useInstances specifies that instances should be used
  16705. * @returns a boolean indicating that the submesh is ready or not
  16706. */
  16707. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16708. /**
  16709. * Checks if the material is ready to render the requested mesh
  16710. * @param mesh Define the mesh to render
  16711. * @param useInstances Define whether or not the material is used with instances
  16712. * @returns true if ready, otherwise false
  16713. */
  16714. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16715. /**
  16716. * Binds the world matrix to the material
  16717. * @param world defines the world transformation matrix
  16718. * @param effectOverride - If provided, use this effect instead of internal effect
  16719. */
  16720. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16721. /**
  16722. * Binds the submesh to this material by preparing the effect and shader to draw
  16723. * @param world defines the world transformation matrix
  16724. * @param mesh defines the mesh containing the submesh
  16725. * @param subMesh defines the submesh to bind the material to
  16726. */
  16727. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16728. /**
  16729. * Binds the material to the mesh
  16730. * @param world defines the world transformation matrix
  16731. * @param mesh defines the mesh to bind the material to
  16732. * @param effectOverride - If provided, use this effect instead of internal effect
  16733. */
  16734. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16735. protected _afterBind(mesh?: Mesh): void;
  16736. /**
  16737. * Gets the active textures from the material
  16738. * @returns an array of textures
  16739. */
  16740. getActiveTextures(): BaseTexture[];
  16741. /**
  16742. * Specifies if the material uses a texture
  16743. * @param texture defines the texture to check against the material
  16744. * @returns a boolean specifying if the material uses the texture
  16745. */
  16746. hasTexture(texture: BaseTexture): boolean;
  16747. /**
  16748. * Makes a duplicate of the material, and gives it a new name
  16749. * @param name defines the new name for the duplicated material
  16750. * @returns the cloned material
  16751. */
  16752. clone(name: string): ShaderMaterial;
  16753. /**
  16754. * Disposes the material
  16755. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16756. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16757. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16758. */
  16759. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16760. /**
  16761. * Serializes this material in a JSON representation
  16762. * @returns the serialized material object
  16763. */
  16764. serialize(): any;
  16765. /**
  16766. * Creates a shader material from parsed shader material data
  16767. * @param source defines the JSON represnetation of the material
  16768. * @param scene defines the hosting scene
  16769. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16770. * @returns a new material
  16771. */
  16772. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16773. /**
  16774. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16775. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16776. * @param url defines the url to load from
  16777. * @param scene defines the hosting scene
  16778. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16779. * @returns a promise that will resolve to the new ShaderMaterial
  16780. */
  16781. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16782. /**
  16783. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16784. * @param snippetId defines the snippet to load
  16785. * @param scene defines the hosting scene
  16786. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16787. * @returns a promise that will resolve to the new ShaderMaterial
  16788. */
  16789. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16790. }
  16791. }
  16792. declare module BABYLON {
  16793. /** @hidden */
  16794. export var colorPixelShader: {
  16795. name: string;
  16796. shader: string;
  16797. };
  16798. }
  16799. declare module BABYLON {
  16800. /** @hidden */
  16801. export var colorVertexShader: {
  16802. name: string;
  16803. shader: string;
  16804. };
  16805. }
  16806. declare module BABYLON {
  16807. /**
  16808. * Line mesh
  16809. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16810. */
  16811. export class LinesMesh extends Mesh {
  16812. /**
  16813. * If vertex color should be applied to the mesh
  16814. */
  16815. readonly useVertexColor?: boolean | undefined;
  16816. /**
  16817. * If vertex alpha should be applied to the mesh
  16818. */
  16819. readonly useVertexAlpha?: boolean | undefined;
  16820. /**
  16821. * Color of the line (Default: White)
  16822. */
  16823. color: Color3;
  16824. /**
  16825. * Alpha of the line (Default: 1)
  16826. */
  16827. alpha: number;
  16828. /**
  16829. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16830. * This margin is expressed in world space coordinates, so its value may vary.
  16831. * Default value is 0.1
  16832. */
  16833. intersectionThreshold: number;
  16834. private _colorShader;
  16835. private color4;
  16836. /**
  16837. * Creates a new LinesMesh
  16838. * @param name defines the name
  16839. * @param scene defines the hosting scene
  16840. * @param parent defines the parent mesh if any
  16841. * @param source defines the optional source LinesMesh used to clone data from
  16842. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16843. * When false, achieved by calling a clone(), also passing False.
  16844. * This will make creation of children, recursive.
  16845. * @param useVertexColor defines if this LinesMesh supports vertex color
  16846. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16847. */
  16848. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16849. /**
  16850. * If vertex color should be applied to the mesh
  16851. */
  16852. useVertexColor?: boolean | undefined,
  16853. /**
  16854. * If vertex alpha should be applied to the mesh
  16855. */
  16856. useVertexAlpha?: boolean | undefined);
  16857. private _addClipPlaneDefine;
  16858. private _removeClipPlaneDefine;
  16859. isReady(): boolean;
  16860. /**
  16861. * Returns the string "LineMesh"
  16862. */
  16863. getClassName(): string;
  16864. /**
  16865. * @hidden
  16866. */
  16867. get material(): Material;
  16868. /**
  16869. * @hidden
  16870. */
  16871. set material(value: Material);
  16872. /**
  16873. * @hidden
  16874. */
  16875. get checkCollisions(): boolean;
  16876. /** @hidden */
  16877. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16878. /** @hidden */
  16879. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16880. /**
  16881. * Disposes of the line mesh
  16882. * @param doNotRecurse If children should be disposed
  16883. */
  16884. dispose(doNotRecurse?: boolean): void;
  16885. /**
  16886. * Returns a new LineMesh object cloned from the current one.
  16887. */
  16888. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16889. /**
  16890. * Creates a new InstancedLinesMesh object from the mesh model.
  16891. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16892. * @param name defines the name of the new instance
  16893. * @returns a new InstancedLinesMesh
  16894. */
  16895. createInstance(name: string): InstancedLinesMesh;
  16896. }
  16897. /**
  16898. * Creates an instance based on a source LinesMesh
  16899. */
  16900. export class InstancedLinesMesh extends InstancedMesh {
  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. * Initilized with the intersectionThreshold value of the source LinesMesh
  16905. */
  16906. intersectionThreshold: number;
  16907. constructor(name: string, source: LinesMesh);
  16908. /**
  16909. * Returns the string "InstancedLinesMesh".
  16910. */
  16911. getClassName(): string;
  16912. }
  16913. }
  16914. declare module BABYLON {
  16915. /** @hidden */
  16916. export var linePixelShader: {
  16917. name: string;
  16918. shader: string;
  16919. };
  16920. }
  16921. declare module BABYLON {
  16922. /** @hidden */
  16923. export var lineVertexShader: {
  16924. name: string;
  16925. shader: string;
  16926. };
  16927. }
  16928. declare module BABYLON {
  16929. interface Scene {
  16930. /** @hidden */
  16931. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16932. }
  16933. interface AbstractMesh {
  16934. /**
  16935. * Gets the edgesRenderer associated with the mesh
  16936. */
  16937. edgesRenderer: Nullable<EdgesRenderer>;
  16938. }
  16939. interface LinesMesh {
  16940. /**
  16941. * Enables the edge rendering mode on the mesh.
  16942. * This mode makes the mesh edges visible
  16943. * @param epsilon defines the maximal distance between two angles to detect a face
  16944. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16945. * @returns the currentAbstractMesh
  16946. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16947. */
  16948. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16949. }
  16950. interface InstancedLinesMesh {
  16951. /**
  16952. * Enables the edge rendering mode on the mesh.
  16953. * This mode makes the mesh edges visible
  16954. * @param epsilon defines the maximal distance between two angles to detect a face
  16955. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16956. * @returns the current InstancedLinesMesh
  16957. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16958. */
  16959. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16960. }
  16961. /**
  16962. * Defines the minimum contract an Edges renderer should follow.
  16963. */
  16964. export interface IEdgesRenderer extends IDisposable {
  16965. /**
  16966. * Gets or sets a boolean indicating if the edgesRenderer is active
  16967. */
  16968. isEnabled: boolean;
  16969. /**
  16970. * Renders the edges of the attached mesh,
  16971. */
  16972. render(): void;
  16973. /**
  16974. * Checks wether or not the edges renderer is ready to render.
  16975. * @return true if ready, otherwise false.
  16976. */
  16977. isReady(): boolean;
  16978. /**
  16979. * List of instances to render in case the source mesh has instances
  16980. */
  16981. customInstances: SmartArray<Matrix>;
  16982. }
  16983. /**
  16984. * Defines the additional options of the edges renderer
  16985. */
  16986. export interface IEdgesRendererOptions {
  16987. /**
  16988. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16989. * If not defined, the default value is true
  16990. */
  16991. useAlternateEdgeFinder?: boolean;
  16992. /**
  16993. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16994. * If not defined, the default value is true.
  16995. * 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)
  16996. * This option is used only if useAlternateEdgeFinder = true
  16997. */
  16998. useFastVertexMerger?: boolean;
  16999. /**
  17000. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17001. * The default value is 1e-6
  17002. * This option is used only if useAlternateEdgeFinder = true
  17003. */
  17004. epsilonVertexMerge?: number;
  17005. /**
  17006. * 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
  17007. * 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.
  17008. * This option is used only if useAlternateEdgeFinder = true
  17009. */
  17010. applyTessellation?: boolean;
  17011. /**
  17012. * 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
  17013. * The default value is 1e-6
  17014. * This option is used only if useAlternateEdgeFinder = true
  17015. */
  17016. epsilonVertexAligned?: number;
  17017. }
  17018. /**
  17019. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17020. */
  17021. export class EdgesRenderer implements IEdgesRenderer {
  17022. /**
  17023. * Define the size of the edges with an orthographic camera
  17024. */
  17025. edgesWidthScalerForOrthographic: number;
  17026. /**
  17027. * Define the size of the edges with a perspective camera
  17028. */
  17029. edgesWidthScalerForPerspective: number;
  17030. protected _source: AbstractMesh;
  17031. protected _linesPositions: number[];
  17032. protected _linesNormals: number[];
  17033. protected _linesIndices: number[];
  17034. protected _epsilon: number;
  17035. protected _indicesCount: number;
  17036. protected _lineShader: ShaderMaterial;
  17037. protected _ib: DataBuffer;
  17038. protected _buffers: {
  17039. [key: string]: Nullable<VertexBuffer>;
  17040. };
  17041. protected _buffersForInstances: {
  17042. [key: string]: Nullable<VertexBuffer>;
  17043. };
  17044. protected _checkVerticesInsteadOfIndices: boolean;
  17045. protected _options: Nullable<IEdgesRendererOptions>;
  17046. private _meshRebuildObserver;
  17047. private _meshDisposeObserver;
  17048. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17049. isEnabled: boolean;
  17050. /**
  17051. * List of instances to render in case the source mesh has instances
  17052. */
  17053. customInstances: SmartArray<Matrix>;
  17054. private static GetShader;
  17055. /**
  17056. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17057. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17058. * @param source Mesh used to create edges
  17059. * @param epsilon sum of angles in adjacency to check for edge
  17060. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17061. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17062. * @param options The options to apply when generating the edges
  17063. */
  17064. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17065. protected _prepareRessources(): void;
  17066. /** @hidden */
  17067. _rebuild(): void;
  17068. /**
  17069. * Releases the required resources for the edges renderer
  17070. */
  17071. dispose(): void;
  17072. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17073. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17074. /**
  17075. * Checks if the pair of p0 and p1 is en edge
  17076. * @param faceIndex
  17077. * @param edge
  17078. * @param faceNormals
  17079. * @param p0
  17080. * @param p1
  17081. * @private
  17082. */
  17083. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17084. /**
  17085. * push line into the position, normal and index buffer
  17086. * @protected
  17087. */
  17088. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17089. /**
  17090. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17091. */
  17092. private _tessellateTriangle;
  17093. private _generateEdgesLinesAlternate;
  17094. /**
  17095. * Generates lines edges from adjacencjes
  17096. * @private
  17097. */
  17098. _generateEdgesLines(): void;
  17099. /**
  17100. * Checks wether or not the edges renderer is ready to render.
  17101. * @return true if ready, otherwise false.
  17102. */
  17103. isReady(): boolean;
  17104. /**
  17105. * Renders the edges of the attached mesh,
  17106. */
  17107. render(): void;
  17108. }
  17109. /**
  17110. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17111. */
  17112. export class LineEdgesRenderer extends EdgesRenderer {
  17113. /**
  17114. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17115. * @param source LineMesh used to generate edges
  17116. * @param epsilon not important (specified angle for edge detection)
  17117. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17118. */
  17119. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17120. /**
  17121. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17122. */
  17123. _generateEdgesLines(): void;
  17124. }
  17125. }
  17126. declare module BABYLON {
  17127. /**
  17128. * This represents the object necessary to create a rendering group.
  17129. * This is exclusively used and created by the rendering manager.
  17130. * To modify the behavior, you use the available helpers in your scene or meshes.
  17131. * @hidden
  17132. */
  17133. export class RenderingGroup {
  17134. index: number;
  17135. private static _zeroVector;
  17136. private _scene;
  17137. private _opaqueSubMeshes;
  17138. private _transparentSubMeshes;
  17139. private _alphaTestSubMeshes;
  17140. private _depthOnlySubMeshes;
  17141. private _particleSystems;
  17142. private _spriteManagers;
  17143. private _opaqueSortCompareFn;
  17144. private _alphaTestSortCompareFn;
  17145. private _transparentSortCompareFn;
  17146. private _renderOpaque;
  17147. private _renderAlphaTest;
  17148. private _renderTransparent;
  17149. /** @hidden */
  17150. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17151. onBeforeTransparentRendering: () => void;
  17152. /**
  17153. * Set the opaque sort comparison function.
  17154. * If null the sub meshes will be render in the order they were created
  17155. */
  17156. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17157. /**
  17158. * Set the alpha test sort comparison function.
  17159. * If null the sub meshes will be render in the order they were created
  17160. */
  17161. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17162. /**
  17163. * Set the transparent sort comparison function.
  17164. * If null the sub meshes will be render in the order they were created
  17165. */
  17166. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17167. /**
  17168. * Creates a new rendering group.
  17169. * @param index The rendering group index
  17170. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17171. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17172. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17173. */
  17174. 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>);
  17175. /**
  17176. * Render all the sub meshes contained in the group.
  17177. * @param customRenderFunction Used to override the default render behaviour of the group.
  17178. * @returns true if rendered some submeshes.
  17179. */
  17180. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17181. /**
  17182. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17183. * @param subMeshes The submeshes to render
  17184. */
  17185. private renderOpaqueSorted;
  17186. /**
  17187. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17188. * @param subMeshes The submeshes to render
  17189. */
  17190. private renderAlphaTestSorted;
  17191. /**
  17192. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17193. * @param subMeshes The submeshes to render
  17194. */
  17195. private renderTransparentSorted;
  17196. /**
  17197. * Renders the submeshes in a specified order.
  17198. * @param subMeshes The submeshes to sort before render
  17199. * @param sortCompareFn The comparison function use to sort
  17200. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17201. * @param transparent Specifies to activate blending if true
  17202. */
  17203. private static renderSorted;
  17204. /**
  17205. * Renders the submeshes in the order they were dispatched (no sort applied).
  17206. * @param subMeshes The submeshes to render
  17207. */
  17208. private static renderUnsorted;
  17209. /**
  17210. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17211. * are rendered back to front if in the same alpha index.
  17212. *
  17213. * @param a The first submesh
  17214. * @param b The second submesh
  17215. * @returns The result of the comparison
  17216. */
  17217. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17218. /**
  17219. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17220. * are rendered back to front.
  17221. *
  17222. * @param a The first submesh
  17223. * @param b The second submesh
  17224. * @returns The result of the comparison
  17225. */
  17226. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17227. /**
  17228. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17229. * are rendered front to back (prevent overdraw).
  17230. *
  17231. * @param a The first submesh
  17232. * @param b The second submesh
  17233. * @returns The result of the comparison
  17234. */
  17235. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17236. /**
  17237. * Resets the different lists of submeshes to prepare a new frame.
  17238. */
  17239. prepare(): void;
  17240. dispose(): void;
  17241. /**
  17242. * Inserts the submesh in its correct queue depending on its material.
  17243. * @param subMesh The submesh to dispatch
  17244. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17245. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17246. */
  17247. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17248. dispatchSprites(spriteManager: ISpriteManager): void;
  17249. dispatchParticles(particleSystem: IParticleSystem): void;
  17250. private _renderParticles;
  17251. private _renderSprites;
  17252. }
  17253. }
  17254. declare module BABYLON {
  17255. /**
  17256. * Interface describing the different options available in the rendering manager
  17257. * regarding Auto Clear between groups.
  17258. */
  17259. export interface IRenderingManagerAutoClearSetup {
  17260. /**
  17261. * Defines whether or not autoclear is enable.
  17262. */
  17263. autoClear: boolean;
  17264. /**
  17265. * Defines whether or not to autoclear the depth buffer.
  17266. */
  17267. depth: boolean;
  17268. /**
  17269. * Defines whether or not to autoclear the stencil buffer.
  17270. */
  17271. stencil: boolean;
  17272. }
  17273. /**
  17274. * This class is used by the onRenderingGroupObservable
  17275. */
  17276. export class RenderingGroupInfo {
  17277. /**
  17278. * The Scene that being rendered
  17279. */
  17280. scene: Scene;
  17281. /**
  17282. * The camera currently used for the rendering pass
  17283. */
  17284. camera: Nullable<Camera>;
  17285. /**
  17286. * The ID of the renderingGroup being processed
  17287. */
  17288. renderingGroupId: number;
  17289. }
  17290. /**
  17291. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17292. * It is enable to manage the different groups as well as the different necessary sort functions.
  17293. * This should not be used directly aside of the few static configurations
  17294. */
  17295. export class RenderingManager {
  17296. /**
  17297. * The max id used for rendering groups (not included)
  17298. */
  17299. static MAX_RENDERINGGROUPS: number;
  17300. /**
  17301. * The min id used for rendering groups (included)
  17302. */
  17303. static MIN_RENDERINGGROUPS: number;
  17304. /**
  17305. * Used to globally prevent autoclearing scenes.
  17306. */
  17307. static AUTOCLEAR: boolean;
  17308. /**
  17309. * @hidden
  17310. */
  17311. _useSceneAutoClearSetup: boolean;
  17312. private _scene;
  17313. private _renderingGroups;
  17314. private _depthStencilBufferAlreadyCleaned;
  17315. private _autoClearDepthStencil;
  17316. private _customOpaqueSortCompareFn;
  17317. private _customAlphaTestSortCompareFn;
  17318. private _customTransparentSortCompareFn;
  17319. private _renderingGroupInfo;
  17320. /**
  17321. * Instantiates a new rendering group for a particular scene
  17322. * @param scene Defines the scene the groups belongs to
  17323. */
  17324. constructor(scene: Scene);
  17325. private _clearDepthStencilBuffer;
  17326. /**
  17327. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17328. * @hidden
  17329. */
  17330. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17331. /**
  17332. * Resets the different information of the group to prepare a new frame
  17333. * @hidden
  17334. */
  17335. reset(): void;
  17336. /**
  17337. * Dispose and release the group and its associated resources.
  17338. * @hidden
  17339. */
  17340. dispose(): void;
  17341. /**
  17342. * Clear the info related to rendering groups preventing retention points during dispose.
  17343. */
  17344. freeRenderingGroups(): void;
  17345. private _prepareRenderingGroup;
  17346. /**
  17347. * Add a sprite manager to the rendering manager in order to render it this frame.
  17348. * @param spriteManager Define the sprite manager to render
  17349. */
  17350. dispatchSprites(spriteManager: ISpriteManager): void;
  17351. /**
  17352. * Add a particle system to the rendering manager in order to render it this frame.
  17353. * @param particleSystem Define the particle system to render
  17354. */
  17355. dispatchParticles(particleSystem: IParticleSystem): void;
  17356. /**
  17357. * Add a submesh to the manager in order to render it this frame
  17358. * @param subMesh The submesh to dispatch
  17359. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17360. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17361. */
  17362. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17363. /**
  17364. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17365. * This allowed control for front to back rendering or reversly depending of the special needs.
  17366. *
  17367. * @param renderingGroupId The rendering group id corresponding to its index
  17368. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17369. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17370. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17371. */
  17372. 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;
  17373. /**
  17374. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17375. *
  17376. * @param renderingGroupId The rendering group id corresponding to its index
  17377. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17378. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17379. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17380. */
  17381. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17382. /**
  17383. * Gets the current auto clear configuration for one rendering group of the rendering
  17384. * manager.
  17385. * @param index the rendering group index to get the information for
  17386. * @returns The auto clear setup for the requested rendering group
  17387. */
  17388. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17389. }
  17390. }
  17391. declare module BABYLON {
  17392. /**
  17393. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17394. */
  17395. export interface ICustomShaderOptions {
  17396. /**
  17397. * Gets or sets the custom shader name to use
  17398. */
  17399. shaderName: string;
  17400. /**
  17401. * The list of attribute names used in the shader
  17402. */
  17403. attributes?: string[];
  17404. /**
  17405. * The list of unifrom names used in the shader
  17406. */
  17407. uniforms?: string[];
  17408. /**
  17409. * The list of sampler names used in the shader
  17410. */
  17411. samplers?: string[];
  17412. /**
  17413. * The list of defines used in the shader
  17414. */
  17415. defines?: string[];
  17416. }
  17417. /**
  17418. * Interface to implement to create a shadow generator compatible with BJS.
  17419. */
  17420. export interface IShadowGenerator {
  17421. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17422. id: string;
  17423. /**
  17424. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17425. * @returns The render target texture if present otherwise, null
  17426. */
  17427. getShadowMap(): Nullable<RenderTargetTexture>;
  17428. /**
  17429. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17430. * @param subMesh The submesh we want to render in the shadow map
  17431. * @param useInstances Defines wether will draw in the map using instances
  17432. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17433. * @returns true if ready otherwise, false
  17434. */
  17435. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17436. /**
  17437. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17438. * @param defines Defines of the material we want to update
  17439. * @param lightIndex Index of the light in the enabled light list of the material
  17440. */
  17441. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17442. /**
  17443. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17444. * defined in the generator but impacting the effect).
  17445. * It implies the unifroms available on the materials are the standard BJS ones.
  17446. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17447. * @param effect The effect we are binfing the information for
  17448. */
  17449. bindShadowLight(lightIndex: string, effect: Effect): void;
  17450. /**
  17451. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17452. * (eq to shadow prjection matrix * light transform matrix)
  17453. * @returns The transform matrix used to create the shadow map
  17454. */
  17455. getTransformMatrix(): Matrix;
  17456. /**
  17457. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17458. * Cube and 2D textures for instance.
  17459. */
  17460. recreateShadowMap(): void;
  17461. /**
  17462. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17463. * @param onCompiled Callback triggered at the and of the effects compilation
  17464. * @param options Sets of optional options forcing the compilation with different modes
  17465. */
  17466. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17467. useInstances: boolean;
  17468. }>): void;
  17469. /**
  17470. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17471. * @param options Sets of optional options forcing the compilation with different modes
  17472. * @returns A promise that resolves when the compilation completes
  17473. */
  17474. forceCompilationAsync(options?: Partial<{
  17475. useInstances: boolean;
  17476. }>): Promise<void>;
  17477. /**
  17478. * Serializes the shadow generator setup to a json object.
  17479. * @returns The serialized JSON object
  17480. */
  17481. serialize(): any;
  17482. /**
  17483. * Disposes the Shadow map and related Textures and effects.
  17484. */
  17485. dispose(): void;
  17486. }
  17487. /**
  17488. * Default implementation IShadowGenerator.
  17489. * This is the main object responsible of generating shadows in the framework.
  17490. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17491. */
  17492. export class ShadowGenerator implements IShadowGenerator {
  17493. /**
  17494. * Name of the shadow generator class
  17495. */
  17496. static CLASSNAME: string;
  17497. /**
  17498. * Shadow generator mode None: no filtering applied.
  17499. */
  17500. static readonly FILTER_NONE: number;
  17501. /**
  17502. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17503. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17504. */
  17505. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17506. /**
  17507. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17508. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17509. */
  17510. static readonly FILTER_POISSONSAMPLING: number;
  17511. /**
  17512. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17513. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17514. */
  17515. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17516. /**
  17517. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17518. * edge artifacts on steep falloff.
  17519. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17520. */
  17521. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17522. /**
  17523. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17524. * edge artifacts on steep falloff.
  17525. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17526. */
  17527. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17528. /**
  17529. * Shadow generator mode PCF: Percentage Closer Filtering
  17530. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17531. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17532. */
  17533. static readonly FILTER_PCF: number;
  17534. /**
  17535. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17536. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17537. * Contact Hardening
  17538. */
  17539. static readonly FILTER_PCSS: number;
  17540. /**
  17541. * Reserved for PCF and PCSS
  17542. * Highest Quality.
  17543. *
  17544. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17545. *
  17546. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17547. */
  17548. static readonly QUALITY_HIGH: number;
  17549. /**
  17550. * Reserved for PCF and PCSS
  17551. * Good tradeoff for quality/perf cross devices
  17552. *
  17553. * Execute PCF on a 3*3 kernel.
  17554. *
  17555. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17556. */
  17557. static readonly QUALITY_MEDIUM: number;
  17558. /**
  17559. * Reserved for PCF and PCSS
  17560. * The lowest quality but the fastest.
  17561. *
  17562. * Execute PCF on a 1*1 kernel.
  17563. *
  17564. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17565. */
  17566. static readonly QUALITY_LOW: number;
  17567. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17568. id: string;
  17569. /** Gets or sets the custom shader name to use */
  17570. customShaderOptions: ICustomShaderOptions;
  17571. /**
  17572. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17573. */
  17574. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17575. /**
  17576. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17577. */
  17578. onAfterShadowMapRenderObservable: Observable<Effect>;
  17579. /**
  17580. * Observable triggered before a mesh is rendered in the shadow map.
  17581. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17582. */
  17583. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17584. /**
  17585. * Observable triggered after a mesh is rendered in the shadow map.
  17586. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17587. */
  17588. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17589. protected _bias: number;
  17590. /**
  17591. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17592. */
  17593. get bias(): number;
  17594. /**
  17595. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17596. */
  17597. set bias(bias: number);
  17598. protected _normalBias: number;
  17599. /**
  17600. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17601. */
  17602. get normalBias(): number;
  17603. /**
  17604. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17605. */
  17606. set normalBias(normalBias: number);
  17607. protected _blurBoxOffset: number;
  17608. /**
  17609. * Gets the blur box offset: offset applied during the blur pass.
  17610. * Only useful if useKernelBlur = false
  17611. */
  17612. get blurBoxOffset(): number;
  17613. /**
  17614. * Sets the blur box offset: offset applied during the blur pass.
  17615. * Only useful if useKernelBlur = false
  17616. */
  17617. set blurBoxOffset(value: number);
  17618. protected _blurScale: number;
  17619. /**
  17620. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17621. * 2 means half of the size.
  17622. */
  17623. get blurScale(): number;
  17624. /**
  17625. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17626. * 2 means half of the size.
  17627. */
  17628. set blurScale(value: number);
  17629. protected _blurKernel: number;
  17630. /**
  17631. * Gets the blur kernel: kernel size of the blur pass.
  17632. * Only useful if useKernelBlur = true
  17633. */
  17634. get blurKernel(): number;
  17635. /**
  17636. * Sets the blur kernel: kernel size of the blur pass.
  17637. * Only useful if useKernelBlur = true
  17638. */
  17639. set blurKernel(value: number);
  17640. protected _useKernelBlur: boolean;
  17641. /**
  17642. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17643. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17644. */
  17645. get useKernelBlur(): boolean;
  17646. /**
  17647. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17648. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17649. */
  17650. set useKernelBlur(value: boolean);
  17651. protected _depthScale: number;
  17652. /**
  17653. * Gets the depth scale used in ESM mode.
  17654. */
  17655. get depthScale(): number;
  17656. /**
  17657. * Sets the depth scale used in ESM mode.
  17658. * This can override the scale stored on the light.
  17659. */
  17660. set depthScale(value: number);
  17661. protected _validateFilter(filter: number): number;
  17662. protected _filter: number;
  17663. /**
  17664. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17665. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17666. */
  17667. get filter(): number;
  17668. /**
  17669. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17670. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17671. */
  17672. set filter(value: number);
  17673. /**
  17674. * Gets if the current filter is set to Poisson Sampling.
  17675. */
  17676. get usePoissonSampling(): boolean;
  17677. /**
  17678. * Sets the current filter to Poisson Sampling.
  17679. */
  17680. set usePoissonSampling(value: boolean);
  17681. /**
  17682. * Gets if the current filter is set to ESM.
  17683. */
  17684. get useExponentialShadowMap(): boolean;
  17685. /**
  17686. * Sets the current filter is to ESM.
  17687. */
  17688. set useExponentialShadowMap(value: boolean);
  17689. /**
  17690. * Gets if the current filter is set to filtered ESM.
  17691. */
  17692. get useBlurExponentialShadowMap(): boolean;
  17693. /**
  17694. * Gets if the current filter is set to filtered ESM.
  17695. */
  17696. set useBlurExponentialShadowMap(value: boolean);
  17697. /**
  17698. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17699. * exponential to prevent steep falloff artifacts).
  17700. */
  17701. get useCloseExponentialShadowMap(): boolean;
  17702. /**
  17703. * Sets the current filter to "close ESM" (using the inverse of the
  17704. * exponential to prevent steep falloff artifacts).
  17705. */
  17706. set useCloseExponentialShadowMap(value: boolean);
  17707. /**
  17708. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17709. * exponential to prevent steep falloff artifacts).
  17710. */
  17711. get useBlurCloseExponentialShadowMap(): boolean;
  17712. /**
  17713. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17714. * exponential to prevent steep falloff artifacts).
  17715. */
  17716. set useBlurCloseExponentialShadowMap(value: boolean);
  17717. /**
  17718. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17719. */
  17720. get usePercentageCloserFiltering(): boolean;
  17721. /**
  17722. * Sets the current filter to "PCF" (percentage closer filtering).
  17723. */
  17724. set usePercentageCloserFiltering(value: boolean);
  17725. protected _filteringQuality: number;
  17726. /**
  17727. * Gets the PCF or PCSS Quality.
  17728. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17729. */
  17730. get filteringQuality(): number;
  17731. /**
  17732. * Sets the PCF or PCSS Quality.
  17733. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17734. */
  17735. set filteringQuality(filteringQuality: number);
  17736. /**
  17737. * Gets if the current filter is set to "PCSS" (contact hardening).
  17738. */
  17739. get useContactHardeningShadow(): boolean;
  17740. /**
  17741. * Sets the current filter to "PCSS" (contact hardening).
  17742. */
  17743. set useContactHardeningShadow(value: boolean);
  17744. protected _contactHardeningLightSizeUVRatio: number;
  17745. /**
  17746. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17747. * Using a ratio helps keeping shape stability independently of the map size.
  17748. *
  17749. * It does not account for the light projection as it was having too much
  17750. * instability during the light setup or during light position changes.
  17751. *
  17752. * Only valid if useContactHardeningShadow is true.
  17753. */
  17754. get contactHardeningLightSizeUVRatio(): number;
  17755. /**
  17756. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17757. * Using a ratio helps keeping shape stability independently of the map size.
  17758. *
  17759. * It does not account for the light projection as it was having too much
  17760. * instability during the light setup or during light position changes.
  17761. *
  17762. * Only valid if useContactHardeningShadow is true.
  17763. */
  17764. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17765. protected _darkness: number;
  17766. /** Gets or sets the actual darkness of a shadow */
  17767. get darkness(): number;
  17768. set darkness(value: number);
  17769. /**
  17770. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17771. * 0 means strongest and 1 would means no shadow.
  17772. * @returns the darkness.
  17773. */
  17774. getDarkness(): number;
  17775. /**
  17776. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17777. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17778. * @returns the shadow generator allowing fluent coding.
  17779. */
  17780. setDarkness(darkness: number): ShadowGenerator;
  17781. protected _transparencyShadow: boolean;
  17782. /** Gets or sets the ability to have transparent shadow */
  17783. get transparencyShadow(): boolean;
  17784. set transparencyShadow(value: boolean);
  17785. /**
  17786. * Sets the ability to have transparent shadow (boolean).
  17787. * @param transparent True if transparent else False
  17788. * @returns the shadow generator allowing fluent coding
  17789. */
  17790. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17791. /**
  17792. * Enables or disables shadows with varying strength based on the transparency
  17793. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17794. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17795. * mesh.visibility * alphaTexture.a
  17796. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17797. */
  17798. enableSoftTransparentShadow: boolean;
  17799. protected _shadowMap: Nullable<RenderTargetTexture>;
  17800. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17801. /**
  17802. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17803. * @returns The render target texture if present otherwise, null
  17804. */
  17805. getShadowMap(): Nullable<RenderTargetTexture>;
  17806. /**
  17807. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17808. * @returns The render target texture if the shadow map is present otherwise, null
  17809. */
  17810. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17811. /**
  17812. * Gets the class name of that object
  17813. * @returns "ShadowGenerator"
  17814. */
  17815. getClassName(): string;
  17816. /**
  17817. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17818. * @param mesh Mesh to add
  17819. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17820. * @returns the Shadow Generator itself
  17821. */
  17822. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17823. /**
  17824. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17825. * @param mesh Mesh to remove
  17826. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17827. * @returns the Shadow Generator itself
  17828. */
  17829. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17830. /**
  17831. * Controls the extent to which the shadows fade out at the edge of the frustum
  17832. */
  17833. frustumEdgeFalloff: number;
  17834. protected _light: IShadowLight;
  17835. /**
  17836. * Returns the associated light object.
  17837. * @returns the light generating the shadow
  17838. */
  17839. getLight(): IShadowLight;
  17840. /**
  17841. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17842. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17843. * It might on the other hand introduce peter panning.
  17844. */
  17845. forceBackFacesOnly: boolean;
  17846. protected _scene: Scene;
  17847. protected _lightDirection: Vector3;
  17848. protected _effect: Effect;
  17849. protected _viewMatrix: Matrix;
  17850. protected _projectionMatrix: Matrix;
  17851. protected _transformMatrix: Matrix;
  17852. protected _cachedPosition: Vector3;
  17853. protected _cachedDirection: Vector3;
  17854. protected _cachedDefines: string;
  17855. protected _currentRenderID: number;
  17856. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17857. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17858. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17859. protected _blurPostProcesses: PostProcess[];
  17860. protected _mapSize: number;
  17861. protected _currentFaceIndex: number;
  17862. protected _currentFaceIndexCache: number;
  17863. protected _textureType: number;
  17864. protected _defaultTextureMatrix: Matrix;
  17865. protected _storedUniqueId: Nullable<number>;
  17866. /** @hidden */
  17867. static _SceneComponentInitialization: (scene: Scene) => void;
  17868. /**
  17869. * Creates a ShadowGenerator object.
  17870. * A ShadowGenerator is the required tool to use the shadows.
  17871. * Each light casting shadows needs to use its own ShadowGenerator.
  17872. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17873. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17874. * @param light The light object generating the shadows.
  17875. * @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.
  17876. */
  17877. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17878. protected _initializeGenerator(): void;
  17879. protected _createTargetRenderTexture(): void;
  17880. protected _initializeShadowMap(): void;
  17881. protected _initializeBlurRTTAndPostProcesses(): void;
  17882. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17883. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17884. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17885. protected _applyFilterValues(): void;
  17886. /**
  17887. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17888. * @param onCompiled Callback triggered at the and of the effects compilation
  17889. * @param options Sets of optional options forcing the compilation with different modes
  17890. */
  17891. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17892. useInstances: boolean;
  17893. }>): void;
  17894. /**
  17895. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17896. * @param options Sets of optional options forcing the compilation with different modes
  17897. * @returns A promise that resolves when the compilation completes
  17898. */
  17899. forceCompilationAsync(options?: Partial<{
  17900. useInstances: boolean;
  17901. }>): Promise<void>;
  17902. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17903. private _prepareShadowDefines;
  17904. /**
  17905. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17906. * @param subMesh The submesh we want to render in the shadow map
  17907. * @param useInstances Defines wether will draw in the map using instances
  17908. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17909. * @returns true if ready otherwise, false
  17910. */
  17911. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17912. /**
  17913. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17914. * @param defines Defines of the material we want to update
  17915. * @param lightIndex Index of the light in the enabled light list of the material
  17916. */
  17917. prepareDefines(defines: any, lightIndex: number): void;
  17918. /**
  17919. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17920. * defined in the generator but impacting the effect).
  17921. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17922. * @param effect The effect we are binfing the information for
  17923. */
  17924. bindShadowLight(lightIndex: string, effect: Effect): void;
  17925. /**
  17926. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17927. * (eq to shadow prjection matrix * light transform matrix)
  17928. * @returns The transform matrix used to create the shadow map
  17929. */
  17930. getTransformMatrix(): Matrix;
  17931. /**
  17932. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17933. * Cube and 2D textures for instance.
  17934. */
  17935. recreateShadowMap(): void;
  17936. protected _disposeBlurPostProcesses(): void;
  17937. protected _disposeRTTandPostProcesses(): void;
  17938. /**
  17939. * Disposes the ShadowGenerator.
  17940. * Returns nothing.
  17941. */
  17942. dispose(): void;
  17943. /**
  17944. * Serializes the shadow generator setup to a json object.
  17945. * @returns The serialized JSON object
  17946. */
  17947. serialize(): any;
  17948. /**
  17949. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17950. * @param parsedShadowGenerator The JSON object to parse
  17951. * @param scene The scene to create the shadow map for
  17952. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17953. * @returns The parsed shadow generator
  17954. */
  17955. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17956. }
  17957. }
  17958. declare module BABYLON {
  17959. /**
  17960. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17961. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17962. * 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.
  17963. */
  17964. export abstract class Light extends Node {
  17965. /**
  17966. * Falloff Default: light is falling off following the material specification:
  17967. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17968. */
  17969. static readonly FALLOFF_DEFAULT: number;
  17970. /**
  17971. * Falloff Physical: light is falling off following the inverse squared distance law.
  17972. */
  17973. static readonly FALLOFF_PHYSICAL: number;
  17974. /**
  17975. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17976. * to enhance interoperability with other engines.
  17977. */
  17978. static readonly FALLOFF_GLTF: number;
  17979. /**
  17980. * Falloff Standard: light is falling off like in the standard material
  17981. * to enhance interoperability with other materials.
  17982. */
  17983. static readonly FALLOFF_STANDARD: number;
  17984. /**
  17985. * If every light affecting the material is in this lightmapMode,
  17986. * material.lightmapTexture adds or multiplies
  17987. * (depends on material.useLightmapAsShadowmap)
  17988. * after every other light calculations.
  17989. */
  17990. static readonly LIGHTMAP_DEFAULT: number;
  17991. /**
  17992. * material.lightmapTexture as only diffuse lighting from this light
  17993. * adds only specular lighting from this light
  17994. * adds dynamic shadows
  17995. */
  17996. static readonly LIGHTMAP_SPECULAR: number;
  17997. /**
  17998. * material.lightmapTexture as only lighting
  17999. * no light calculation from this light
  18000. * only adds dynamic shadows from this light
  18001. */
  18002. static readonly LIGHTMAP_SHADOWSONLY: number;
  18003. /**
  18004. * Each light type uses the default quantity according to its type:
  18005. * point/spot lights use luminous intensity
  18006. * directional lights use illuminance
  18007. */
  18008. static readonly INTENSITYMODE_AUTOMATIC: number;
  18009. /**
  18010. * lumen (lm)
  18011. */
  18012. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18013. /**
  18014. * candela (lm/sr)
  18015. */
  18016. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18017. /**
  18018. * lux (lm/m^2)
  18019. */
  18020. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18021. /**
  18022. * nit (cd/m^2)
  18023. */
  18024. static readonly INTENSITYMODE_LUMINANCE: number;
  18025. /**
  18026. * Light type const id of the point light.
  18027. */
  18028. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18029. /**
  18030. * Light type const id of the directional light.
  18031. */
  18032. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18033. /**
  18034. * Light type const id of the spot light.
  18035. */
  18036. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18037. /**
  18038. * Light type const id of the hemispheric light.
  18039. */
  18040. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18041. /**
  18042. * Diffuse gives the basic color to an object.
  18043. */
  18044. diffuse: Color3;
  18045. /**
  18046. * Specular produces a highlight color on an object.
  18047. * Note: This is note affecting PBR materials.
  18048. */
  18049. specular: Color3;
  18050. /**
  18051. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18052. * falling off base on range or angle.
  18053. * This can be set to any values in Light.FALLOFF_x.
  18054. *
  18055. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18056. * other types of materials.
  18057. */
  18058. falloffType: number;
  18059. /**
  18060. * Strength of the light.
  18061. * Note: By default it is define in the framework own unit.
  18062. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18063. */
  18064. intensity: number;
  18065. private _range;
  18066. protected _inverseSquaredRange: number;
  18067. /**
  18068. * Defines how far from the source the light is impacting in scene units.
  18069. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18070. */
  18071. get range(): number;
  18072. /**
  18073. * Defines how far from the source the light is impacting in scene units.
  18074. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18075. */
  18076. set range(value: number);
  18077. /**
  18078. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18079. * of light.
  18080. */
  18081. private _photometricScale;
  18082. private _intensityMode;
  18083. /**
  18084. * Gets the photometric scale used to interpret the intensity.
  18085. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18086. */
  18087. get intensityMode(): number;
  18088. /**
  18089. * Sets the photometric scale used to interpret the intensity.
  18090. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18091. */
  18092. set intensityMode(value: number);
  18093. private _radius;
  18094. /**
  18095. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18096. */
  18097. get radius(): number;
  18098. /**
  18099. * sets the light radius used by PBR Materials to simulate soft area lights.
  18100. */
  18101. set radius(value: number);
  18102. private _renderPriority;
  18103. /**
  18104. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18105. * exceeding the number allowed of the materials.
  18106. */
  18107. renderPriority: number;
  18108. private _shadowEnabled;
  18109. /**
  18110. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18111. * the current shadow generator.
  18112. */
  18113. get shadowEnabled(): boolean;
  18114. /**
  18115. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18116. * the current shadow generator.
  18117. */
  18118. set shadowEnabled(value: boolean);
  18119. private _includedOnlyMeshes;
  18120. /**
  18121. * Gets the only meshes impacted by this light.
  18122. */
  18123. get includedOnlyMeshes(): AbstractMesh[];
  18124. /**
  18125. * Sets the only meshes impacted by this light.
  18126. */
  18127. set includedOnlyMeshes(value: AbstractMesh[]);
  18128. private _excludedMeshes;
  18129. /**
  18130. * Gets the meshes not impacted by this light.
  18131. */
  18132. get excludedMeshes(): AbstractMesh[];
  18133. /**
  18134. * Sets the meshes not impacted by this light.
  18135. */
  18136. set excludedMeshes(value: AbstractMesh[]);
  18137. private _excludeWithLayerMask;
  18138. /**
  18139. * Gets the layer id use to find what meshes are not impacted by the light.
  18140. * Inactive if 0
  18141. */
  18142. get excludeWithLayerMask(): number;
  18143. /**
  18144. * Sets the layer id use to find what meshes are not impacted by the light.
  18145. * Inactive if 0
  18146. */
  18147. set excludeWithLayerMask(value: number);
  18148. private _includeOnlyWithLayerMask;
  18149. /**
  18150. * Gets the layer id use to find what meshes are impacted by the light.
  18151. * Inactive if 0
  18152. */
  18153. get includeOnlyWithLayerMask(): number;
  18154. /**
  18155. * Sets the layer id use to find what meshes are impacted by the light.
  18156. * Inactive if 0
  18157. */
  18158. set includeOnlyWithLayerMask(value: number);
  18159. private _lightmapMode;
  18160. /**
  18161. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18162. */
  18163. get lightmapMode(): number;
  18164. /**
  18165. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18166. */
  18167. set lightmapMode(value: number);
  18168. /**
  18169. * Shadow generator associted to the light.
  18170. * @hidden Internal use only.
  18171. */
  18172. _shadowGenerator: Nullable<IShadowGenerator>;
  18173. /**
  18174. * @hidden Internal use only.
  18175. */
  18176. _excludedMeshesIds: string[];
  18177. /**
  18178. * @hidden Internal use only.
  18179. */
  18180. _includedOnlyMeshesIds: string[];
  18181. /**
  18182. * The current light unifom buffer.
  18183. * @hidden Internal use only.
  18184. */
  18185. _uniformBuffer: UniformBuffer;
  18186. /** @hidden */
  18187. _renderId: number;
  18188. /**
  18189. * Creates a Light object in the scene.
  18190. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18191. * @param name The firendly name of the light
  18192. * @param scene The scene the light belongs too
  18193. */
  18194. constructor(name: string, scene: Scene);
  18195. protected abstract _buildUniformLayout(): void;
  18196. /**
  18197. * Sets the passed Effect "effect" with the Light information.
  18198. * @param effect The effect to update
  18199. * @param lightIndex The index of the light in the effect to update
  18200. * @returns The light
  18201. */
  18202. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18203. /**
  18204. * Sets the passed Effect "effect" with the Light textures.
  18205. * @param effect The effect to update
  18206. * @param lightIndex The index of the light in the effect to update
  18207. * @returns The light
  18208. */
  18209. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18210. /**
  18211. * Binds the lights information from the scene to the effect for the given mesh.
  18212. * @param lightIndex Light index
  18213. * @param scene The scene where the light belongs to
  18214. * @param effect The effect we are binding the data to
  18215. * @param useSpecular Defines if specular is supported
  18216. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18217. */
  18218. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18219. /**
  18220. * Sets the passed Effect "effect" with the Light information.
  18221. * @param effect The effect to update
  18222. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18223. * @returns The light
  18224. */
  18225. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18226. /**
  18227. * Returns the string "Light".
  18228. * @returns the class name
  18229. */
  18230. getClassName(): string;
  18231. /** @hidden */
  18232. readonly _isLight: boolean;
  18233. /**
  18234. * Converts the light information to a readable string for debug purpose.
  18235. * @param fullDetails Supports for multiple levels of logging within scene loading
  18236. * @returns the human readable light info
  18237. */
  18238. toString(fullDetails?: boolean): string;
  18239. /** @hidden */
  18240. protected _syncParentEnabledState(): void;
  18241. /**
  18242. * Set the enabled state of this node.
  18243. * @param value - the new enabled state
  18244. */
  18245. setEnabled(value: boolean): void;
  18246. /**
  18247. * Returns the Light associated shadow generator if any.
  18248. * @return the associated shadow generator.
  18249. */
  18250. getShadowGenerator(): Nullable<IShadowGenerator>;
  18251. /**
  18252. * Returns a Vector3, the absolute light position in the World.
  18253. * @returns the world space position of the light
  18254. */
  18255. getAbsolutePosition(): Vector3;
  18256. /**
  18257. * Specifies if the light will affect the passed mesh.
  18258. * @param mesh The mesh to test against the light
  18259. * @return true the mesh is affected otherwise, false.
  18260. */
  18261. canAffectMesh(mesh: AbstractMesh): boolean;
  18262. /**
  18263. * Sort function to order lights for rendering.
  18264. * @param a First Light object to compare to second.
  18265. * @param b Second Light object to compare first.
  18266. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18267. */
  18268. static CompareLightsPriority(a: Light, b: Light): number;
  18269. /**
  18270. * Releases resources associated with this node.
  18271. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18272. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18273. */
  18274. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18275. /**
  18276. * Returns the light type ID (integer).
  18277. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18278. */
  18279. getTypeID(): number;
  18280. /**
  18281. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18282. * @returns the scaled intensity in intensity mode unit
  18283. */
  18284. getScaledIntensity(): number;
  18285. /**
  18286. * Returns a new Light object, named "name", from the current one.
  18287. * @param name The name of the cloned light
  18288. * @param newParent The parent of this light, if it has one
  18289. * @returns the new created light
  18290. */
  18291. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18292. /**
  18293. * Serializes the current light into a Serialization object.
  18294. * @returns the serialized object.
  18295. */
  18296. serialize(): any;
  18297. /**
  18298. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18299. * This new light is named "name" and added to the passed scene.
  18300. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18301. * @param name The friendly name of the light
  18302. * @param scene The scene the new light will belong to
  18303. * @returns the constructor function
  18304. */
  18305. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18306. /**
  18307. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18308. * @param parsedLight The JSON representation of the light
  18309. * @param scene The scene to create the parsed light in
  18310. * @returns the created light after parsing
  18311. */
  18312. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18313. private _hookArrayForExcluded;
  18314. private _hookArrayForIncludedOnly;
  18315. private _resyncMeshes;
  18316. /**
  18317. * Forces the meshes to update their light related information in their rendering used effects
  18318. * @hidden Internal Use Only
  18319. */
  18320. _markMeshesAsLightDirty(): void;
  18321. /**
  18322. * Recomputes the cached photometric scale if needed.
  18323. */
  18324. private _computePhotometricScale;
  18325. /**
  18326. * Returns the Photometric Scale according to the light type and intensity mode.
  18327. */
  18328. private _getPhotometricScale;
  18329. /**
  18330. * Reorder the light in the scene according to their defined priority.
  18331. * @hidden Internal Use Only
  18332. */
  18333. _reorderLightsInScene(): void;
  18334. /**
  18335. * Prepares the list of defines specific to the light type.
  18336. * @param defines the list of defines
  18337. * @param lightIndex defines the index of the light for the effect
  18338. */
  18339. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18340. }
  18341. }
  18342. declare module BABYLON {
  18343. /**
  18344. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18345. * This is the base of the follow, arc rotate cameras and Free camera
  18346. * @see https://doc.babylonjs.com/features/cameras
  18347. */
  18348. export class TargetCamera extends Camera {
  18349. private static _RigCamTransformMatrix;
  18350. private static _TargetTransformMatrix;
  18351. private static _TargetFocalPoint;
  18352. private _tmpUpVector;
  18353. private _tmpTargetVector;
  18354. /**
  18355. * Define the current direction the camera is moving to
  18356. */
  18357. cameraDirection: Vector3;
  18358. /**
  18359. * Define the current rotation the camera is rotating to
  18360. */
  18361. cameraRotation: Vector2;
  18362. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18363. ignoreParentScaling: boolean;
  18364. /**
  18365. * When set, the up vector of the camera will be updated by the rotation of the camera
  18366. */
  18367. updateUpVectorFromRotation: boolean;
  18368. private _tmpQuaternion;
  18369. /**
  18370. * Define the current rotation of the camera
  18371. */
  18372. rotation: Vector3;
  18373. /**
  18374. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18375. */
  18376. rotationQuaternion: Quaternion;
  18377. /**
  18378. * Define the current speed of the camera
  18379. */
  18380. speed: number;
  18381. /**
  18382. * Add constraint to the camera to prevent it to move freely in all directions and
  18383. * around all axis.
  18384. */
  18385. noRotationConstraint: boolean;
  18386. /**
  18387. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18388. * panning
  18389. */
  18390. invertRotation: boolean;
  18391. /**
  18392. * Speed multiplier for inverse camera panning
  18393. */
  18394. inverseRotationSpeed: number;
  18395. /**
  18396. * Define the current target of the camera as an object or a position.
  18397. */
  18398. lockedTarget: any;
  18399. /** @hidden */
  18400. _currentTarget: Vector3;
  18401. /** @hidden */
  18402. _initialFocalDistance: number;
  18403. /** @hidden */
  18404. _viewMatrix: Matrix;
  18405. /** @hidden */
  18406. _camMatrix: Matrix;
  18407. /** @hidden */
  18408. _cameraTransformMatrix: Matrix;
  18409. /** @hidden */
  18410. _cameraRotationMatrix: Matrix;
  18411. /** @hidden */
  18412. _referencePoint: Vector3;
  18413. /** @hidden */
  18414. _transformedReferencePoint: Vector3;
  18415. /** @hidden */
  18416. _reset: () => void;
  18417. private _defaultUp;
  18418. /**
  18419. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18420. * This is the base of the follow, arc rotate cameras and Free camera
  18421. * @see https://doc.babylonjs.com/features/cameras
  18422. * @param name Defines the name of the camera in the scene
  18423. * @param position Defines the start position of the camera in the scene
  18424. * @param scene Defines the scene the camera belongs to
  18425. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18426. */
  18427. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18428. /**
  18429. * Gets the position in front of the camera at a given distance.
  18430. * @param distance The distance from the camera we want the position to be
  18431. * @returns the position
  18432. */
  18433. getFrontPosition(distance: number): Vector3;
  18434. /** @hidden */
  18435. _getLockedTargetPosition(): Nullable<Vector3>;
  18436. private _storedPosition;
  18437. private _storedRotation;
  18438. private _storedRotationQuaternion;
  18439. /**
  18440. * Store current camera state of the camera (fov, position, rotation, etc..)
  18441. * @returns the camera
  18442. */
  18443. storeState(): Camera;
  18444. /**
  18445. * Restored camera state. You must call storeState() first
  18446. * @returns whether it was successful or not
  18447. * @hidden
  18448. */
  18449. _restoreStateValues(): boolean;
  18450. /** @hidden */
  18451. _initCache(): void;
  18452. /** @hidden */
  18453. _updateCache(ignoreParentClass?: boolean): void;
  18454. /** @hidden */
  18455. _isSynchronizedViewMatrix(): boolean;
  18456. /** @hidden */
  18457. _computeLocalCameraSpeed(): number;
  18458. /**
  18459. * Defines the target the camera should look at.
  18460. * @param target Defines the new target as a Vector or a mesh
  18461. */
  18462. setTarget(target: Vector3): void;
  18463. /**
  18464. * Defines the target point of the camera.
  18465. * The camera looks towards it form the radius distance.
  18466. */
  18467. get target(): Vector3;
  18468. set target(value: Vector3);
  18469. /**
  18470. * Return the current target position of the camera. This value is expressed in local space.
  18471. * @returns the target position
  18472. */
  18473. getTarget(): Vector3;
  18474. /** @hidden */
  18475. _decideIfNeedsToMove(): boolean;
  18476. /** @hidden */
  18477. _updatePosition(): void;
  18478. /** @hidden */
  18479. _checkInputs(): void;
  18480. protected _updateCameraRotationMatrix(): void;
  18481. /**
  18482. * 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)
  18483. * @returns the current camera
  18484. */
  18485. private _rotateUpVectorWithCameraRotationMatrix;
  18486. private _cachedRotationZ;
  18487. private _cachedQuaternionRotationZ;
  18488. /** @hidden */
  18489. _getViewMatrix(): Matrix;
  18490. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18491. /**
  18492. * @hidden
  18493. */
  18494. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18495. /**
  18496. * @hidden
  18497. */
  18498. _updateRigCameras(): void;
  18499. private _getRigCamPositionAndTarget;
  18500. /**
  18501. * Gets the current object class name.
  18502. * @return the class name
  18503. */
  18504. getClassName(): string;
  18505. }
  18506. }
  18507. declare module BABYLON {
  18508. /**
  18509. * Gather the list of keyboard event types as constants.
  18510. */
  18511. export class KeyboardEventTypes {
  18512. /**
  18513. * The keydown event is fired when a key becomes active (pressed).
  18514. */
  18515. static readonly KEYDOWN: number;
  18516. /**
  18517. * The keyup event is fired when a key has been released.
  18518. */
  18519. static readonly KEYUP: number;
  18520. }
  18521. /**
  18522. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18523. */
  18524. export class KeyboardInfo {
  18525. /**
  18526. * Defines the type of event (KeyboardEventTypes)
  18527. */
  18528. type: number;
  18529. /**
  18530. * Defines the related dom event
  18531. */
  18532. event: KeyboardEvent;
  18533. /**
  18534. * Instantiates a new keyboard info.
  18535. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18536. * @param type Defines the type of event (KeyboardEventTypes)
  18537. * @param event Defines the related dom event
  18538. */
  18539. constructor(
  18540. /**
  18541. * Defines the type of event (KeyboardEventTypes)
  18542. */
  18543. type: number,
  18544. /**
  18545. * Defines the related dom event
  18546. */
  18547. event: KeyboardEvent);
  18548. }
  18549. /**
  18550. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18551. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18552. */
  18553. export class KeyboardInfoPre extends KeyboardInfo {
  18554. /**
  18555. * Defines the type of event (KeyboardEventTypes)
  18556. */
  18557. type: number;
  18558. /**
  18559. * Defines the related dom event
  18560. */
  18561. event: KeyboardEvent;
  18562. /**
  18563. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18564. */
  18565. skipOnPointerObservable: boolean;
  18566. /**
  18567. * Instantiates a new keyboard pre info.
  18568. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18569. * @param type Defines the type of event (KeyboardEventTypes)
  18570. * @param event Defines the related dom event
  18571. */
  18572. constructor(
  18573. /**
  18574. * Defines the type of event (KeyboardEventTypes)
  18575. */
  18576. type: number,
  18577. /**
  18578. * Defines the related dom event
  18579. */
  18580. event: KeyboardEvent);
  18581. }
  18582. }
  18583. declare module BABYLON {
  18584. /**
  18585. * Manage the keyboard inputs to control the movement of a free camera.
  18586. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18587. */
  18588. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18589. /**
  18590. * Defines the camera the input is attached to.
  18591. */
  18592. camera: FreeCamera;
  18593. /**
  18594. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18595. */
  18596. keysUp: number[];
  18597. /**
  18598. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18599. */
  18600. keysUpward: number[];
  18601. /**
  18602. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18603. */
  18604. keysDown: number[];
  18605. /**
  18606. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18607. */
  18608. keysDownward: number[];
  18609. /**
  18610. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18611. */
  18612. keysLeft: number[];
  18613. /**
  18614. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18615. */
  18616. keysRight: number[];
  18617. private _keys;
  18618. private _onCanvasBlurObserver;
  18619. private _onKeyboardObserver;
  18620. private _engine;
  18621. private _scene;
  18622. /**
  18623. * Attach the input controls to a specific dom element to get the input from.
  18624. * @param element Defines the element the controls should be listened from
  18625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18626. */
  18627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18628. /**
  18629. * Detach the current controls from the specified dom element.
  18630. * @param element Defines the element to stop listening the inputs from
  18631. */
  18632. detachControl(element: Nullable<HTMLElement>): void;
  18633. /**
  18634. * Update the current camera state depending on the inputs that have been used this frame.
  18635. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18636. */
  18637. checkInputs(): void;
  18638. /**
  18639. * Gets the class name of the current intput.
  18640. * @returns the class name
  18641. */
  18642. getClassName(): string;
  18643. /** @hidden */
  18644. _onLostFocus(): void;
  18645. /**
  18646. * Get the friendly name associated with the input class.
  18647. * @returns the input friendly name
  18648. */
  18649. getSimpleName(): string;
  18650. }
  18651. }
  18652. declare module BABYLON {
  18653. /**
  18654. * Gather the list of pointer event types as constants.
  18655. */
  18656. export class PointerEventTypes {
  18657. /**
  18658. * 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.
  18659. */
  18660. static readonly POINTERDOWN: number;
  18661. /**
  18662. * The pointerup event is fired when a pointer is no longer active.
  18663. */
  18664. static readonly POINTERUP: number;
  18665. /**
  18666. * The pointermove event is fired when a pointer changes coordinates.
  18667. */
  18668. static readonly POINTERMOVE: number;
  18669. /**
  18670. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18671. */
  18672. static readonly POINTERWHEEL: number;
  18673. /**
  18674. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18675. */
  18676. static readonly POINTERPICK: number;
  18677. /**
  18678. * The pointertap event is fired when a the object has been touched and released without drag.
  18679. */
  18680. static readonly POINTERTAP: number;
  18681. /**
  18682. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18683. */
  18684. static readonly POINTERDOUBLETAP: number;
  18685. }
  18686. /**
  18687. * Base class of pointer info types.
  18688. */
  18689. export class PointerInfoBase {
  18690. /**
  18691. * Defines the type of event (PointerEventTypes)
  18692. */
  18693. type: number;
  18694. /**
  18695. * Defines the related dom event
  18696. */
  18697. event: PointerEvent | MouseWheelEvent;
  18698. /**
  18699. * Instantiates the base class of pointers info.
  18700. * @param type Defines the type of event (PointerEventTypes)
  18701. * @param event Defines the related dom event
  18702. */
  18703. constructor(
  18704. /**
  18705. * Defines the type of event (PointerEventTypes)
  18706. */
  18707. type: number,
  18708. /**
  18709. * Defines the related dom event
  18710. */
  18711. event: PointerEvent | MouseWheelEvent);
  18712. }
  18713. /**
  18714. * This class is used to store pointer related info for the onPrePointerObservable event.
  18715. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18716. */
  18717. export class PointerInfoPre extends PointerInfoBase {
  18718. /**
  18719. * Ray from a pointer if availible (eg. 6dof controller)
  18720. */
  18721. ray: Nullable<Ray>;
  18722. /**
  18723. * Defines the local position of the pointer on the canvas.
  18724. */
  18725. localPosition: Vector2;
  18726. /**
  18727. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18728. */
  18729. skipOnPointerObservable: boolean;
  18730. /**
  18731. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18732. * @param type Defines the type of event (PointerEventTypes)
  18733. * @param event Defines the related dom event
  18734. * @param localX Defines the local x coordinates of the pointer when the event occured
  18735. * @param localY Defines the local y coordinates of the pointer when the event occured
  18736. */
  18737. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18738. }
  18739. /**
  18740. * This type contains all the data related to a pointer event in Babylon.js.
  18741. * 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.
  18742. */
  18743. export class PointerInfo extends PointerInfoBase {
  18744. /**
  18745. * Defines the picking info associated to the info (if any)\
  18746. */
  18747. pickInfo: Nullable<PickingInfo>;
  18748. /**
  18749. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18750. * @param type Defines the type of event (PointerEventTypes)
  18751. * @param event Defines the related dom event
  18752. * @param pickInfo Defines the picking info associated to the info (if any)\
  18753. */
  18754. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18755. /**
  18756. * Defines the picking info associated to the info (if any)\
  18757. */
  18758. pickInfo: Nullable<PickingInfo>);
  18759. }
  18760. /**
  18761. * Data relating to a touch event on the screen.
  18762. */
  18763. export interface PointerTouch {
  18764. /**
  18765. * X coordinate of touch.
  18766. */
  18767. x: number;
  18768. /**
  18769. * Y coordinate of touch.
  18770. */
  18771. y: number;
  18772. /**
  18773. * Id of touch. Unique for each finger.
  18774. */
  18775. pointerId: number;
  18776. /**
  18777. * Event type passed from DOM.
  18778. */
  18779. type: any;
  18780. }
  18781. }
  18782. declare module BABYLON {
  18783. /**
  18784. * Manage the mouse inputs to control the movement of a free camera.
  18785. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18786. */
  18787. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18788. /**
  18789. * Define if touch is enabled in the mouse input
  18790. */
  18791. touchEnabled: boolean;
  18792. /**
  18793. * Defines the camera the input is attached to.
  18794. */
  18795. camera: FreeCamera;
  18796. /**
  18797. * Defines the buttons associated with the input to handle camera move.
  18798. */
  18799. buttons: number[];
  18800. /**
  18801. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18802. */
  18803. angularSensibility: number;
  18804. private _pointerInput;
  18805. private _onMouseMove;
  18806. private _observer;
  18807. private previousPosition;
  18808. /**
  18809. * Observable for when a pointer move event occurs containing the move offset
  18810. */
  18811. onPointerMovedObservable: Observable<{
  18812. offsetX: number;
  18813. offsetY: number;
  18814. }>;
  18815. /**
  18816. * @hidden
  18817. * If the camera should be rotated automatically based on pointer movement
  18818. */
  18819. _allowCameraRotation: boolean;
  18820. /**
  18821. * Manage the mouse inputs to control the movement of a free camera.
  18822. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18823. * @param touchEnabled Defines if touch is enabled or not
  18824. */
  18825. constructor(
  18826. /**
  18827. * Define if touch is enabled in the mouse input
  18828. */
  18829. touchEnabled?: boolean);
  18830. /**
  18831. * Attach the input controls to a specific dom element to get the input from.
  18832. * @param element Defines the element the controls should be listened from
  18833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18834. */
  18835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18836. /**
  18837. * Called on JS contextmenu event.
  18838. * Override this method to provide functionality.
  18839. */
  18840. protected onContextMenu(evt: PointerEvent): void;
  18841. /**
  18842. * Detach the current controls from the specified dom element.
  18843. * @param element Defines the element to stop listening the inputs from
  18844. */
  18845. detachControl(element: Nullable<HTMLElement>): void;
  18846. /**
  18847. * Gets the class name of the current intput.
  18848. * @returns the class name
  18849. */
  18850. getClassName(): string;
  18851. /**
  18852. * Get the friendly name associated with the input class.
  18853. * @returns the input friendly name
  18854. */
  18855. getSimpleName(): string;
  18856. }
  18857. }
  18858. declare module BABYLON {
  18859. /**
  18860. * Manage the touch inputs to control the movement of a free camera.
  18861. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18862. */
  18863. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18864. /**
  18865. * Define if mouse events can be treated as touch events
  18866. */
  18867. allowMouse: boolean;
  18868. /**
  18869. * Defines the camera the input is attached to.
  18870. */
  18871. camera: FreeCamera;
  18872. /**
  18873. * Defines the touch sensibility for rotation.
  18874. * The higher the faster.
  18875. */
  18876. touchAngularSensibility: number;
  18877. /**
  18878. * Defines the touch sensibility for move.
  18879. * The higher the faster.
  18880. */
  18881. touchMoveSensibility: number;
  18882. private _offsetX;
  18883. private _offsetY;
  18884. private _pointerPressed;
  18885. private _pointerInput;
  18886. private _observer;
  18887. private _onLostFocus;
  18888. /**
  18889. * Manage the touch inputs to control the movement of a free camera.
  18890. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18891. * @param allowMouse Defines if mouse events can be treated as touch events
  18892. */
  18893. constructor(
  18894. /**
  18895. * Define if mouse events can be treated as touch events
  18896. */
  18897. allowMouse?: boolean);
  18898. /**
  18899. * Attach the input controls to a specific dom element to get the input from.
  18900. * @param element Defines the element the controls should be listened from
  18901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18902. */
  18903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18904. /**
  18905. * Detach the current controls from the specified dom element.
  18906. * @param element Defines the element to stop listening the inputs from
  18907. */
  18908. detachControl(element: Nullable<HTMLElement>): void;
  18909. /**
  18910. * Update the current camera state depending on the inputs that have been used this frame.
  18911. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18912. */
  18913. checkInputs(): void;
  18914. /**
  18915. * Gets the class name of the current intput.
  18916. * @returns the class name
  18917. */
  18918. getClassName(): string;
  18919. /**
  18920. * Get the friendly name associated with the input class.
  18921. * @returns the input friendly name
  18922. */
  18923. getSimpleName(): string;
  18924. }
  18925. }
  18926. declare module BABYLON {
  18927. /**
  18928. * Default Inputs manager for the FreeCamera.
  18929. * It groups all the default supported inputs for ease of use.
  18930. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18931. */
  18932. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18933. /**
  18934. * @hidden
  18935. */
  18936. _mouseInput: Nullable<FreeCameraMouseInput>;
  18937. /**
  18938. * Instantiates a new FreeCameraInputsManager.
  18939. * @param camera Defines the camera the inputs belong to
  18940. */
  18941. constructor(camera: FreeCamera);
  18942. /**
  18943. * Add keyboard input support to the input manager.
  18944. * @returns the current input manager
  18945. */
  18946. addKeyboard(): FreeCameraInputsManager;
  18947. /**
  18948. * Add mouse input support to the input manager.
  18949. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18950. * @returns the current input manager
  18951. */
  18952. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18953. /**
  18954. * Removes the mouse input support from the manager
  18955. * @returns the current input manager
  18956. */
  18957. removeMouse(): FreeCameraInputsManager;
  18958. /**
  18959. * Add touch input support to the input manager.
  18960. * @returns the current input manager
  18961. */
  18962. addTouch(): FreeCameraInputsManager;
  18963. /**
  18964. * Remove all attached input methods from a camera
  18965. */
  18966. clear(): void;
  18967. }
  18968. }
  18969. declare module BABYLON {
  18970. /**
  18971. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18972. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18973. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18974. */
  18975. export class FreeCamera extends TargetCamera {
  18976. /**
  18977. * Define the collision ellipsoid of the camera.
  18978. * This is helpful to simulate a camera body like the player body around the camera
  18979. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18980. */
  18981. ellipsoid: Vector3;
  18982. /**
  18983. * Define an offset for the position of the ellipsoid around the camera.
  18984. * This can be helpful to determine the center of the body near the gravity center of the body
  18985. * instead of its head.
  18986. */
  18987. ellipsoidOffset: Vector3;
  18988. /**
  18989. * Enable or disable collisions of the camera with the rest of the scene objects.
  18990. */
  18991. checkCollisions: boolean;
  18992. /**
  18993. * Enable or disable gravity on the camera.
  18994. */
  18995. applyGravity: boolean;
  18996. /**
  18997. * Define the input manager associated to the camera.
  18998. */
  18999. inputs: FreeCameraInputsManager;
  19000. /**
  19001. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19002. * Higher values reduce sensitivity.
  19003. */
  19004. get angularSensibility(): number;
  19005. /**
  19006. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19007. * Higher values reduce sensitivity.
  19008. */
  19009. set angularSensibility(value: number);
  19010. /**
  19011. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19012. */
  19013. get keysUp(): number[];
  19014. set keysUp(value: number[]);
  19015. /**
  19016. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19017. */
  19018. get keysUpward(): number[];
  19019. set keysUpward(value: number[]);
  19020. /**
  19021. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19022. */
  19023. get keysDown(): number[];
  19024. set keysDown(value: number[]);
  19025. /**
  19026. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19027. */
  19028. get keysDownward(): number[];
  19029. set keysDownward(value: number[]);
  19030. /**
  19031. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19032. */
  19033. get keysLeft(): number[];
  19034. set keysLeft(value: number[]);
  19035. /**
  19036. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19037. */
  19038. get keysRight(): number[];
  19039. set keysRight(value: number[]);
  19040. /**
  19041. * Event raised when the camera collide with a mesh in the scene.
  19042. */
  19043. onCollide: (collidedMesh: AbstractMesh) => void;
  19044. private _collider;
  19045. private _needMoveForGravity;
  19046. private _oldPosition;
  19047. private _diffPosition;
  19048. private _newPosition;
  19049. /** @hidden */
  19050. _localDirection: Vector3;
  19051. /** @hidden */
  19052. _transformedDirection: Vector3;
  19053. /**
  19054. * Instantiates a Free Camera.
  19055. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19056. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19057. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19058. * @param name Define the name of the camera in the scene
  19059. * @param position Define the start position of the camera in the scene
  19060. * @param scene Define the scene the camera belongs to
  19061. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19062. */
  19063. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19064. /**
  19065. * Attached controls to the current camera.
  19066. * @param element Defines the element the controls should be listened from
  19067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19068. */
  19069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19070. /**
  19071. * Detach the current controls from the camera.
  19072. * The camera will stop reacting to inputs.
  19073. * @param element Defines the element to stop listening the inputs from
  19074. */
  19075. detachControl(element: HTMLElement): void;
  19076. private _collisionMask;
  19077. /**
  19078. * Define a collision mask to limit the list of object the camera can collide with
  19079. */
  19080. get collisionMask(): number;
  19081. set collisionMask(mask: number);
  19082. /** @hidden */
  19083. _collideWithWorld(displacement: Vector3): void;
  19084. private _onCollisionPositionChange;
  19085. /** @hidden */
  19086. _checkInputs(): void;
  19087. /** @hidden */
  19088. _decideIfNeedsToMove(): boolean;
  19089. /** @hidden */
  19090. _updatePosition(): void;
  19091. /**
  19092. * Destroy the camera and release the current resources hold by it.
  19093. */
  19094. dispose(): void;
  19095. /**
  19096. * Gets the current object class name.
  19097. * @return the class name
  19098. */
  19099. getClassName(): string;
  19100. }
  19101. }
  19102. declare module BABYLON {
  19103. /**
  19104. * Represents a gamepad control stick position
  19105. */
  19106. export class StickValues {
  19107. /**
  19108. * The x component of the control stick
  19109. */
  19110. x: number;
  19111. /**
  19112. * The y component of the control stick
  19113. */
  19114. y: number;
  19115. /**
  19116. * Initializes the gamepad x and y control stick values
  19117. * @param x The x component of the gamepad control stick value
  19118. * @param y The y component of the gamepad control stick value
  19119. */
  19120. constructor(
  19121. /**
  19122. * The x component of the control stick
  19123. */
  19124. x: number,
  19125. /**
  19126. * The y component of the control stick
  19127. */
  19128. y: number);
  19129. }
  19130. /**
  19131. * An interface which manages callbacks for gamepad button changes
  19132. */
  19133. export interface GamepadButtonChanges {
  19134. /**
  19135. * Called when a gamepad has been changed
  19136. */
  19137. changed: boolean;
  19138. /**
  19139. * Called when a gamepad press event has been triggered
  19140. */
  19141. pressChanged: boolean;
  19142. /**
  19143. * Called when a touch event has been triggered
  19144. */
  19145. touchChanged: boolean;
  19146. /**
  19147. * Called when a value has changed
  19148. */
  19149. valueChanged: boolean;
  19150. }
  19151. /**
  19152. * Represents a gamepad
  19153. */
  19154. export class Gamepad {
  19155. /**
  19156. * The id of the gamepad
  19157. */
  19158. id: string;
  19159. /**
  19160. * The index of the gamepad
  19161. */
  19162. index: number;
  19163. /**
  19164. * The browser gamepad
  19165. */
  19166. browserGamepad: any;
  19167. /**
  19168. * Specifies what type of gamepad this represents
  19169. */
  19170. type: number;
  19171. private _leftStick;
  19172. private _rightStick;
  19173. /** @hidden */
  19174. _isConnected: boolean;
  19175. private _leftStickAxisX;
  19176. private _leftStickAxisY;
  19177. private _rightStickAxisX;
  19178. private _rightStickAxisY;
  19179. /**
  19180. * Triggered when the left control stick has been changed
  19181. */
  19182. private _onleftstickchanged;
  19183. /**
  19184. * Triggered when the right control stick has been changed
  19185. */
  19186. private _onrightstickchanged;
  19187. /**
  19188. * Represents a gamepad controller
  19189. */
  19190. static GAMEPAD: number;
  19191. /**
  19192. * Represents a generic controller
  19193. */
  19194. static GENERIC: number;
  19195. /**
  19196. * Represents an XBox controller
  19197. */
  19198. static XBOX: number;
  19199. /**
  19200. * Represents a pose-enabled controller
  19201. */
  19202. static POSE_ENABLED: number;
  19203. /**
  19204. * Represents an Dual Shock controller
  19205. */
  19206. static DUALSHOCK: number;
  19207. /**
  19208. * Specifies whether the left control stick should be Y-inverted
  19209. */
  19210. protected _invertLeftStickY: boolean;
  19211. /**
  19212. * Specifies if the gamepad has been connected
  19213. */
  19214. get isConnected(): boolean;
  19215. /**
  19216. * Initializes the gamepad
  19217. * @param id The id of the gamepad
  19218. * @param index The index of the gamepad
  19219. * @param browserGamepad The browser gamepad
  19220. * @param leftStickX The x component of the left joystick
  19221. * @param leftStickY The y component of the left joystick
  19222. * @param rightStickX The x component of the right joystick
  19223. * @param rightStickY The y component of the right joystick
  19224. */
  19225. constructor(
  19226. /**
  19227. * The id of the gamepad
  19228. */
  19229. id: string,
  19230. /**
  19231. * The index of the gamepad
  19232. */
  19233. index: number,
  19234. /**
  19235. * The browser gamepad
  19236. */
  19237. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19238. /**
  19239. * Callback triggered when the left joystick has changed
  19240. * @param callback
  19241. */
  19242. onleftstickchanged(callback: (values: StickValues) => void): void;
  19243. /**
  19244. * Callback triggered when the right joystick has changed
  19245. * @param callback
  19246. */
  19247. onrightstickchanged(callback: (values: StickValues) => void): void;
  19248. /**
  19249. * Gets the left joystick
  19250. */
  19251. get leftStick(): StickValues;
  19252. /**
  19253. * Sets the left joystick values
  19254. */
  19255. set leftStick(newValues: StickValues);
  19256. /**
  19257. * Gets the right joystick
  19258. */
  19259. get rightStick(): StickValues;
  19260. /**
  19261. * Sets the right joystick value
  19262. */
  19263. set rightStick(newValues: StickValues);
  19264. /**
  19265. * Updates the gamepad joystick positions
  19266. */
  19267. update(): void;
  19268. /**
  19269. * Disposes the gamepad
  19270. */
  19271. dispose(): void;
  19272. }
  19273. /**
  19274. * Represents a generic gamepad
  19275. */
  19276. export class GenericPad extends Gamepad {
  19277. private _buttons;
  19278. private _onbuttondown;
  19279. private _onbuttonup;
  19280. /**
  19281. * Observable triggered when a button has been pressed
  19282. */
  19283. onButtonDownObservable: Observable<number>;
  19284. /**
  19285. * Observable triggered when a button has been released
  19286. */
  19287. onButtonUpObservable: Observable<number>;
  19288. /**
  19289. * Callback triggered when a button has been pressed
  19290. * @param callback Called when a button has been pressed
  19291. */
  19292. onbuttondown(callback: (buttonPressed: number) => void): void;
  19293. /**
  19294. * Callback triggered when a button has been released
  19295. * @param callback Called when a button has been released
  19296. */
  19297. onbuttonup(callback: (buttonReleased: number) => void): void;
  19298. /**
  19299. * Initializes the generic gamepad
  19300. * @param id The id of the generic gamepad
  19301. * @param index The index of the generic gamepad
  19302. * @param browserGamepad The browser gamepad
  19303. */
  19304. constructor(id: string, index: number, browserGamepad: any);
  19305. private _setButtonValue;
  19306. /**
  19307. * Updates the generic gamepad
  19308. */
  19309. update(): void;
  19310. /**
  19311. * Disposes the generic gamepad
  19312. */
  19313. dispose(): void;
  19314. }
  19315. }
  19316. declare module BABYLON {
  19317. /**
  19318. * Defines the types of pose enabled controllers that are supported
  19319. */
  19320. export enum PoseEnabledControllerType {
  19321. /**
  19322. * HTC Vive
  19323. */
  19324. VIVE = 0,
  19325. /**
  19326. * Oculus Rift
  19327. */
  19328. OCULUS = 1,
  19329. /**
  19330. * Windows mixed reality
  19331. */
  19332. WINDOWS = 2,
  19333. /**
  19334. * Samsung gear VR
  19335. */
  19336. GEAR_VR = 3,
  19337. /**
  19338. * Google Daydream
  19339. */
  19340. DAYDREAM = 4,
  19341. /**
  19342. * Generic
  19343. */
  19344. GENERIC = 5
  19345. }
  19346. /**
  19347. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19348. */
  19349. export interface MutableGamepadButton {
  19350. /**
  19351. * Value of the button/trigger
  19352. */
  19353. value: number;
  19354. /**
  19355. * If the button/trigger is currently touched
  19356. */
  19357. touched: boolean;
  19358. /**
  19359. * If the button/trigger is currently pressed
  19360. */
  19361. pressed: boolean;
  19362. }
  19363. /**
  19364. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19365. * @hidden
  19366. */
  19367. export interface ExtendedGamepadButton extends GamepadButton {
  19368. /**
  19369. * If the button/trigger is currently pressed
  19370. */
  19371. readonly pressed: boolean;
  19372. /**
  19373. * If the button/trigger is currently touched
  19374. */
  19375. readonly touched: boolean;
  19376. /**
  19377. * Value of the button/trigger
  19378. */
  19379. readonly value: number;
  19380. }
  19381. /** @hidden */
  19382. export interface _GamePadFactory {
  19383. /**
  19384. * Returns whether or not the current gamepad can be created for this type of controller.
  19385. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19386. * @returns true if it can be created, otherwise false
  19387. */
  19388. canCreate(gamepadInfo: any): boolean;
  19389. /**
  19390. * Creates a new instance of the Gamepad.
  19391. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19392. * @returns the new gamepad instance
  19393. */
  19394. create(gamepadInfo: any): Gamepad;
  19395. }
  19396. /**
  19397. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19398. */
  19399. export class PoseEnabledControllerHelper {
  19400. /** @hidden */
  19401. static _ControllerFactories: _GamePadFactory[];
  19402. /** @hidden */
  19403. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19404. /**
  19405. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19406. * @param vrGamepad the gamepad to initialized
  19407. * @returns a vr controller of the type the gamepad identified as
  19408. */
  19409. static InitiateController(vrGamepad: any): Gamepad;
  19410. }
  19411. /**
  19412. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19413. */
  19414. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19415. /**
  19416. * If the controller is used in a webXR session
  19417. */
  19418. isXR: boolean;
  19419. private _deviceRoomPosition;
  19420. private _deviceRoomRotationQuaternion;
  19421. /**
  19422. * The device position in babylon space
  19423. */
  19424. devicePosition: Vector3;
  19425. /**
  19426. * The device rotation in babylon space
  19427. */
  19428. deviceRotationQuaternion: Quaternion;
  19429. /**
  19430. * The scale factor of the device in babylon space
  19431. */
  19432. deviceScaleFactor: number;
  19433. /**
  19434. * (Likely devicePosition should be used instead) The device position in its room space
  19435. */
  19436. position: Vector3;
  19437. /**
  19438. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19439. */
  19440. rotationQuaternion: Quaternion;
  19441. /**
  19442. * The type of controller (Eg. Windows mixed reality)
  19443. */
  19444. controllerType: PoseEnabledControllerType;
  19445. protected _calculatedPosition: Vector3;
  19446. private _calculatedRotation;
  19447. /**
  19448. * The raw pose from the device
  19449. */
  19450. rawPose: DevicePose;
  19451. private _trackPosition;
  19452. private _maxRotationDistFromHeadset;
  19453. private _draggedRoomRotation;
  19454. /**
  19455. * @hidden
  19456. */
  19457. _disableTrackPosition(fixedPosition: Vector3): void;
  19458. /**
  19459. * Internal, the mesh attached to the controller
  19460. * @hidden
  19461. */
  19462. _mesh: Nullable<AbstractMesh>;
  19463. private _poseControlledCamera;
  19464. private _leftHandSystemQuaternion;
  19465. /**
  19466. * Internal, matrix used to convert room space to babylon space
  19467. * @hidden
  19468. */
  19469. _deviceToWorld: Matrix;
  19470. /**
  19471. * Node to be used when casting a ray from the controller
  19472. * @hidden
  19473. */
  19474. _pointingPoseNode: Nullable<TransformNode>;
  19475. /**
  19476. * Name of the child mesh that can be used to cast a ray from the controller
  19477. */
  19478. static readonly POINTING_POSE: string;
  19479. /**
  19480. * Creates a new PoseEnabledController from a gamepad
  19481. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19482. */
  19483. constructor(browserGamepad: any);
  19484. private _workingMatrix;
  19485. /**
  19486. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19487. */
  19488. update(): void;
  19489. /**
  19490. * Updates only the pose device and mesh without doing any button event checking
  19491. */
  19492. protected _updatePoseAndMesh(): void;
  19493. /**
  19494. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19495. * @param poseData raw pose fromthe device
  19496. */
  19497. updateFromDevice(poseData: DevicePose): void;
  19498. /**
  19499. * @hidden
  19500. */
  19501. _meshAttachedObservable: Observable<AbstractMesh>;
  19502. /**
  19503. * Attaches a mesh to the controller
  19504. * @param mesh the mesh to be attached
  19505. */
  19506. attachToMesh(mesh: AbstractMesh): void;
  19507. /**
  19508. * Attaches the controllers mesh to a camera
  19509. * @param camera the camera the mesh should be attached to
  19510. */
  19511. attachToPoseControlledCamera(camera: TargetCamera): void;
  19512. /**
  19513. * Disposes of the controller
  19514. */
  19515. dispose(): void;
  19516. /**
  19517. * The mesh that is attached to the controller
  19518. */
  19519. get mesh(): Nullable<AbstractMesh>;
  19520. /**
  19521. * Gets the ray of the controller in the direction the controller is pointing
  19522. * @param length the length the resulting ray should be
  19523. * @returns a ray in the direction the controller is pointing
  19524. */
  19525. getForwardRay(length?: number): Ray;
  19526. }
  19527. }
  19528. declare module BABYLON {
  19529. /**
  19530. * Defines the WebVRController object that represents controllers tracked in 3D space
  19531. */
  19532. export abstract class WebVRController extends PoseEnabledController {
  19533. /**
  19534. * Internal, the default controller model for the controller
  19535. */
  19536. protected _defaultModel: Nullable<AbstractMesh>;
  19537. /**
  19538. * Fired when the trigger state has changed
  19539. */
  19540. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19541. /**
  19542. * Fired when the main button state has changed
  19543. */
  19544. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19545. /**
  19546. * Fired when the secondary button state has changed
  19547. */
  19548. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19549. /**
  19550. * Fired when the pad state has changed
  19551. */
  19552. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19553. /**
  19554. * Fired when controllers stick values have changed
  19555. */
  19556. onPadValuesChangedObservable: Observable<StickValues>;
  19557. /**
  19558. * Array of button availible on the controller
  19559. */
  19560. protected _buttons: Array<MutableGamepadButton>;
  19561. private _onButtonStateChange;
  19562. /**
  19563. * Fired when a controller button's state has changed
  19564. * @param callback the callback containing the button that was modified
  19565. */
  19566. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19567. /**
  19568. * X and Y axis corresponding to the controllers joystick
  19569. */
  19570. pad: StickValues;
  19571. /**
  19572. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19573. */
  19574. hand: string;
  19575. /**
  19576. * The default controller model for the controller
  19577. */
  19578. get defaultModel(): Nullable<AbstractMesh>;
  19579. /**
  19580. * Creates a new WebVRController from a gamepad
  19581. * @param vrGamepad the gamepad that the WebVRController should be created from
  19582. */
  19583. constructor(vrGamepad: any);
  19584. /**
  19585. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19586. */
  19587. update(): void;
  19588. /**
  19589. * Function to be called when a button is modified
  19590. */
  19591. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19592. /**
  19593. * Loads a mesh and attaches it to the controller
  19594. * @param scene the scene the mesh should be added to
  19595. * @param meshLoaded callback for when the mesh has been loaded
  19596. */
  19597. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19598. private _setButtonValue;
  19599. private _changes;
  19600. private _checkChanges;
  19601. /**
  19602. * Disposes of th webVRCOntroller
  19603. */
  19604. dispose(): void;
  19605. }
  19606. }
  19607. declare module BABYLON {
  19608. /**
  19609. * The HemisphericLight simulates the ambient environment light,
  19610. * so the passed direction is the light reflection direction, not the incoming direction.
  19611. */
  19612. export class HemisphericLight extends Light {
  19613. /**
  19614. * The groundColor is the light in the opposite direction to the one specified during creation.
  19615. * 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.
  19616. */
  19617. groundColor: Color3;
  19618. /**
  19619. * The light reflection direction, not the incoming direction.
  19620. */
  19621. direction: Vector3;
  19622. /**
  19623. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19624. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19625. * The HemisphericLight can't cast shadows.
  19626. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19627. * @param name The friendly name of the light
  19628. * @param direction The direction of the light reflection
  19629. * @param scene The scene the light belongs to
  19630. */
  19631. constructor(name: string, direction: Vector3, scene: Scene);
  19632. protected _buildUniformLayout(): void;
  19633. /**
  19634. * Returns the string "HemisphericLight".
  19635. * @return The class name
  19636. */
  19637. getClassName(): string;
  19638. /**
  19639. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19640. * Returns the updated direction.
  19641. * @param target The target the direction should point to
  19642. * @return The computed direction
  19643. */
  19644. setDirectionToTarget(target: Vector3): Vector3;
  19645. /**
  19646. * Returns the shadow generator associated to the light.
  19647. * @returns Always null for hemispheric lights because it does not support shadows.
  19648. */
  19649. getShadowGenerator(): Nullable<IShadowGenerator>;
  19650. /**
  19651. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19652. * @param effect The effect to update
  19653. * @param lightIndex The index of the light in the effect to update
  19654. * @returns The hemispheric light
  19655. */
  19656. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19657. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19658. /**
  19659. * Computes the world matrix of the node
  19660. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19661. * @param useWasUpdatedFlag defines a reserved property
  19662. * @returns the world matrix
  19663. */
  19664. computeWorldMatrix(): Matrix;
  19665. /**
  19666. * Returns the integer 3.
  19667. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19668. */
  19669. getTypeID(): number;
  19670. /**
  19671. * Prepares the list of defines specific to the light type.
  19672. * @param defines the list of defines
  19673. * @param lightIndex defines the index of the light for the effect
  19674. */
  19675. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19676. }
  19677. }
  19678. declare module BABYLON {
  19679. /** @hidden */
  19680. export var vrMultiviewToSingleviewPixelShader: {
  19681. name: string;
  19682. shader: string;
  19683. };
  19684. }
  19685. declare module BABYLON {
  19686. /**
  19687. * Renders to multiple views with a single draw call
  19688. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19689. */
  19690. export class MultiviewRenderTarget extends RenderTargetTexture {
  19691. /**
  19692. * Creates a multiview render target
  19693. * @param scene scene used with the render target
  19694. * @param size the size of the render target (used for each view)
  19695. */
  19696. constructor(scene: Scene, size?: number | {
  19697. width: number;
  19698. height: number;
  19699. } | {
  19700. ratio: number;
  19701. });
  19702. /**
  19703. * @hidden
  19704. * @param faceIndex the face index, if its a cube texture
  19705. */
  19706. _bindFrameBuffer(faceIndex?: number): void;
  19707. /**
  19708. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19709. * @returns the view count
  19710. */
  19711. getViewCount(): number;
  19712. }
  19713. }
  19714. declare module BABYLON {
  19715. interface Engine {
  19716. /**
  19717. * Creates a new multiview render target
  19718. * @param width defines the width of the texture
  19719. * @param height defines the height of the texture
  19720. * @returns the created multiview texture
  19721. */
  19722. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19723. /**
  19724. * Binds a multiview framebuffer to be drawn to
  19725. * @param multiviewTexture texture to bind
  19726. */
  19727. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19728. }
  19729. interface Camera {
  19730. /**
  19731. * @hidden
  19732. * 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)
  19733. */
  19734. _useMultiviewToSingleView: boolean;
  19735. /**
  19736. * @hidden
  19737. * 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)
  19738. */
  19739. _multiviewTexture: Nullable<RenderTargetTexture>;
  19740. /**
  19741. * @hidden
  19742. * ensures the multiview texture of the camera exists and has the specified width/height
  19743. * @param width height to set on the multiview texture
  19744. * @param height width to set on the multiview texture
  19745. */
  19746. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19747. }
  19748. interface Scene {
  19749. /** @hidden */
  19750. _transformMatrixR: Matrix;
  19751. /** @hidden */
  19752. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19753. /** @hidden */
  19754. _createMultiviewUbo(): void;
  19755. /** @hidden */
  19756. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19757. /** @hidden */
  19758. _renderMultiviewToSingleView(camera: Camera): void;
  19759. }
  19760. }
  19761. declare module BABYLON {
  19762. /**
  19763. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19764. * This will not be used for webXR as it supports displaying texture arrays directly
  19765. */
  19766. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19767. /**
  19768. * Gets a string identifying the name of the class
  19769. * @returns "VRMultiviewToSingleviewPostProcess" string
  19770. */
  19771. getClassName(): string;
  19772. /**
  19773. * Initializes a VRMultiviewToSingleview
  19774. * @param name name of the post process
  19775. * @param camera camera to be applied to
  19776. * @param scaleFactor scaling factor to the size of the output texture
  19777. */
  19778. constructor(name: string, camera: Camera, scaleFactor: number);
  19779. }
  19780. }
  19781. declare module BABYLON {
  19782. /**
  19783. * Interface used to define additional presentation attributes
  19784. */
  19785. export interface IVRPresentationAttributes {
  19786. /**
  19787. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19788. */
  19789. highRefreshRate: boolean;
  19790. /**
  19791. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19792. */
  19793. foveationLevel: number;
  19794. }
  19795. interface Engine {
  19796. /** @hidden */
  19797. _vrDisplay: any;
  19798. /** @hidden */
  19799. _vrSupported: boolean;
  19800. /** @hidden */
  19801. _oldSize: Size;
  19802. /** @hidden */
  19803. _oldHardwareScaleFactor: number;
  19804. /** @hidden */
  19805. _vrExclusivePointerMode: boolean;
  19806. /** @hidden */
  19807. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19808. /** @hidden */
  19809. _onVRDisplayPointerRestricted: () => void;
  19810. /** @hidden */
  19811. _onVRDisplayPointerUnrestricted: () => void;
  19812. /** @hidden */
  19813. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19814. /** @hidden */
  19815. _onVrDisplayDisconnect: Nullable<() => void>;
  19816. /** @hidden */
  19817. _onVrDisplayPresentChange: Nullable<() => void>;
  19818. /**
  19819. * Observable signaled when VR display mode changes
  19820. */
  19821. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19822. /**
  19823. * Observable signaled when VR request present is complete
  19824. */
  19825. onVRRequestPresentComplete: Observable<boolean>;
  19826. /**
  19827. * Observable signaled when VR request present starts
  19828. */
  19829. onVRRequestPresentStart: Observable<Engine>;
  19830. /**
  19831. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19832. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19833. */
  19834. isInVRExclusivePointerMode: boolean;
  19835. /**
  19836. * Gets a boolean indicating if a webVR device was detected
  19837. * @returns true if a webVR device was detected
  19838. */
  19839. isVRDevicePresent(): boolean;
  19840. /**
  19841. * Gets the current webVR device
  19842. * @returns the current webVR device (or null)
  19843. */
  19844. getVRDevice(): any;
  19845. /**
  19846. * Initializes a webVR display and starts listening to display change events
  19847. * The onVRDisplayChangedObservable will be notified upon these changes
  19848. * @returns A promise containing a VRDisplay and if vr is supported
  19849. */
  19850. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19851. /** @hidden */
  19852. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19853. /**
  19854. * Gets or sets the presentation attributes used to configure VR rendering
  19855. */
  19856. vrPresentationAttributes?: IVRPresentationAttributes;
  19857. /**
  19858. * Call this function to switch to webVR mode
  19859. * Will do nothing if webVR is not supported or if there is no webVR device
  19860. * @param options the webvr options provided to the camera. mainly used for multiview
  19861. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19862. */
  19863. enableVR(options: WebVROptions): void;
  19864. /** @hidden */
  19865. _onVRFullScreenTriggered(): void;
  19866. }
  19867. }
  19868. declare module BABYLON {
  19869. /**
  19870. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19871. * IMPORTANT!! The data is right-hand data.
  19872. * @export
  19873. * @interface DevicePose
  19874. */
  19875. export interface DevicePose {
  19876. /**
  19877. * The position of the device, values in array are [x,y,z].
  19878. */
  19879. readonly position: Nullable<Float32Array>;
  19880. /**
  19881. * The linearVelocity of the device, values in array are [x,y,z].
  19882. */
  19883. readonly linearVelocity: Nullable<Float32Array>;
  19884. /**
  19885. * The linearAcceleration of the device, values in array are [x,y,z].
  19886. */
  19887. readonly linearAcceleration: Nullable<Float32Array>;
  19888. /**
  19889. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19890. */
  19891. readonly orientation: Nullable<Float32Array>;
  19892. /**
  19893. * The angularVelocity of the device, values in array are [x,y,z].
  19894. */
  19895. readonly angularVelocity: Nullable<Float32Array>;
  19896. /**
  19897. * The angularAcceleration of the device, values in array are [x,y,z].
  19898. */
  19899. readonly angularAcceleration: Nullable<Float32Array>;
  19900. }
  19901. /**
  19902. * Interface representing a pose controlled object in Babylon.
  19903. * A pose controlled object has both regular pose values as well as pose values
  19904. * from an external device such as a VR head mounted display
  19905. */
  19906. export interface PoseControlled {
  19907. /**
  19908. * The position of the object in babylon space.
  19909. */
  19910. position: Vector3;
  19911. /**
  19912. * The rotation quaternion of the object in babylon space.
  19913. */
  19914. rotationQuaternion: Quaternion;
  19915. /**
  19916. * The position of the device in babylon space.
  19917. */
  19918. devicePosition?: Vector3;
  19919. /**
  19920. * The rotation quaternion of the device in babylon space.
  19921. */
  19922. deviceRotationQuaternion: Quaternion;
  19923. /**
  19924. * The raw pose coming from the device.
  19925. */
  19926. rawPose: Nullable<DevicePose>;
  19927. /**
  19928. * The scale of the device to be used when translating from device space to babylon space.
  19929. */
  19930. deviceScaleFactor: number;
  19931. /**
  19932. * Updates the poseControlled values based on the input device pose.
  19933. * @param poseData the pose data to update the object with
  19934. */
  19935. updateFromDevice(poseData: DevicePose): void;
  19936. }
  19937. /**
  19938. * Set of options to customize the webVRCamera
  19939. */
  19940. export interface WebVROptions {
  19941. /**
  19942. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19943. */
  19944. trackPosition?: boolean;
  19945. /**
  19946. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19947. */
  19948. positionScale?: number;
  19949. /**
  19950. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19951. */
  19952. displayName?: string;
  19953. /**
  19954. * Should the native controller meshes be initialized. (default: true)
  19955. */
  19956. controllerMeshes?: boolean;
  19957. /**
  19958. * Creating a default HemiLight only on controllers. (default: true)
  19959. */
  19960. defaultLightingOnControllers?: boolean;
  19961. /**
  19962. * If you don't want to use the default VR button of the helper. (default: false)
  19963. */
  19964. useCustomVRButton?: boolean;
  19965. /**
  19966. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19967. */
  19968. customVRButton?: HTMLButtonElement;
  19969. /**
  19970. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19971. */
  19972. rayLength?: number;
  19973. /**
  19974. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19975. */
  19976. defaultHeight?: number;
  19977. /**
  19978. * If multiview should be used if availible (default: false)
  19979. */
  19980. useMultiview?: boolean;
  19981. }
  19982. /**
  19983. * This represents a WebVR camera.
  19984. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19985. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19986. */
  19987. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19988. private webVROptions;
  19989. /**
  19990. * @hidden
  19991. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19992. */
  19993. _vrDevice: any;
  19994. /**
  19995. * The rawPose of the vrDevice.
  19996. */
  19997. rawPose: Nullable<DevicePose>;
  19998. private _onVREnabled;
  19999. private _specsVersion;
  20000. private _attached;
  20001. private _frameData;
  20002. protected _descendants: Array<Node>;
  20003. private _deviceRoomPosition;
  20004. /** @hidden */
  20005. _deviceRoomRotationQuaternion: Quaternion;
  20006. private _standingMatrix;
  20007. /**
  20008. * Represents device position in babylon space.
  20009. */
  20010. devicePosition: Vector3;
  20011. /**
  20012. * Represents device rotation in babylon space.
  20013. */
  20014. deviceRotationQuaternion: Quaternion;
  20015. /**
  20016. * The scale of the device to be used when translating from device space to babylon space.
  20017. */
  20018. deviceScaleFactor: number;
  20019. private _deviceToWorld;
  20020. private _worldToDevice;
  20021. /**
  20022. * References to the webVR controllers for the vrDevice.
  20023. */
  20024. controllers: Array<WebVRController>;
  20025. /**
  20026. * Emits an event when a controller is attached.
  20027. */
  20028. onControllersAttachedObservable: Observable<WebVRController[]>;
  20029. /**
  20030. * Emits an event when a controller's mesh has been loaded;
  20031. */
  20032. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20033. /**
  20034. * Emits an event when the HMD's pose has been updated.
  20035. */
  20036. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20037. private _poseSet;
  20038. /**
  20039. * If the rig cameras be used as parent instead of this camera.
  20040. */
  20041. rigParenting: boolean;
  20042. private _lightOnControllers;
  20043. private _defaultHeight?;
  20044. /**
  20045. * Instantiates a WebVRFreeCamera.
  20046. * @param name The name of the WebVRFreeCamera
  20047. * @param position The starting anchor position for the camera
  20048. * @param scene The scene the camera belongs to
  20049. * @param webVROptions a set of customizable options for the webVRCamera
  20050. */
  20051. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20052. /**
  20053. * Gets the device distance from the ground in meters.
  20054. * @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.
  20055. */
  20056. deviceDistanceToRoomGround(): number;
  20057. /**
  20058. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20059. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20060. */
  20061. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20062. /**
  20063. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20064. * @returns A promise with a boolean set to if the standing matrix is supported.
  20065. */
  20066. useStandingMatrixAsync(): Promise<boolean>;
  20067. /**
  20068. * Disposes the camera
  20069. */
  20070. dispose(): void;
  20071. /**
  20072. * Gets a vrController by name.
  20073. * @param name The name of the controller to retreive
  20074. * @returns the controller matching the name specified or null if not found
  20075. */
  20076. getControllerByName(name: string): Nullable<WebVRController>;
  20077. private _leftController;
  20078. /**
  20079. * The controller corresponding to the users left hand.
  20080. */
  20081. get leftController(): Nullable<WebVRController>;
  20082. private _rightController;
  20083. /**
  20084. * The controller corresponding to the users right hand.
  20085. */
  20086. get rightController(): Nullable<WebVRController>;
  20087. /**
  20088. * Casts a ray forward from the vrCamera's gaze.
  20089. * @param length Length of the ray (default: 100)
  20090. * @returns the ray corresponding to the gaze
  20091. */
  20092. getForwardRay(length?: number): Ray;
  20093. /**
  20094. * @hidden
  20095. * Updates the camera based on device's frame data
  20096. */
  20097. _checkInputs(): void;
  20098. /**
  20099. * Updates the poseControlled values based on the input device pose.
  20100. * @param poseData Pose coming from the device
  20101. */
  20102. updateFromDevice(poseData: DevicePose): void;
  20103. private _htmlElementAttached;
  20104. private _detachIfAttached;
  20105. /**
  20106. * WebVR's attach control will start broadcasting frames to the device.
  20107. * Note that in certain browsers (chrome for example) this function must be called
  20108. * within a user-interaction callback. Example:
  20109. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20110. *
  20111. * @param element html element to attach the vrDevice to
  20112. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20113. */
  20114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20115. /**
  20116. * Detaches the camera from the html element and disables VR
  20117. *
  20118. * @param element html element to detach from
  20119. */
  20120. detachControl(element: HTMLElement): void;
  20121. /**
  20122. * @returns the name of this class
  20123. */
  20124. getClassName(): string;
  20125. /**
  20126. * Calls resetPose on the vrDisplay
  20127. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20128. */
  20129. resetToCurrentRotation(): void;
  20130. /**
  20131. * @hidden
  20132. * Updates the rig cameras (left and right eye)
  20133. */
  20134. _updateRigCameras(): void;
  20135. private _workingVector;
  20136. private _oneVector;
  20137. private _workingMatrix;
  20138. private updateCacheCalled;
  20139. private _correctPositionIfNotTrackPosition;
  20140. /**
  20141. * @hidden
  20142. * Updates the cached values of the camera
  20143. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20144. */
  20145. _updateCache(ignoreParentClass?: boolean): void;
  20146. /**
  20147. * @hidden
  20148. * Get current device position in babylon world
  20149. */
  20150. _computeDevicePosition(): void;
  20151. /**
  20152. * Updates the current device position and rotation in the babylon world
  20153. */
  20154. update(): void;
  20155. /**
  20156. * @hidden
  20157. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20158. * @returns an identity matrix
  20159. */
  20160. _getViewMatrix(): Matrix;
  20161. private _tmpMatrix;
  20162. /**
  20163. * This function is called by the two RIG cameras.
  20164. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20165. * @hidden
  20166. */
  20167. _getWebVRViewMatrix(): Matrix;
  20168. /** @hidden */
  20169. _getWebVRProjectionMatrix(): Matrix;
  20170. private _onGamepadConnectedObserver;
  20171. private _onGamepadDisconnectedObserver;
  20172. private _updateCacheWhenTrackingDisabledObserver;
  20173. /**
  20174. * Initializes the controllers and their meshes
  20175. */
  20176. initControllers(): void;
  20177. }
  20178. }
  20179. declare module BABYLON {
  20180. /**
  20181. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20182. *
  20183. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20184. *
  20185. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20186. */
  20187. export class MaterialHelper {
  20188. /**
  20189. * Bind the current view position to an effect.
  20190. * @param effect The effect to be bound
  20191. * @param scene The scene the eyes position is used from
  20192. * @param variableName name of the shader variable that will hold the eye position
  20193. */
  20194. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20195. /**
  20196. * Helps preparing the defines values about the UVs in used in the effect.
  20197. * UVs are shared as much as we can accross channels in the shaders.
  20198. * @param texture The texture we are preparing the UVs for
  20199. * @param defines The defines to update
  20200. * @param key The channel key "diffuse", "specular"... used in the shader
  20201. */
  20202. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20203. /**
  20204. * Binds a texture matrix value to its corrsponding uniform
  20205. * @param texture The texture to bind the matrix for
  20206. * @param uniformBuffer The uniform buffer receivin the data
  20207. * @param key The channel key "diffuse", "specular"... used in the shader
  20208. */
  20209. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20210. /**
  20211. * Gets the current status of the fog (should it be enabled?)
  20212. * @param mesh defines the mesh to evaluate for fog support
  20213. * @param scene defines the hosting scene
  20214. * @returns true if fog must be enabled
  20215. */
  20216. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20217. /**
  20218. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20219. * @param mesh defines the current mesh
  20220. * @param scene defines the current scene
  20221. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20222. * @param pointsCloud defines if point cloud rendering has to be turned on
  20223. * @param fogEnabled defines if fog has to be turned on
  20224. * @param alphaTest defines if alpha testing has to be turned on
  20225. * @param defines defines the current list of defines
  20226. */
  20227. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20228. /**
  20229. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20230. * @param scene defines the current scene
  20231. * @param engine defines the current engine
  20232. * @param defines specifies the list of active defines
  20233. * @param useInstances defines if instances have to be turned on
  20234. * @param useClipPlane defines if clip plane have to be turned on
  20235. * @param useInstances defines if instances have to be turned on
  20236. * @param useThinInstances defines if thin instances have to be turned on
  20237. */
  20238. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20239. /**
  20240. * Prepares the defines for bones
  20241. * @param mesh The mesh containing the geometry data we will draw
  20242. * @param defines The defines to update
  20243. */
  20244. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20245. /**
  20246. * Prepares the defines for morph targets
  20247. * @param mesh The mesh containing the geometry data we will draw
  20248. * @param defines The defines to update
  20249. */
  20250. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20251. /**
  20252. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20253. * @param mesh The mesh containing the geometry data we will draw
  20254. * @param defines The defines to update
  20255. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20256. * @param useBones Precise whether bones should be used or not (override mesh info)
  20257. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20258. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20259. * @returns false if defines are considered not dirty and have not been checked
  20260. */
  20261. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20262. /**
  20263. * Prepares the defines related to multiview
  20264. * @param scene The scene we are intending to draw
  20265. * @param defines The defines to update
  20266. */
  20267. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20268. /**
  20269. * Prepares the defines related to the prepass
  20270. * @param scene The scene we are intending to draw
  20271. * @param defines The defines to update
  20272. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20273. */
  20274. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20275. /**
  20276. * Prepares the defines related to the light information passed in parameter
  20277. * @param scene The scene we are intending to draw
  20278. * @param mesh The mesh the effect is compiling for
  20279. * @param light The light the effect is compiling for
  20280. * @param lightIndex The index of the light
  20281. * @param defines The defines to update
  20282. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20283. * @param state Defines the current state regarding what is needed (normals, etc...)
  20284. */
  20285. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20286. needNormals: boolean;
  20287. needRebuild: boolean;
  20288. shadowEnabled: boolean;
  20289. specularEnabled: boolean;
  20290. lightmapMode: boolean;
  20291. }): void;
  20292. /**
  20293. * Prepares the defines related to the light information passed in parameter
  20294. * @param scene The scene we are intending to draw
  20295. * @param mesh The mesh the effect is compiling for
  20296. * @param defines The defines to update
  20297. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20298. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20299. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20300. * @returns true if normals will be required for the rest of the effect
  20301. */
  20302. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20303. /**
  20304. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20305. * @param lightIndex defines the light index
  20306. * @param uniformsList The uniform list
  20307. * @param samplersList The sampler list
  20308. * @param projectedLightTexture defines if projected texture must be used
  20309. * @param uniformBuffersList defines an optional list of uniform buffers
  20310. */
  20311. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20312. /**
  20313. * Prepares the uniforms and samplers list to be used in the effect
  20314. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20315. * @param samplersList The sampler list
  20316. * @param defines The defines helping in the list generation
  20317. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20318. */
  20319. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20320. /**
  20321. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20322. * @param defines The defines to update while falling back
  20323. * @param fallbacks The authorized effect fallbacks
  20324. * @param maxSimultaneousLights The maximum number of lights allowed
  20325. * @param rank the current rank of the Effect
  20326. * @returns The newly affected rank
  20327. */
  20328. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20329. private static _TmpMorphInfluencers;
  20330. /**
  20331. * Prepares the list of attributes required for morph targets according to the effect defines.
  20332. * @param attribs The current list of supported attribs
  20333. * @param mesh The mesh to prepare the morph targets attributes for
  20334. * @param influencers The number of influencers
  20335. */
  20336. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20337. /**
  20338. * Prepares the list of attributes required for morph targets according to the effect defines.
  20339. * @param attribs The current list of supported attribs
  20340. * @param mesh The mesh to prepare the morph targets attributes for
  20341. * @param defines The current Defines of the effect
  20342. */
  20343. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20344. /**
  20345. * Prepares the list of attributes required for bones according to the effect defines.
  20346. * @param attribs The current list of supported attribs
  20347. * @param mesh The mesh to prepare the bones attributes for
  20348. * @param defines The current Defines of the effect
  20349. * @param fallbacks The current efffect fallback strategy
  20350. */
  20351. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20352. /**
  20353. * Check and prepare the list of attributes required for instances according to the effect defines.
  20354. * @param attribs The current list of supported attribs
  20355. * @param defines The current MaterialDefines of the effect
  20356. */
  20357. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20358. /**
  20359. * Add the list of attributes required for instances to the attribs array.
  20360. * @param attribs The current list of supported attribs
  20361. */
  20362. static PushAttributesForInstances(attribs: string[]): void;
  20363. /**
  20364. * Binds the light information to the effect.
  20365. * @param light The light containing the generator
  20366. * @param effect The effect we are binding the data to
  20367. * @param lightIndex The light index in the effect used to render
  20368. */
  20369. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20370. /**
  20371. * Binds the lights information from the scene to the effect for the given mesh.
  20372. * @param light Light to bind
  20373. * @param lightIndex Light index
  20374. * @param scene The scene where the light belongs to
  20375. * @param effect The effect we are binding the data to
  20376. * @param useSpecular Defines if specular is supported
  20377. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20378. */
  20379. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20380. /**
  20381. * Binds the lights information from the scene to the effect for the given mesh.
  20382. * @param scene The scene the lights belongs to
  20383. * @param mesh The mesh we are binding the information to render
  20384. * @param effect The effect we are binding the data to
  20385. * @param defines The generated defines for the effect
  20386. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20387. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20388. */
  20389. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20390. private static _tempFogColor;
  20391. /**
  20392. * Binds the fog information from the scene to the effect for the given mesh.
  20393. * @param scene The scene the lights belongs to
  20394. * @param mesh The mesh we are binding the information to render
  20395. * @param effect The effect we are binding the data to
  20396. * @param linearSpace Defines if the fog effect is applied in linear space
  20397. */
  20398. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20399. /**
  20400. * Binds the bones information from the mesh to the effect.
  20401. * @param mesh The mesh we are binding the information to render
  20402. * @param effect The effect we are binding the data to
  20403. */
  20404. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20405. /**
  20406. * Binds the morph targets information from the mesh to the effect.
  20407. * @param abstractMesh The mesh we are binding the information to render
  20408. * @param effect The effect we are binding the data to
  20409. */
  20410. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20411. /**
  20412. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20413. * @param defines The generated defines used in the effect
  20414. * @param effect The effect we are binding the data to
  20415. * @param scene The scene we are willing to render with logarithmic scale for
  20416. */
  20417. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20418. /**
  20419. * Binds the clip plane information from the scene to the effect.
  20420. * @param scene The scene the clip plane information are extracted from
  20421. * @param effect The effect we are binding the data to
  20422. */
  20423. static BindClipPlane(effect: Effect, scene: Scene): void;
  20424. }
  20425. }
  20426. declare module BABYLON {
  20427. /**
  20428. * Block used to expose an input value
  20429. */
  20430. export class InputBlock extends NodeMaterialBlock {
  20431. private _mode;
  20432. private _associatedVariableName;
  20433. private _storedValue;
  20434. private _valueCallback;
  20435. private _type;
  20436. private _animationType;
  20437. /** Gets or set a value used to limit the range of float values */
  20438. min: number;
  20439. /** Gets or set a value used to limit the range of float values */
  20440. max: number;
  20441. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20442. isBoolean: boolean;
  20443. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20444. matrixMode: number;
  20445. /** @hidden */
  20446. _systemValue: Nullable<NodeMaterialSystemValues>;
  20447. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20448. visibleInInspector: boolean;
  20449. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20450. isConstant: boolean;
  20451. /** Gets or sets the group to use to display this block in the Inspector */
  20452. groupInInspector: string;
  20453. /** Gets an observable raised when the value is changed */
  20454. onValueChangedObservable: Observable<InputBlock>;
  20455. /**
  20456. * Gets or sets the connection point type (default is float)
  20457. */
  20458. get type(): NodeMaterialBlockConnectionPointTypes;
  20459. /**
  20460. * Creates a new InputBlock
  20461. * @param name defines the block name
  20462. * @param target defines the target of that block (Vertex by default)
  20463. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20464. */
  20465. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20466. /**
  20467. * Validates if a name is a reserve word.
  20468. * @param newName the new name to be given to the node.
  20469. * @returns false if the name is a reserve word, else true.
  20470. */
  20471. validateBlockName(newName: string): boolean;
  20472. /**
  20473. * Gets the output component
  20474. */
  20475. get output(): NodeMaterialConnectionPoint;
  20476. /**
  20477. * Set the source of this connection point to a vertex attribute
  20478. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20479. * @returns the current connection point
  20480. */
  20481. setAsAttribute(attributeName?: string): InputBlock;
  20482. /**
  20483. * Set the source of this connection point to a system value
  20484. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20485. * @returns the current connection point
  20486. */
  20487. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20488. /**
  20489. * Gets or sets the value of that point.
  20490. * Please note that this value will be ignored if valueCallback is defined
  20491. */
  20492. get value(): any;
  20493. set value(value: any);
  20494. /**
  20495. * Gets or sets a callback used to get the value of that point.
  20496. * Please note that setting this value will force the connection point to ignore the value property
  20497. */
  20498. get valueCallback(): () => any;
  20499. set valueCallback(value: () => any);
  20500. /**
  20501. * Gets or sets the associated variable name in the shader
  20502. */
  20503. get associatedVariableName(): string;
  20504. set associatedVariableName(value: string);
  20505. /** Gets or sets the type of animation applied to the input */
  20506. get animationType(): AnimatedInputBlockTypes;
  20507. set animationType(value: AnimatedInputBlockTypes);
  20508. /**
  20509. * Gets a boolean indicating that this connection point not defined yet
  20510. */
  20511. get isUndefined(): boolean;
  20512. /**
  20513. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20514. * In this case the connection point name must be the name of the uniform to use.
  20515. * Can only be set on inputs
  20516. */
  20517. get isUniform(): boolean;
  20518. set isUniform(value: boolean);
  20519. /**
  20520. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20521. * In this case the connection point name must be the name of the attribute to use
  20522. * Can only be set on inputs
  20523. */
  20524. get isAttribute(): boolean;
  20525. set isAttribute(value: boolean);
  20526. /**
  20527. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20528. * Can only be set on exit points
  20529. */
  20530. get isVarying(): boolean;
  20531. set isVarying(value: boolean);
  20532. /**
  20533. * Gets a boolean indicating that the current connection point is a system value
  20534. */
  20535. get isSystemValue(): boolean;
  20536. /**
  20537. * Gets or sets the current well known value or null if not defined as a system value
  20538. */
  20539. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20540. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20541. /**
  20542. * Gets the current class name
  20543. * @returns the class name
  20544. */
  20545. getClassName(): string;
  20546. /**
  20547. * Animate the input if animationType !== None
  20548. * @param scene defines the rendering scene
  20549. */
  20550. animate(scene: Scene): void;
  20551. private _emitDefine;
  20552. initialize(state: NodeMaterialBuildState): void;
  20553. /**
  20554. * Set the input block to its default value (based on its type)
  20555. */
  20556. setDefaultValue(): void;
  20557. private _emitConstant;
  20558. /** @hidden */
  20559. get _noContextSwitch(): boolean;
  20560. private _emit;
  20561. /** @hidden */
  20562. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20563. /** @hidden */
  20564. _transmit(effect: Effect, scene: Scene): void;
  20565. protected _buildBlock(state: NodeMaterialBuildState): void;
  20566. protected _dumpPropertiesCode(): string;
  20567. dispose(): void;
  20568. serialize(): any;
  20569. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20570. }
  20571. }
  20572. declare module BABYLON {
  20573. /**
  20574. * Enum used to define the compatibility state between two connection points
  20575. */
  20576. export enum NodeMaterialConnectionPointCompatibilityStates {
  20577. /** Points are compatibles */
  20578. Compatible = 0,
  20579. /** Points are incompatible because of their types */
  20580. TypeIncompatible = 1,
  20581. /** Points are incompatible because of their targets (vertex vs fragment) */
  20582. TargetIncompatible = 2
  20583. }
  20584. /**
  20585. * Defines the direction of a connection point
  20586. */
  20587. export enum NodeMaterialConnectionPointDirection {
  20588. /** Input */
  20589. Input = 0,
  20590. /** Output */
  20591. Output = 1
  20592. }
  20593. /**
  20594. * Defines a connection point for a block
  20595. */
  20596. export class NodeMaterialConnectionPoint {
  20597. /** @hidden */
  20598. _ownerBlock: NodeMaterialBlock;
  20599. /** @hidden */
  20600. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20601. private _endpoints;
  20602. private _associatedVariableName;
  20603. private _direction;
  20604. /** @hidden */
  20605. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20606. /** @hidden */
  20607. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20608. private _type;
  20609. /** @hidden */
  20610. _enforceAssociatedVariableName: boolean;
  20611. /** Gets the direction of the point */
  20612. get direction(): NodeMaterialConnectionPointDirection;
  20613. /** Indicates that this connection point needs dual validation before being connected to another point */
  20614. needDualDirectionValidation: boolean;
  20615. /**
  20616. * Gets or sets the additional types supported by this connection point
  20617. */
  20618. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20619. /**
  20620. * Gets or sets the additional types excluded by this connection point
  20621. */
  20622. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20623. /**
  20624. * Observable triggered when this point is connected
  20625. */
  20626. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20627. /**
  20628. * Gets or sets the associated variable name in the shader
  20629. */
  20630. get associatedVariableName(): string;
  20631. set associatedVariableName(value: string);
  20632. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20633. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20634. /**
  20635. * Gets or sets the connection point type (default is float)
  20636. */
  20637. get type(): NodeMaterialBlockConnectionPointTypes;
  20638. set type(value: NodeMaterialBlockConnectionPointTypes);
  20639. /**
  20640. * Gets or sets the connection point name
  20641. */
  20642. name: string;
  20643. /**
  20644. * Gets or sets the connection point name
  20645. */
  20646. displayName: string;
  20647. /**
  20648. * Gets or sets a boolean indicating that this connection point can be omitted
  20649. */
  20650. isOptional: boolean;
  20651. /**
  20652. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20653. */
  20654. isExposedOnFrame: boolean;
  20655. /**
  20656. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20657. */
  20658. define: string;
  20659. /** @hidden */
  20660. _prioritizeVertex: boolean;
  20661. private _target;
  20662. /** Gets or sets the target of that connection point */
  20663. get target(): NodeMaterialBlockTargets;
  20664. set target(value: NodeMaterialBlockTargets);
  20665. /**
  20666. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20667. */
  20668. get isConnected(): boolean;
  20669. /**
  20670. * Gets a boolean indicating that the current point is connected to an input block
  20671. */
  20672. get isConnectedToInputBlock(): boolean;
  20673. /**
  20674. * Gets a the connected input block (if any)
  20675. */
  20676. get connectInputBlock(): Nullable<InputBlock>;
  20677. /** Get the other side of the connection (if any) */
  20678. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20679. /** Get the block that owns this connection point */
  20680. get ownerBlock(): NodeMaterialBlock;
  20681. /** Get the block connected on the other side of this connection (if any) */
  20682. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20683. /** Get the block connected on the endpoints of this connection (if any) */
  20684. get connectedBlocks(): Array<NodeMaterialBlock>;
  20685. /** Gets the list of connected endpoints */
  20686. get endpoints(): NodeMaterialConnectionPoint[];
  20687. /** Gets a boolean indicating if that output point is connected to at least one input */
  20688. get hasEndpoints(): boolean;
  20689. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20690. get isConnectedInVertexShader(): boolean;
  20691. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20692. get isConnectedInFragmentShader(): boolean;
  20693. /**
  20694. * Creates a block suitable to be used as an input for this input point.
  20695. * If null is returned, a block based on the point type will be created.
  20696. * @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
  20697. */
  20698. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20699. /**
  20700. * Creates a new connection point
  20701. * @param name defines the connection point name
  20702. * @param ownerBlock defines the block hosting this connection point
  20703. * @param direction defines the direction of the connection point
  20704. */
  20705. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20706. /**
  20707. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20708. * @returns the class name
  20709. */
  20710. getClassName(): string;
  20711. /**
  20712. * Gets a boolean indicating if the current point can be connected to another point
  20713. * @param connectionPoint defines the other connection point
  20714. * @returns a boolean
  20715. */
  20716. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20717. /**
  20718. * Gets a number indicating if the current point can be connected to another point
  20719. * @param connectionPoint defines the other connection point
  20720. * @returns a number defining the compatibility state
  20721. */
  20722. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20723. /**
  20724. * Connect this point to another connection point
  20725. * @param connectionPoint defines the other connection point
  20726. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20727. * @returns the current connection point
  20728. */
  20729. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20730. /**
  20731. * Disconnect this point from one of his endpoint
  20732. * @param endpoint defines the other connection point
  20733. * @returns the current connection point
  20734. */
  20735. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20736. /**
  20737. * Serializes this point in a JSON representation
  20738. * @param isInput defines if the connection point is an input (default is true)
  20739. * @returns the serialized point object
  20740. */
  20741. serialize(isInput?: boolean): any;
  20742. /**
  20743. * Release resources
  20744. */
  20745. dispose(): void;
  20746. }
  20747. }
  20748. declare module BABYLON {
  20749. /**
  20750. * Enum used to define the material modes
  20751. */
  20752. export enum NodeMaterialModes {
  20753. /** Regular material */
  20754. Material = 0,
  20755. /** For post process */
  20756. PostProcess = 1,
  20757. /** For particle system */
  20758. Particle = 2
  20759. }
  20760. }
  20761. declare module BABYLON {
  20762. /**
  20763. * Block used to read a texture from a sampler
  20764. */
  20765. export class TextureBlock extends NodeMaterialBlock {
  20766. private _defineName;
  20767. private _linearDefineName;
  20768. private _gammaDefineName;
  20769. private _tempTextureRead;
  20770. private _samplerName;
  20771. private _transformedUVName;
  20772. private _textureTransformName;
  20773. private _textureInfoName;
  20774. private _mainUVName;
  20775. private _mainUVDefineName;
  20776. private _fragmentOnly;
  20777. /**
  20778. * Gets or sets the texture associated with the node
  20779. */
  20780. texture: Nullable<Texture>;
  20781. /**
  20782. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20783. */
  20784. convertToGammaSpace: boolean;
  20785. /**
  20786. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20787. */
  20788. convertToLinearSpace: boolean;
  20789. /**
  20790. * Create a new TextureBlock
  20791. * @param name defines the block name
  20792. */
  20793. constructor(name: string, fragmentOnly?: boolean);
  20794. /**
  20795. * Gets the current class name
  20796. * @returns the class name
  20797. */
  20798. getClassName(): string;
  20799. /**
  20800. * Gets the uv input component
  20801. */
  20802. get uv(): NodeMaterialConnectionPoint;
  20803. /**
  20804. * Gets the rgba output component
  20805. */
  20806. get rgba(): NodeMaterialConnectionPoint;
  20807. /**
  20808. * Gets the rgb output component
  20809. */
  20810. get rgb(): NodeMaterialConnectionPoint;
  20811. /**
  20812. * Gets the r output component
  20813. */
  20814. get r(): NodeMaterialConnectionPoint;
  20815. /**
  20816. * Gets the g output component
  20817. */
  20818. get g(): NodeMaterialConnectionPoint;
  20819. /**
  20820. * Gets the b output component
  20821. */
  20822. get b(): NodeMaterialConnectionPoint;
  20823. /**
  20824. * Gets the a output component
  20825. */
  20826. get a(): NodeMaterialConnectionPoint;
  20827. get target(): NodeMaterialBlockTargets;
  20828. autoConfigure(material: NodeMaterial): void;
  20829. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20830. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20831. isReady(): boolean;
  20832. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20833. private get _isMixed();
  20834. private _injectVertexCode;
  20835. private _writeTextureRead;
  20836. private _writeOutput;
  20837. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20838. protected _dumpPropertiesCode(): string;
  20839. serialize(): any;
  20840. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20841. }
  20842. }
  20843. declare module BABYLON {
  20844. /** @hidden */
  20845. export var reflectionFunction: {
  20846. name: string;
  20847. shader: string;
  20848. };
  20849. }
  20850. declare module BABYLON {
  20851. /**
  20852. * Base block used to read a reflection texture from a sampler
  20853. */
  20854. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20855. /** @hidden */
  20856. _define3DName: string;
  20857. /** @hidden */
  20858. _defineCubicName: string;
  20859. /** @hidden */
  20860. _defineExplicitName: string;
  20861. /** @hidden */
  20862. _defineProjectionName: string;
  20863. /** @hidden */
  20864. _defineLocalCubicName: string;
  20865. /** @hidden */
  20866. _defineSphericalName: string;
  20867. /** @hidden */
  20868. _definePlanarName: string;
  20869. /** @hidden */
  20870. _defineEquirectangularName: string;
  20871. /** @hidden */
  20872. _defineMirroredEquirectangularFixedName: string;
  20873. /** @hidden */
  20874. _defineEquirectangularFixedName: string;
  20875. /** @hidden */
  20876. _defineSkyboxName: string;
  20877. /** @hidden */
  20878. _defineOppositeZ: string;
  20879. /** @hidden */
  20880. _cubeSamplerName: string;
  20881. /** @hidden */
  20882. _2DSamplerName: string;
  20883. protected _positionUVWName: string;
  20884. protected _directionWName: string;
  20885. protected _reflectionVectorName: string;
  20886. /** @hidden */
  20887. _reflectionCoordsName: string;
  20888. /** @hidden */
  20889. _reflectionMatrixName: string;
  20890. protected _reflectionColorName: string;
  20891. /**
  20892. * Gets or sets the texture associated with the node
  20893. */
  20894. texture: Nullable<BaseTexture>;
  20895. /**
  20896. * Create a new ReflectionTextureBaseBlock
  20897. * @param name defines the block name
  20898. */
  20899. constructor(name: string);
  20900. /**
  20901. * Gets the current class name
  20902. * @returns the class name
  20903. */
  20904. getClassName(): string;
  20905. /**
  20906. * Gets the world position input component
  20907. */
  20908. abstract get position(): NodeMaterialConnectionPoint;
  20909. /**
  20910. * Gets the world position input component
  20911. */
  20912. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20913. /**
  20914. * Gets the world normal input component
  20915. */
  20916. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20917. /**
  20918. * Gets the world input component
  20919. */
  20920. abstract get world(): NodeMaterialConnectionPoint;
  20921. /**
  20922. * Gets the camera (or eye) position component
  20923. */
  20924. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20925. /**
  20926. * Gets the view input component
  20927. */
  20928. abstract get view(): NodeMaterialConnectionPoint;
  20929. protected _getTexture(): Nullable<BaseTexture>;
  20930. autoConfigure(material: NodeMaterial): void;
  20931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20932. isReady(): boolean;
  20933. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20934. /**
  20935. * Gets the code to inject in the vertex shader
  20936. * @param state current state of the node material building
  20937. * @returns the shader code
  20938. */
  20939. handleVertexSide(state: NodeMaterialBuildState): string;
  20940. /**
  20941. * Handles the inits for the fragment code path
  20942. * @param state node material build state
  20943. */
  20944. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20945. /**
  20946. * Generates the reflection coords code for the fragment code path
  20947. * @param worldNormalVarName name of the world normal variable
  20948. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20949. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20950. * @returns the shader code
  20951. */
  20952. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20953. /**
  20954. * Generates the reflection color code for the fragment code path
  20955. * @param lodVarName name of the lod variable
  20956. * @param swizzleLookupTexture swizzle to use for the final color variable
  20957. * @returns the shader code
  20958. */
  20959. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20960. /**
  20961. * Generates the code corresponding to the connected output points
  20962. * @param state node material build state
  20963. * @param varName name of the variable to output
  20964. * @returns the shader code
  20965. */
  20966. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20967. protected _buildBlock(state: NodeMaterialBuildState): this;
  20968. protected _dumpPropertiesCode(): string;
  20969. serialize(): any;
  20970. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20971. }
  20972. }
  20973. declare module BABYLON {
  20974. /**
  20975. * Defines a connection point to be used for points with a custom object type
  20976. */
  20977. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20978. private _blockType;
  20979. private _blockName;
  20980. private _nameForCheking?;
  20981. /**
  20982. * Creates a new connection point
  20983. * @param name defines the connection point name
  20984. * @param ownerBlock defines the block hosting this connection point
  20985. * @param direction defines the direction of the connection point
  20986. */
  20987. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20988. /**
  20989. * Gets a number indicating if the current point can be connected to another point
  20990. * @param connectionPoint defines the other connection point
  20991. * @returns a number defining the compatibility state
  20992. */
  20993. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20994. /**
  20995. * Creates a block suitable to be used as an input for this input point.
  20996. * If null is returned, a block based on the point type will be created.
  20997. * @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
  20998. */
  20999. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21000. }
  21001. }
  21002. declare module BABYLON {
  21003. /**
  21004. * Enum defining the type of properties that can be edited in the property pages in the NME
  21005. */
  21006. export enum PropertyTypeForEdition {
  21007. /** property is a boolean */
  21008. Boolean = 0,
  21009. /** property is a float */
  21010. Float = 1,
  21011. /** property is a Vector2 */
  21012. Vector2 = 2,
  21013. /** property is a list of values */
  21014. List = 3
  21015. }
  21016. /**
  21017. * Interface that defines an option in a variable of type list
  21018. */
  21019. export interface IEditablePropertyListOption {
  21020. /** label of the option */
  21021. "label": string;
  21022. /** value of the option */
  21023. "value": number;
  21024. }
  21025. /**
  21026. * Interface that defines the options available for an editable property
  21027. */
  21028. export interface IEditablePropertyOption {
  21029. /** min value */
  21030. "min"?: number;
  21031. /** max value */
  21032. "max"?: number;
  21033. /** notifiers: indicates which actions to take when the property is changed */
  21034. "notifiers"?: {
  21035. /** the material should be rebuilt */
  21036. "rebuild"?: boolean;
  21037. /** the preview should be updated */
  21038. "update"?: boolean;
  21039. };
  21040. /** list of the options for a variable of type list */
  21041. "options"?: IEditablePropertyListOption[];
  21042. }
  21043. /**
  21044. * Interface that describes an editable property
  21045. */
  21046. export interface IPropertyDescriptionForEdition {
  21047. /** name of the property */
  21048. "propertyName": string;
  21049. /** display name of the property */
  21050. "displayName": string;
  21051. /** type of the property */
  21052. "type": PropertyTypeForEdition;
  21053. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21054. "groupName": string;
  21055. /** options for the property */
  21056. "options": IEditablePropertyOption;
  21057. }
  21058. /**
  21059. * Decorator that flags a property in a node material block as being editable
  21060. */
  21061. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21062. }
  21063. declare module BABYLON {
  21064. /**
  21065. * Block used to implement the refraction part of the sub surface module of the PBR material
  21066. */
  21067. export class RefractionBlock extends NodeMaterialBlock {
  21068. /** @hidden */
  21069. _define3DName: string;
  21070. /** @hidden */
  21071. _refractionMatrixName: string;
  21072. /** @hidden */
  21073. _defineLODRefractionAlpha: string;
  21074. /** @hidden */
  21075. _defineLinearSpecularRefraction: string;
  21076. /** @hidden */
  21077. _defineOppositeZ: string;
  21078. /** @hidden */
  21079. _cubeSamplerName: string;
  21080. /** @hidden */
  21081. _2DSamplerName: string;
  21082. /** @hidden */
  21083. _vRefractionMicrosurfaceInfosName: string;
  21084. /** @hidden */
  21085. _vRefractionInfosName: string;
  21086. private _scene;
  21087. /**
  21088. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21089. * Materials half opaque for instance using refraction could benefit from this control.
  21090. */
  21091. linkRefractionWithTransparency: boolean;
  21092. /**
  21093. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21094. */
  21095. invertRefractionY: boolean;
  21096. /**
  21097. * Gets or sets the texture associated with the node
  21098. */
  21099. texture: Nullable<BaseTexture>;
  21100. /**
  21101. * Create a new RefractionBlock
  21102. * @param name defines the block name
  21103. */
  21104. constructor(name: string);
  21105. /**
  21106. * Gets the current class name
  21107. * @returns the class name
  21108. */
  21109. getClassName(): string;
  21110. /**
  21111. * Gets the intensity input component
  21112. */
  21113. get intensity(): NodeMaterialConnectionPoint;
  21114. /**
  21115. * Gets the index of refraction input component
  21116. */
  21117. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21118. /**
  21119. * Gets the tint at distance input component
  21120. */
  21121. get tintAtDistance(): NodeMaterialConnectionPoint;
  21122. /**
  21123. * Gets the view input component
  21124. */
  21125. get view(): NodeMaterialConnectionPoint;
  21126. /**
  21127. * Gets the refraction object output component
  21128. */
  21129. get refraction(): NodeMaterialConnectionPoint;
  21130. /**
  21131. * Returns true if the block has a texture
  21132. */
  21133. get hasTexture(): boolean;
  21134. protected _getTexture(): Nullable<BaseTexture>;
  21135. autoConfigure(material: NodeMaterial): void;
  21136. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21137. isReady(): boolean;
  21138. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21139. /**
  21140. * Gets the main code of the block (fragment side)
  21141. * @param state current state of the node material building
  21142. * @returns the shader code
  21143. */
  21144. getCode(state: NodeMaterialBuildState): string;
  21145. protected _buildBlock(state: NodeMaterialBuildState): this;
  21146. protected _dumpPropertiesCode(): string;
  21147. serialize(): any;
  21148. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21149. }
  21150. }
  21151. declare module BABYLON {
  21152. /**
  21153. * Base block used as input for post process
  21154. */
  21155. export class CurrentScreenBlock extends NodeMaterialBlock {
  21156. private _samplerName;
  21157. private _linearDefineName;
  21158. private _gammaDefineName;
  21159. private _mainUVName;
  21160. private _tempTextureRead;
  21161. /**
  21162. * Gets or sets the texture associated with the node
  21163. */
  21164. texture: Nullable<BaseTexture>;
  21165. /**
  21166. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21167. */
  21168. convertToGammaSpace: boolean;
  21169. /**
  21170. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21171. */
  21172. convertToLinearSpace: boolean;
  21173. /**
  21174. * Create a new CurrentScreenBlock
  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 uv input component
  21185. */
  21186. get uv(): NodeMaterialConnectionPoint;
  21187. /**
  21188. * Gets the rgba output component
  21189. */
  21190. get rgba(): NodeMaterialConnectionPoint;
  21191. /**
  21192. * Gets the rgb output component
  21193. */
  21194. get rgb(): NodeMaterialConnectionPoint;
  21195. /**
  21196. * Gets the r output component
  21197. */
  21198. get r(): NodeMaterialConnectionPoint;
  21199. /**
  21200. * Gets the g output component
  21201. */
  21202. get g(): NodeMaterialConnectionPoint;
  21203. /**
  21204. * Gets the b output component
  21205. */
  21206. get b(): NodeMaterialConnectionPoint;
  21207. /**
  21208. * Gets the a output component
  21209. */
  21210. get a(): NodeMaterialConnectionPoint;
  21211. /**
  21212. * Initialize the block and prepare the context for build
  21213. * @param state defines the state that will be used for the build
  21214. */
  21215. initialize(state: NodeMaterialBuildState): void;
  21216. get target(): NodeMaterialBlockTargets;
  21217. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21218. isReady(): boolean;
  21219. private _injectVertexCode;
  21220. private _writeTextureRead;
  21221. private _writeOutput;
  21222. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21223. serialize(): any;
  21224. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21225. }
  21226. }
  21227. declare module BABYLON {
  21228. /**
  21229. * Base block used for the particle texture
  21230. */
  21231. export class ParticleTextureBlock extends NodeMaterialBlock {
  21232. private _samplerName;
  21233. private _linearDefineName;
  21234. private _gammaDefineName;
  21235. private _tempTextureRead;
  21236. /**
  21237. * Gets or sets the texture associated with the node
  21238. */
  21239. texture: Nullable<BaseTexture>;
  21240. /**
  21241. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21242. */
  21243. convertToGammaSpace: boolean;
  21244. /**
  21245. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21246. */
  21247. convertToLinearSpace: boolean;
  21248. /**
  21249. * Create a new ParticleTextureBlock
  21250. * @param name defines the block name
  21251. */
  21252. constructor(name: string);
  21253. /**
  21254. * Gets the current class name
  21255. * @returns the class name
  21256. */
  21257. getClassName(): string;
  21258. /**
  21259. * Gets the uv input component
  21260. */
  21261. get uv(): NodeMaterialConnectionPoint;
  21262. /**
  21263. * Gets the rgba output component
  21264. */
  21265. get rgba(): NodeMaterialConnectionPoint;
  21266. /**
  21267. * Gets the rgb output component
  21268. */
  21269. get rgb(): NodeMaterialConnectionPoint;
  21270. /**
  21271. * Gets the r output component
  21272. */
  21273. get r(): NodeMaterialConnectionPoint;
  21274. /**
  21275. * Gets the g output component
  21276. */
  21277. get g(): NodeMaterialConnectionPoint;
  21278. /**
  21279. * Gets the b output component
  21280. */
  21281. get b(): NodeMaterialConnectionPoint;
  21282. /**
  21283. * Gets the a output component
  21284. */
  21285. get a(): NodeMaterialConnectionPoint;
  21286. /**
  21287. * Initialize the block and prepare the context for build
  21288. * @param state defines the state that will be used for the build
  21289. */
  21290. initialize(state: NodeMaterialBuildState): void;
  21291. autoConfigure(material: NodeMaterial): void;
  21292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21293. isReady(): boolean;
  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. * Class used to store shared data between 2 NodeMaterialBuildState
  21303. */
  21304. export class NodeMaterialBuildStateSharedData {
  21305. /**
  21306. * Gets the list of emitted varyings
  21307. */
  21308. temps: string[];
  21309. /**
  21310. * Gets the list of emitted varyings
  21311. */
  21312. varyings: string[];
  21313. /**
  21314. * Gets the varying declaration string
  21315. */
  21316. varyingDeclaration: string;
  21317. /**
  21318. * Input blocks
  21319. */
  21320. inputBlocks: InputBlock[];
  21321. /**
  21322. * Input blocks
  21323. */
  21324. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21325. /**
  21326. * Bindable blocks (Blocks that need to set data to the effect)
  21327. */
  21328. bindableBlocks: NodeMaterialBlock[];
  21329. /**
  21330. * List of blocks that can provide a compilation fallback
  21331. */
  21332. blocksWithFallbacks: NodeMaterialBlock[];
  21333. /**
  21334. * List of blocks that can provide a define update
  21335. */
  21336. blocksWithDefines: NodeMaterialBlock[];
  21337. /**
  21338. * List of blocks that can provide a repeatable content
  21339. */
  21340. repeatableContentBlocks: NodeMaterialBlock[];
  21341. /**
  21342. * List of blocks that can provide a dynamic list of uniforms
  21343. */
  21344. dynamicUniformBlocks: NodeMaterialBlock[];
  21345. /**
  21346. * List of blocks that can block the isReady function for the material
  21347. */
  21348. blockingBlocks: NodeMaterialBlock[];
  21349. /**
  21350. * Gets the list of animated inputs
  21351. */
  21352. animatedInputs: InputBlock[];
  21353. /**
  21354. * Build Id used to avoid multiple recompilations
  21355. */
  21356. buildId: number;
  21357. /** List of emitted variables */
  21358. variableNames: {
  21359. [key: string]: number;
  21360. };
  21361. /** List of emitted defines */
  21362. defineNames: {
  21363. [key: string]: number;
  21364. };
  21365. /** Should emit comments? */
  21366. emitComments: boolean;
  21367. /** Emit build activity */
  21368. verbose: boolean;
  21369. /** Gets or sets the hosting scene */
  21370. scene: Scene;
  21371. /**
  21372. * Gets the compilation hints emitted at compilation time
  21373. */
  21374. hints: {
  21375. needWorldViewMatrix: boolean;
  21376. needWorldViewProjectionMatrix: boolean;
  21377. needAlphaBlending: boolean;
  21378. needAlphaTesting: boolean;
  21379. };
  21380. /**
  21381. * List of compilation checks
  21382. */
  21383. checks: {
  21384. emitVertex: boolean;
  21385. emitFragment: boolean;
  21386. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21387. };
  21388. /**
  21389. * Is vertex program allowed to be empty?
  21390. */
  21391. allowEmptyVertexProgram: boolean;
  21392. /** Creates a new shared data */
  21393. constructor();
  21394. /**
  21395. * Emits console errors and exceptions if there is a failing check
  21396. */
  21397. emitErrors(): void;
  21398. }
  21399. }
  21400. declare module BABYLON {
  21401. /**
  21402. * Class used to store node based material build state
  21403. */
  21404. export class NodeMaterialBuildState {
  21405. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21406. supportUniformBuffers: boolean;
  21407. /**
  21408. * Gets the list of emitted attributes
  21409. */
  21410. attributes: string[];
  21411. /**
  21412. * Gets the list of emitted uniforms
  21413. */
  21414. uniforms: string[];
  21415. /**
  21416. * Gets the list of emitted constants
  21417. */
  21418. constants: string[];
  21419. /**
  21420. * Gets the list of emitted samplers
  21421. */
  21422. samplers: string[];
  21423. /**
  21424. * Gets the list of emitted functions
  21425. */
  21426. functions: {
  21427. [key: string]: string;
  21428. };
  21429. /**
  21430. * Gets the list of emitted extensions
  21431. */
  21432. extensions: {
  21433. [key: string]: string;
  21434. };
  21435. /**
  21436. * Gets the target of the compilation state
  21437. */
  21438. target: NodeMaterialBlockTargets;
  21439. /**
  21440. * Gets the list of emitted counters
  21441. */
  21442. counters: {
  21443. [key: string]: number;
  21444. };
  21445. /**
  21446. * Shared data between multiple NodeMaterialBuildState instances
  21447. */
  21448. sharedData: NodeMaterialBuildStateSharedData;
  21449. /** @hidden */
  21450. _vertexState: NodeMaterialBuildState;
  21451. /** @hidden */
  21452. _attributeDeclaration: string;
  21453. /** @hidden */
  21454. _uniformDeclaration: string;
  21455. /** @hidden */
  21456. _constantDeclaration: string;
  21457. /** @hidden */
  21458. _samplerDeclaration: string;
  21459. /** @hidden */
  21460. _varyingTransfer: string;
  21461. /** @hidden */
  21462. _injectAtEnd: string;
  21463. private _repeatableContentAnchorIndex;
  21464. /** @hidden */
  21465. _builtCompilationString: string;
  21466. /**
  21467. * Gets the emitted compilation strings
  21468. */
  21469. compilationString: string;
  21470. /**
  21471. * Finalize the compilation strings
  21472. * @param state defines the current compilation state
  21473. */
  21474. finalize(state: NodeMaterialBuildState): void;
  21475. /** @hidden */
  21476. get _repeatableContentAnchor(): string;
  21477. /** @hidden */
  21478. _getFreeVariableName(prefix: string): string;
  21479. /** @hidden */
  21480. _getFreeDefineName(prefix: string): string;
  21481. /** @hidden */
  21482. _excludeVariableName(name: string): void;
  21483. /** @hidden */
  21484. _emit2DSampler(name: string): void;
  21485. /** @hidden */
  21486. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21487. /** @hidden */
  21488. _emitExtension(name: string, extension: string, define?: string): void;
  21489. /** @hidden */
  21490. _emitFunction(name: string, code: string, comments: string): void;
  21491. /** @hidden */
  21492. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21493. replaceStrings?: {
  21494. search: RegExp;
  21495. replace: string;
  21496. }[];
  21497. repeatKey?: string;
  21498. }): string;
  21499. /** @hidden */
  21500. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21501. repeatKey?: string;
  21502. removeAttributes?: boolean;
  21503. removeUniforms?: boolean;
  21504. removeVaryings?: boolean;
  21505. removeIfDef?: boolean;
  21506. replaceStrings?: {
  21507. search: RegExp;
  21508. replace: string;
  21509. }[];
  21510. }, storeKey?: string): void;
  21511. /** @hidden */
  21512. _registerTempVariable(name: string): boolean;
  21513. /** @hidden */
  21514. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21515. /** @hidden */
  21516. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21517. /** @hidden */
  21518. _emitFloat(value: number): string;
  21519. }
  21520. }
  21521. declare module BABYLON {
  21522. /**
  21523. * Helper class used to generate session unique ID
  21524. */
  21525. export class UniqueIdGenerator {
  21526. private static _UniqueIdCounter;
  21527. /**
  21528. * Gets an unique (relatively to the current scene) Id
  21529. */
  21530. static get UniqueId(): number;
  21531. }
  21532. }
  21533. declare module BABYLON {
  21534. /**
  21535. * Defines a block that can be used inside a node based material
  21536. */
  21537. export class NodeMaterialBlock {
  21538. private _buildId;
  21539. private _buildTarget;
  21540. private _target;
  21541. private _isFinalMerger;
  21542. private _isInput;
  21543. private _name;
  21544. protected _isUnique: boolean;
  21545. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21546. inputsAreExclusive: boolean;
  21547. /** @hidden */
  21548. _codeVariableName: string;
  21549. /** @hidden */
  21550. _inputs: NodeMaterialConnectionPoint[];
  21551. /** @hidden */
  21552. _outputs: NodeMaterialConnectionPoint[];
  21553. /** @hidden */
  21554. _preparationId: number;
  21555. /**
  21556. * Gets the name of the block
  21557. */
  21558. get name(): string;
  21559. /**
  21560. * Sets the name of the block. Will check if the name is valid.
  21561. */
  21562. set name(newName: string);
  21563. /**
  21564. * Gets or sets the unique id of the node
  21565. */
  21566. uniqueId: number;
  21567. /**
  21568. * Gets or sets the comments associated with this block
  21569. */
  21570. comments: string;
  21571. /**
  21572. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21573. */
  21574. get isUnique(): boolean;
  21575. /**
  21576. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21577. */
  21578. get isFinalMerger(): boolean;
  21579. /**
  21580. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21581. */
  21582. get isInput(): boolean;
  21583. /**
  21584. * Gets or sets the build Id
  21585. */
  21586. get buildId(): number;
  21587. set buildId(value: number);
  21588. /**
  21589. * Gets or sets the target of the block
  21590. */
  21591. get target(): NodeMaterialBlockTargets;
  21592. set target(value: NodeMaterialBlockTargets);
  21593. /**
  21594. * Gets the list of input points
  21595. */
  21596. get inputs(): NodeMaterialConnectionPoint[];
  21597. /** Gets the list of output points */
  21598. get outputs(): NodeMaterialConnectionPoint[];
  21599. /**
  21600. * Find an input by its name
  21601. * @param name defines the name of the input to look for
  21602. * @returns the input or null if not found
  21603. */
  21604. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21605. /**
  21606. * Find an output by its name
  21607. * @param name defines the name of the outputto look for
  21608. * @returns the output or null if not found
  21609. */
  21610. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21611. /**
  21612. * Creates a new NodeMaterialBlock
  21613. * @param name defines the block name
  21614. * @param target defines the target of that block (Vertex by default)
  21615. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21616. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21617. */
  21618. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21619. /**
  21620. * Initialize the block and prepare the context for build
  21621. * @param state defines the state that will be used for the build
  21622. */
  21623. initialize(state: NodeMaterialBuildState): void;
  21624. /**
  21625. * Bind data to effect. Will only be called for blocks with isBindable === true
  21626. * @param effect defines the effect to bind data to
  21627. * @param nodeMaterial defines the hosting NodeMaterial
  21628. * @param mesh defines the mesh that will be rendered
  21629. * @param subMesh defines the submesh that will be rendered
  21630. */
  21631. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21632. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21633. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21634. protected _writeFloat(value: number): string;
  21635. /**
  21636. * Gets the current class name e.g. "NodeMaterialBlock"
  21637. * @returns the class name
  21638. */
  21639. getClassName(): string;
  21640. /**
  21641. * Register a new input. Must be called inside a block constructor
  21642. * @param name defines the connection point name
  21643. * @param type defines the connection point type
  21644. * @param isOptional defines a boolean indicating that this input can be omitted
  21645. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21646. * @param point an already created connection point. If not provided, create a new one
  21647. * @returns the current block
  21648. */
  21649. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21650. /**
  21651. * Register a new output. Must be called inside a block constructor
  21652. * @param name defines the connection point name
  21653. * @param type defines the connection point type
  21654. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21655. * @param point an already created connection point. If not provided, create a new one
  21656. * @returns the current block
  21657. */
  21658. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21659. /**
  21660. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21661. * @param forOutput defines an optional connection point to check compatibility with
  21662. * @returns the first available input or null
  21663. */
  21664. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21665. /**
  21666. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21667. * @param forBlock defines an optional block to check compatibility with
  21668. * @returns the first available input or null
  21669. */
  21670. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21671. /**
  21672. * Gets the sibling of the given output
  21673. * @param current defines the current output
  21674. * @returns the next output in the list or null
  21675. */
  21676. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21677. /**
  21678. * Connect current block with another block
  21679. * @param other defines the block to connect with
  21680. * @param options define the various options to help pick the right connections
  21681. * @returns the current block
  21682. */
  21683. connectTo(other: NodeMaterialBlock, options?: {
  21684. input?: string;
  21685. output?: string;
  21686. outputSwizzle?: string;
  21687. }): this | undefined;
  21688. protected _buildBlock(state: NodeMaterialBuildState): void;
  21689. /**
  21690. * Add uniforms, samplers and uniform buffers at compilation time
  21691. * @param state defines the state to update
  21692. * @param nodeMaterial defines the node material requesting the update
  21693. * @param defines defines the material defines to update
  21694. * @param uniformBuffers defines the list of uniform buffer names
  21695. */
  21696. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21697. /**
  21698. * Add potential fallbacks if shader compilation fails
  21699. * @param mesh defines the mesh to be rendered
  21700. * @param fallbacks defines the current prioritized list of fallbacks
  21701. */
  21702. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21703. /**
  21704. * Initialize defines for shader compilation
  21705. * @param mesh defines the mesh to be rendered
  21706. * @param nodeMaterial defines the node material requesting the update
  21707. * @param defines defines the material defines to update
  21708. * @param useInstances specifies that instances should be used
  21709. */
  21710. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21711. /**
  21712. * Update defines for shader compilation
  21713. * @param mesh defines the mesh to be rendered
  21714. * @param nodeMaterial defines the node material requesting the update
  21715. * @param defines defines the material defines to update
  21716. * @param useInstances specifies that instances should be used
  21717. * @param subMesh defines which submesh to render
  21718. */
  21719. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21720. /**
  21721. * Lets the block try to connect some inputs automatically
  21722. * @param material defines the hosting NodeMaterial
  21723. */
  21724. autoConfigure(material: NodeMaterial): void;
  21725. /**
  21726. * Function called when a block is declared as repeatable content generator
  21727. * @param vertexShaderState defines the current compilation state for the vertex shader
  21728. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21729. * @param mesh defines the mesh to be rendered
  21730. * @param defines defines the material defines to update
  21731. */
  21732. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21733. /**
  21734. * Checks if the block is ready
  21735. * @param mesh defines the mesh to be rendered
  21736. * @param nodeMaterial defines the node material requesting the update
  21737. * @param defines defines the material defines to update
  21738. * @param useInstances specifies that instances should be used
  21739. * @returns true if the block is ready
  21740. */
  21741. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21742. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21743. private _processBuild;
  21744. /**
  21745. * Validates the new name for the block node.
  21746. * @param newName the new name to be given to the node.
  21747. * @returns false if the name is a reserve word, else true.
  21748. */
  21749. validateBlockName(newName: string): boolean;
  21750. /**
  21751. * Compile the current node and generate the shader code
  21752. * @param state defines the current compilation state (uniforms, samplers, current string)
  21753. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21754. * @returns true if already built
  21755. */
  21756. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21757. protected _inputRename(name: string): string;
  21758. protected _outputRename(name: string): string;
  21759. protected _dumpPropertiesCode(): string;
  21760. /** @hidden */
  21761. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21762. /** @hidden */
  21763. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21764. /**
  21765. * Clone the current block to a new identical block
  21766. * @param scene defines the hosting scene
  21767. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21768. * @returns a copy of the current block
  21769. */
  21770. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21771. /**
  21772. * Serializes this block in a JSON representation
  21773. * @returns the serialized block object
  21774. */
  21775. serialize(): any;
  21776. /** @hidden */
  21777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21778. private _deserializePortDisplayNamesAndExposedOnFrame;
  21779. /**
  21780. * Release resources
  21781. */
  21782. dispose(): void;
  21783. }
  21784. }
  21785. declare module BABYLON {
  21786. /**
  21787. * Base class of materials working in push mode in babylon JS
  21788. * @hidden
  21789. */
  21790. export class PushMaterial extends Material {
  21791. protected _activeEffect: Effect;
  21792. protected _normalMatrix: Matrix;
  21793. constructor(name: string, scene: Scene);
  21794. getEffect(): Effect;
  21795. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21796. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21797. /**
  21798. * Binds the given world matrix to the active effect
  21799. *
  21800. * @param world the matrix to bind
  21801. */
  21802. bindOnlyWorldMatrix(world: Matrix): void;
  21803. /**
  21804. * Binds the given normal matrix to the active effect
  21805. *
  21806. * @param normalMatrix the matrix to bind
  21807. */
  21808. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21809. bind(world: Matrix, mesh?: Mesh): void;
  21810. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21811. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21812. }
  21813. }
  21814. declare module BABYLON {
  21815. /**
  21816. * Root class for all node material optimizers
  21817. */
  21818. export class NodeMaterialOptimizer {
  21819. /**
  21820. * Function used to optimize a NodeMaterial graph
  21821. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21822. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21823. */
  21824. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21825. }
  21826. }
  21827. declare module BABYLON {
  21828. /**
  21829. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21830. */
  21831. export class TransformBlock extends NodeMaterialBlock {
  21832. /**
  21833. * Defines the value to use to complement W value to transform it to a Vector4
  21834. */
  21835. complementW: number;
  21836. /**
  21837. * Defines the value to use to complement z value to transform it to a Vector4
  21838. */
  21839. complementZ: number;
  21840. /**
  21841. * Creates a new TransformBlock
  21842. * @param name defines the block name
  21843. */
  21844. constructor(name: string);
  21845. /**
  21846. * Gets the current class name
  21847. * @returns the class name
  21848. */
  21849. getClassName(): string;
  21850. /**
  21851. * Gets the vector input
  21852. */
  21853. get vector(): NodeMaterialConnectionPoint;
  21854. /**
  21855. * Gets the output component
  21856. */
  21857. get output(): NodeMaterialConnectionPoint;
  21858. /**
  21859. * Gets the xyz output component
  21860. */
  21861. get xyz(): NodeMaterialConnectionPoint;
  21862. /**
  21863. * Gets the matrix transform input
  21864. */
  21865. get transform(): NodeMaterialConnectionPoint;
  21866. protected _buildBlock(state: NodeMaterialBuildState): this;
  21867. /**
  21868. * Update defines for shader compilation
  21869. * @param mesh defines the mesh to be rendered
  21870. * @param nodeMaterial defines the node material requesting the update
  21871. * @param defines defines the material defines to update
  21872. * @param useInstances specifies that instances should be used
  21873. * @param subMesh defines which submesh to render
  21874. */
  21875. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21876. serialize(): any;
  21877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21878. protected _dumpPropertiesCode(): string;
  21879. }
  21880. }
  21881. declare module BABYLON {
  21882. /**
  21883. * Block used to output the vertex position
  21884. */
  21885. export class VertexOutputBlock extends NodeMaterialBlock {
  21886. /**
  21887. * Creates a new VertexOutputBlock
  21888. * @param name defines the block name
  21889. */
  21890. constructor(name: string);
  21891. /**
  21892. * Gets the current class name
  21893. * @returns the class name
  21894. */
  21895. getClassName(): string;
  21896. /**
  21897. * Gets the vector input component
  21898. */
  21899. get vector(): NodeMaterialConnectionPoint;
  21900. protected _buildBlock(state: NodeMaterialBuildState): this;
  21901. }
  21902. }
  21903. declare module BABYLON {
  21904. /**
  21905. * Block used to output the final color
  21906. */
  21907. export class FragmentOutputBlock extends NodeMaterialBlock {
  21908. /**
  21909. * Create a new FragmentOutputBlock
  21910. * @param name defines the block name
  21911. */
  21912. constructor(name: string);
  21913. /**
  21914. * Gets the current class name
  21915. * @returns the class name
  21916. */
  21917. getClassName(): string;
  21918. /**
  21919. * Gets the rgba input component
  21920. */
  21921. get rgba(): NodeMaterialConnectionPoint;
  21922. /**
  21923. * Gets the rgb input component
  21924. */
  21925. get rgb(): NodeMaterialConnectionPoint;
  21926. /**
  21927. * Gets the a input component
  21928. */
  21929. get a(): NodeMaterialConnectionPoint;
  21930. protected _buildBlock(state: NodeMaterialBuildState): this;
  21931. }
  21932. }
  21933. declare module BABYLON {
  21934. /**
  21935. * Block used for the particle ramp gradient section
  21936. */
  21937. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21938. /**
  21939. * Create a new ParticleRampGradientBlock
  21940. * @param name defines the block name
  21941. */
  21942. constructor(name: string);
  21943. /**
  21944. * Gets the current class name
  21945. * @returns the class name
  21946. */
  21947. getClassName(): string;
  21948. /**
  21949. * Gets the color input component
  21950. */
  21951. get color(): NodeMaterialConnectionPoint;
  21952. /**
  21953. * Gets the rampColor output component
  21954. */
  21955. get rampColor(): NodeMaterialConnectionPoint;
  21956. /**
  21957. * Initialize the block and prepare the context for build
  21958. * @param state defines the state that will be used for the build
  21959. */
  21960. initialize(state: NodeMaterialBuildState): void;
  21961. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21962. }
  21963. }
  21964. declare module BABYLON {
  21965. /**
  21966. * Block used for the particle blend multiply section
  21967. */
  21968. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21969. /**
  21970. * Create a new ParticleBlendMultiplyBlock
  21971. * @param name defines the block name
  21972. */
  21973. constructor(name: string);
  21974. /**
  21975. * Gets the current class name
  21976. * @returns the class name
  21977. */
  21978. getClassName(): string;
  21979. /**
  21980. * Gets the color input component
  21981. */
  21982. get color(): NodeMaterialConnectionPoint;
  21983. /**
  21984. * Gets the alphaTexture input component
  21985. */
  21986. get alphaTexture(): NodeMaterialConnectionPoint;
  21987. /**
  21988. * Gets the alphaColor input component
  21989. */
  21990. get alphaColor(): NodeMaterialConnectionPoint;
  21991. /**
  21992. * Gets the blendColor output component
  21993. */
  21994. get blendColor(): NodeMaterialConnectionPoint;
  21995. /**
  21996. * Initialize the block and prepare the context for build
  21997. * @param state defines the state that will be used for the build
  21998. */
  21999. initialize(state: NodeMaterialBuildState): void;
  22000. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22001. }
  22002. }
  22003. declare module BABYLON {
  22004. /**
  22005. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22006. */
  22007. export class VectorMergerBlock extends NodeMaterialBlock {
  22008. /**
  22009. * Create a new VectorMergerBlock
  22010. * @param name defines the block name
  22011. */
  22012. constructor(name: string);
  22013. /**
  22014. * Gets the current class name
  22015. * @returns the class name
  22016. */
  22017. getClassName(): string;
  22018. /**
  22019. * Gets the xyz component (input)
  22020. */
  22021. get xyzIn(): NodeMaterialConnectionPoint;
  22022. /**
  22023. * Gets the xy component (input)
  22024. */
  22025. get xyIn(): NodeMaterialConnectionPoint;
  22026. /**
  22027. * Gets the x component (input)
  22028. */
  22029. get x(): NodeMaterialConnectionPoint;
  22030. /**
  22031. * Gets the y component (input)
  22032. */
  22033. get y(): NodeMaterialConnectionPoint;
  22034. /**
  22035. * Gets the z component (input)
  22036. */
  22037. get z(): NodeMaterialConnectionPoint;
  22038. /**
  22039. * Gets the w component (input)
  22040. */
  22041. get w(): NodeMaterialConnectionPoint;
  22042. /**
  22043. * Gets the xyzw component (output)
  22044. */
  22045. get xyzw(): NodeMaterialConnectionPoint;
  22046. /**
  22047. * Gets the xyz component (output)
  22048. */
  22049. get xyzOut(): NodeMaterialConnectionPoint;
  22050. /**
  22051. * Gets the xy component (output)
  22052. */
  22053. get xyOut(): NodeMaterialConnectionPoint;
  22054. /**
  22055. * Gets the xy component (output)
  22056. * @deprecated Please use xyOut instead.
  22057. */
  22058. get xy(): NodeMaterialConnectionPoint;
  22059. /**
  22060. * Gets the xyz component (output)
  22061. * @deprecated Please use xyzOut instead.
  22062. */
  22063. get xyz(): NodeMaterialConnectionPoint;
  22064. protected _buildBlock(state: NodeMaterialBuildState): this;
  22065. }
  22066. }
  22067. declare module BABYLON {
  22068. /**
  22069. * Block used to remap a float from a range to a new one
  22070. */
  22071. export class RemapBlock extends NodeMaterialBlock {
  22072. /**
  22073. * Gets or sets the source range
  22074. */
  22075. sourceRange: Vector2;
  22076. /**
  22077. * Gets or sets the target range
  22078. */
  22079. targetRange: Vector2;
  22080. /**
  22081. * Creates a new RemapBlock
  22082. * @param name defines the block name
  22083. */
  22084. constructor(name: string);
  22085. /**
  22086. * Gets the current class name
  22087. * @returns the class name
  22088. */
  22089. getClassName(): string;
  22090. /**
  22091. * Gets the input component
  22092. */
  22093. get input(): NodeMaterialConnectionPoint;
  22094. /**
  22095. * Gets the source min input component
  22096. */
  22097. get sourceMin(): NodeMaterialConnectionPoint;
  22098. /**
  22099. * Gets the source max input component
  22100. */
  22101. get sourceMax(): NodeMaterialConnectionPoint;
  22102. /**
  22103. * Gets the target min input component
  22104. */
  22105. get targetMin(): NodeMaterialConnectionPoint;
  22106. /**
  22107. * Gets the target max input component
  22108. */
  22109. get targetMax(): NodeMaterialConnectionPoint;
  22110. /**
  22111. * Gets the output component
  22112. */
  22113. get output(): NodeMaterialConnectionPoint;
  22114. protected _buildBlock(state: NodeMaterialBuildState): this;
  22115. protected _dumpPropertiesCode(): string;
  22116. serialize(): any;
  22117. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22118. }
  22119. }
  22120. declare module BABYLON {
  22121. /**
  22122. * Block used to multiply 2 values
  22123. */
  22124. export class MultiplyBlock extends NodeMaterialBlock {
  22125. /**
  22126. * Creates a new MultiplyBlock
  22127. * @param name defines the block name
  22128. */
  22129. constructor(name: string);
  22130. /**
  22131. * Gets the current class name
  22132. * @returns the class name
  22133. */
  22134. getClassName(): string;
  22135. /**
  22136. * Gets the left operand input component
  22137. */
  22138. get left(): NodeMaterialConnectionPoint;
  22139. /**
  22140. * Gets the right operand input component
  22141. */
  22142. get right(): NodeMaterialConnectionPoint;
  22143. /**
  22144. * Gets the output component
  22145. */
  22146. get output(): NodeMaterialConnectionPoint;
  22147. protected _buildBlock(state: NodeMaterialBuildState): this;
  22148. }
  22149. }
  22150. declare module BABYLON {
  22151. /**
  22152. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22153. */
  22154. export class ColorSplitterBlock extends NodeMaterialBlock {
  22155. /**
  22156. * Create a new ColorSplitterBlock
  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 rgba component (input)
  22167. */
  22168. get rgba(): NodeMaterialConnectionPoint;
  22169. /**
  22170. * Gets the rgb component (input)
  22171. */
  22172. get rgbIn(): NodeMaterialConnectionPoint;
  22173. /**
  22174. * Gets the rgb component (output)
  22175. */
  22176. get rgbOut(): NodeMaterialConnectionPoint;
  22177. /**
  22178. * Gets the r component (output)
  22179. */
  22180. get r(): NodeMaterialConnectionPoint;
  22181. /**
  22182. * Gets the g component (output)
  22183. */
  22184. get g(): NodeMaterialConnectionPoint;
  22185. /**
  22186. * Gets the b component (output)
  22187. */
  22188. get b(): NodeMaterialConnectionPoint;
  22189. /**
  22190. * Gets the a component (output)
  22191. */
  22192. get a(): NodeMaterialConnectionPoint;
  22193. protected _inputRename(name: string): string;
  22194. protected _outputRename(name: string): string;
  22195. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22196. }
  22197. }
  22198. declare module BABYLON {
  22199. /**
  22200. * Interface used to configure the node material editor
  22201. */
  22202. export interface INodeMaterialEditorOptions {
  22203. /** Define the URl to load node editor script */
  22204. editorURL?: string;
  22205. }
  22206. /** @hidden */
  22207. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22208. NORMAL: boolean;
  22209. TANGENT: boolean;
  22210. UV1: boolean;
  22211. /** BONES */
  22212. NUM_BONE_INFLUENCERS: number;
  22213. BonesPerMesh: number;
  22214. BONETEXTURE: boolean;
  22215. /** MORPH TARGETS */
  22216. MORPHTARGETS: boolean;
  22217. MORPHTARGETS_NORMAL: boolean;
  22218. MORPHTARGETS_TANGENT: boolean;
  22219. MORPHTARGETS_UV: boolean;
  22220. NUM_MORPH_INFLUENCERS: number;
  22221. /** IMAGE PROCESSING */
  22222. IMAGEPROCESSING: boolean;
  22223. VIGNETTE: boolean;
  22224. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22225. VIGNETTEBLENDMODEOPAQUE: boolean;
  22226. TONEMAPPING: boolean;
  22227. TONEMAPPING_ACES: boolean;
  22228. CONTRAST: boolean;
  22229. EXPOSURE: boolean;
  22230. COLORCURVES: boolean;
  22231. COLORGRADING: boolean;
  22232. COLORGRADING3D: boolean;
  22233. SAMPLER3DGREENDEPTH: boolean;
  22234. SAMPLER3DBGRMAP: boolean;
  22235. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22236. /** MISC. */
  22237. BUMPDIRECTUV: number;
  22238. constructor();
  22239. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22240. }
  22241. /**
  22242. * Class used to configure NodeMaterial
  22243. */
  22244. export interface INodeMaterialOptions {
  22245. /**
  22246. * Defines if blocks should emit comments
  22247. */
  22248. emitComments: boolean;
  22249. }
  22250. /**
  22251. * Class used to create a node based material built by assembling shader blocks
  22252. */
  22253. export class NodeMaterial extends PushMaterial {
  22254. private static _BuildIdGenerator;
  22255. private _options;
  22256. private _vertexCompilationState;
  22257. private _fragmentCompilationState;
  22258. private _sharedData;
  22259. private _buildId;
  22260. private _buildWasSuccessful;
  22261. private _cachedWorldViewMatrix;
  22262. private _cachedWorldViewProjectionMatrix;
  22263. private _optimizers;
  22264. private _animationFrame;
  22265. /** Define the Url to load node editor script */
  22266. static EditorURL: string;
  22267. /** Define the Url to load snippets */
  22268. static SnippetUrl: string;
  22269. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22270. static IgnoreTexturesAtLoadTime: boolean;
  22271. private BJSNODEMATERIALEDITOR;
  22272. /** Get the inspector from bundle or global */
  22273. private _getGlobalNodeMaterialEditor;
  22274. /**
  22275. * Snippet ID if the material was created from the snippet server
  22276. */
  22277. snippetId: string;
  22278. /**
  22279. * Gets or sets data used by visual editor
  22280. * @see https://nme.babylonjs.com
  22281. */
  22282. editorData: any;
  22283. /**
  22284. * 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)
  22285. */
  22286. ignoreAlpha: boolean;
  22287. /**
  22288. * Defines the maximum number of lights that can be used in the material
  22289. */
  22290. maxSimultaneousLights: number;
  22291. /**
  22292. * Observable raised when the material is built
  22293. */
  22294. onBuildObservable: Observable<NodeMaterial>;
  22295. /**
  22296. * Gets or sets the root nodes of the material vertex shader
  22297. */
  22298. _vertexOutputNodes: NodeMaterialBlock[];
  22299. /**
  22300. * Gets or sets the root nodes of the material fragment (pixel) shader
  22301. */
  22302. _fragmentOutputNodes: NodeMaterialBlock[];
  22303. /** Gets or sets options to control the node material overall behavior */
  22304. get options(): INodeMaterialOptions;
  22305. set options(options: INodeMaterialOptions);
  22306. /**
  22307. * Default configuration related to image processing available in the standard Material.
  22308. */
  22309. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22310. /**
  22311. * Gets the image processing configuration used either in this material.
  22312. */
  22313. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22314. /**
  22315. * Sets the Default image processing configuration used either in the this material.
  22316. *
  22317. * If sets to null, the scene one is in use.
  22318. */
  22319. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22320. /**
  22321. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22322. */
  22323. attachedBlocks: NodeMaterialBlock[];
  22324. /**
  22325. * Specifies the mode of the node material
  22326. * @hidden
  22327. */
  22328. _mode: NodeMaterialModes;
  22329. /**
  22330. * Gets the mode property
  22331. */
  22332. get mode(): NodeMaterialModes;
  22333. /**
  22334. * Create a new node based material
  22335. * @param name defines the material name
  22336. * @param scene defines the hosting scene
  22337. * @param options defines creation option
  22338. */
  22339. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22340. /**
  22341. * Gets the current class name of the material e.g. "NodeMaterial"
  22342. * @returns the class name
  22343. */
  22344. getClassName(): string;
  22345. /**
  22346. * Keep track of the image processing observer to allow dispose and replace.
  22347. */
  22348. private _imageProcessingObserver;
  22349. /**
  22350. * Attaches a new image processing configuration to the Standard Material.
  22351. * @param configuration
  22352. */
  22353. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22354. /**
  22355. * Get a block by its name
  22356. * @param name defines the name of the block to retrieve
  22357. * @returns the required block or null if not found
  22358. */
  22359. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22360. /**
  22361. * Get a block by its name
  22362. * @param predicate defines the predicate used to find the good candidate
  22363. * @returns the required block or null if not found
  22364. */
  22365. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22366. /**
  22367. * Get an input block by its name
  22368. * @param predicate defines the predicate used to find the good candidate
  22369. * @returns the required input block or null if not found
  22370. */
  22371. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22372. /**
  22373. * Gets the list of input blocks attached to this material
  22374. * @returns an array of InputBlocks
  22375. */
  22376. getInputBlocks(): InputBlock[];
  22377. /**
  22378. * Adds a new optimizer to the list of optimizers
  22379. * @param optimizer defines the optimizers to add
  22380. * @returns the current material
  22381. */
  22382. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22383. /**
  22384. * Remove an optimizer from the list of optimizers
  22385. * @param optimizer defines the optimizers to remove
  22386. * @returns the current material
  22387. */
  22388. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22389. /**
  22390. * Add a new block to the list of output nodes
  22391. * @param node defines the node to add
  22392. * @returns the current material
  22393. */
  22394. addOutputNode(node: NodeMaterialBlock): this;
  22395. /**
  22396. * Remove a block from the list of root nodes
  22397. * @param node defines the node to remove
  22398. * @returns the current material
  22399. */
  22400. removeOutputNode(node: NodeMaterialBlock): this;
  22401. private _addVertexOutputNode;
  22402. private _removeVertexOutputNode;
  22403. private _addFragmentOutputNode;
  22404. private _removeFragmentOutputNode;
  22405. /**
  22406. * Specifies if the material will require alpha blending
  22407. * @returns a boolean specifying if alpha blending is needed
  22408. */
  22409. needAlphaBlending(): boolean;
  22410. /**
  22411. * Specifies if this material should be rendered in alpha test mode
  22412. * @returns a boolean specifying if an alpha test is needed.
  22413. */
  22414. needAlphaTesting(): boolean;
  22415. private _initializeBlock;
  22416. private _resetDualBlocks;
  22417. /**
  22418. * Remove a block from the current node material
  22419. * @param block defines the block to remove
  22420. */
  22421. removeBlock(block: NodeMaterialBlock): void;
  22422. /**
  22423. * Build the material and generates the inner effect
  22424. * @param verbose defines if the build should log activity
  22425. */
  22426. build(verbose?: boolean): void;
  22427. /**
  22428. * Runs an otpimization phase to try to improve the shader code
  22429. */
  22430. optimize(): void;
  22431. private _prepareDefinesForAttributes;
  22432. /**
  22433. * Create a post process from the material
  22434. * @param camera The camera to apply the render pass to.
  22435. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22437. * @param engine The engine which the post process will be applied. (default: current engine)
  22438. * @param reusable If the post process can be reused on the same frame. (default: false)
  22439. * @param textureType Type of textures used when performing the post process. (default: 0)
  22440. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22441. * @returns the post process created
  22442. */
  22443. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22444. /**
  22445. * Create the post process effect from the material
  22446. * @param postProcess The post process to create the effect for
  22447. */
  22448. createEffectForPostProcess(postProcess: PostProcess): void;
  22449. private _createEffectOrPostProcess;
  22450. private _createEffectForParticles;
  22451. /**
  22452. * Create the effect to be used as the custom effect for a particle system
  22453. * @param particleSystem Particle system to create the effect for
  22454. * @param onCompiled defines a function to call when the effect creation is successful
  22455. * @param onError defines a function to call when the effect creation has failed
  22456. */
  22457. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22458. private _processDefines;
  22459. /**
  22460. * Get if the submesh is ready to be used and all its information available.
  22461. * Child classes can use it to update shaders
  22462. * @param mesh defines the mesh to check
  22463. * @param subMesh defines which submesh to check
  22464. * @param useInstances specifies that instances should be used
  22465. * @returns a boolean indicating that the submesh is ready or not
  22466. */
  22467. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22468. /**
  22469. * Get a string representing the shaders built by the current node graph
  22470. */
  22471. get compiledShaders(): string;
  22472. /**
  22473. * Binds the world matrix to the material
  22474. * @param world defines the world transformation matrix
  22475. */
  22476. bindOnlyWorldMatrix(world: Matrix): void;
  22477. /**
  22478. * Binds the submesh to this material by preparing the effect and shader to draw
  22479. * @param world defines the world transformation matrix
  22480. * @param mesh defines the mesh containing the submesh
  22481. * @param subMesh defines the submesh to bind the material to
  22482. */
  22483. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22484. /**
  22485. * Gets the active textures from the material
  22486. * @returns an array of textures
  22487. */
  22488. getActiveTextures(): BaseTexture[];
  22489. /**
  22490. * Gets the list of texture blocks
  22491. * @returns an array of texture blocks
  22492. */
  22493. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22494. /**
  22495. * Specifies if the material uses a texture
  22496. * @param texture defines the texture to check against the material
  22497. * @returns a boolean specifying if the material uses the texture
  22498. */
  22499. hasTexture(texture: BaseTexture): boolean;
  22500. /**
  22501. * Disposes the material
  22502. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22503. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22504. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22505. */
  22506. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22507. /** Creates the node editor window. */
  22508. private _createNodeEditor;
  22509. /**
  22510. * Launch the node material editor
  22511. * @param config Define the configuration of the editor
  22512. * @return a promise fulfilled when the node editor is visible
  22513. */
  22514. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22515. /**
  22516. * Clear the current material
  22517. */
  22518. clear(): void;
  22519. /**
  22520. * Clear the current material and set it to a default state
  22521. */
  22522. setToDefault(): void;
  22523. /**
  22524. * Clear the current material and set it to a default state for post process
  22525. */
  22526. setToDefaultPostProcess(): void;
  22527. /**
  22528. * Clear the current material and set it to a default state for particle
  22529. */
  22530. setToDefaultParticle(): void;
  22531. /**
  22532. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22533. * @param url defines the url to load from
  22534. * @returns a promise that will fullfil when the material is fully loaded
  22535. */
  22536. loadAsync(url: string): Promise<void>;
  22537. private _gatherBlocks;
  22538. /**
  22539. * Generate a string containing the code declaration required to create an equivalent of this material
  22540. * @returns a string
  22541. */
  22542. generateCode(): string;
  22543. /**
  22544. * Serializes this material in a JSON representation
  22545. * @returns the serialized material object
  22546. */
  22547. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22548. private _restoreConnections;
  22549. /**
  22550. * Clear the current graph and load a new one from a serialization object
  22551. * @param source defines the JSON representation of the material
  22552. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22553. * @param merge defines whether or not the source must be merged or replace the current content
  22554. */
  22555. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22556. /**
  22557. * Makes a duplicate of the current material.
  22558. * @param name - name to use for the new material.
  22559. */
  22560. clone(name: string): NodeMaterial;
  22561. /**
  22562. * Creates a node material from parsed material data
  22563. * @param source defines the JSON representation of the material
  22564. * @param scene defines the hosting scene
  22565. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22566. * @returns a new node material
  22567. */
  22568. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22569. /**
  22570. * Creates a node material from a snippet saved in a remote file
  22571. * @param name defines the name of the material to create
  22572. * @param url defines the url to load from
  22573. * @param scene defines the hosting scene
  22574. * @returns a promise that will resolve to the new node material
  22575. */
  22576. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22577. /**
  22578. * Creates a node material from a snippet saved by the node material editor
  22579. * @param snippetId defines the snippet to load
  22580. * @param scene defines the hosting scene
  22581. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22582. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22583. * @returns a promise that will resolve to the new node material
  22584. */
  22585. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22586. /**
  22587. * Creates a new node material set to default basic configuration
  22588. * @param name defines the name of the material
  22589. * @param scene defines the hosting scene
  22590. * @returns a new NodeMaterial
  22591. */
  22592. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22593. }
  22594. }
  22595. declare module BABYLON {
  22596. /**
  22597. * Size options for a post process
  22598. */
  22599. export type PostProcessOptions = {
  22600. width: number;
  22601. height: number;
  22602. };
  22603. /**
  22604. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22605. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22606. */
  22607. export class PostProcess {
  22608. /**
  22609. * Gets or sets the unique id of the post process
  22610. */
  22611. uniqueId: number;
  22612. /** Name of the PostProcess. */
  22613. name: string;
  22614. /**
  22615. * Width of the texture to apply the post process on
  22616. */
  22617. width: number;
  22618. /**
  22619. * Height of the texture to apply the post process on
  22620. */
  22621. height: number;
  22622. /**
  22623. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22624. */
  22625. nodeMaterialSource: Nullable<NodeMaterial>;
  22626. /**
  22627. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22628. * @hidden
  22629. */
  22630. _outputTexture: Nullable<InternalTexture>;
  22631. /**
  22632. * Sampling mode used by the shader
  22633. * See https://doc.babylonjs.com/classes/3.1/texture
  22634. */
  22635. renderTargetSamplingMode: number;
  22636. /**
  22637. * Clear color to use when screen clearing
  22638. */
  22639. clearColor: Color4;
  22640. /**
  22641. * If the buffer needs to be cleared before applying the post process. (default: true)
  22642. * Should be set to false if shader will overwrite all previous pixels.
  22643. */
  22644. autoClear: boolean;
  22645. /**
  22646. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22647. */
  22648. alphaMode: number;
  22649. /**
  22650. * Sets the setAlphaBlendConstants of the babylon engine
  22651. */
  22652. alphaConstants: Color4;
  22653. /**
  22654. * Animations to be used for the post processing
  22655. */
  22656. animations: Animation[];
  22657. /**
  22658. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22659. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22660. */
  22661. enablePixelPerfectMode: boolean;
  22662. /**
  22663. * Force the postprocess to be applied without taking in account viewport
  22664. */
  22665. forceFullscreenViewport: boolean;
  22666. /**
  22667. * List of inspectable custom properties (used by the Inspector)
  22668. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22669. */
  22670. inspectableCustomProperties: IInspectable[];
  22671. /**
  22672. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22673. *
  22674. * | Value | Type | Description |
  22675. * | ----- | ----------------------------------- | ----------- |
  22676. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22677. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22678. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22679. *
  22680. */
  22681. scaleMode: number;
  22682. /**
  22683. * Force textures to be a power of two (default: false)
  22684. */
  22685. alwaysForcePOT: boolean;
  22686. private _samples;
  22687. /**
  22688. * Number of sample textures (default: 1)
  22689. */
  22690. get samples(): number;
  22691. set samples(n: number);
  22692. /**
  22693. * Modify the scale of the post process to be the same as the viewport (default: false)
  22694. */
  22695. adaptScaleToCurrentViewport: boolean;
  22696. private _camera;
  22697. protected _scene: Scene;
  22698. private _engine;
  22699. private _options;
  22700. private _reusable;
  22701. private _textureType;
  22702. private _textureFormat;
  22703. /**
  22704. * Smart array of input and output textures for the post process.
  22705. * @hidden
  22706. */
  22707. _textures: SmartArray<InternalTexture>;
  22708. /**
  22709. * The index in _textures that corresponds to the output texture.
  22710. * @hidden
  22711. */
  22712. _currentRenderTextureInd: number;
  22713. private _effect;
  22714. private _samplers;
  22715. private _fragmentUrl;
  22716. private _vertexUrl;
  22717. private _parameters;
  22718. private _scaleRatio;
  22719. protected _indexParameters: any;
  22720. private _shareOutputWithPostProcess;
  22721. private _texelSize;
  22722. private _forcedOutputTexture;
  22723. /**
  22724. * Returns the fragment url or shader name used in the post process.
  22725. * @returns the fragment url or name in the shader store.
  22726. */
  22727. getEffectName(): string;
  22728. /**
  22729. * An event triggered when the postprocess is activated.
  22730. */
  22731. onActivateObservable: Observable<Camera>;
  22732. private _onActivateObserver;
  22733. /**
  22734. * A function that is added to the onActivateObservable
  22735. */
  22736. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22737. /**
  22738. * An event triggered when the postprocess changes its size.
  22739. */
  22740. onSizeChangedObservable: Observable<PostProcess>;
  22741. private _onSizeChangedObserver;
  22742. /**
  22743. * A function that is added to the onSizeChangedObservable
  22744. */
  22745. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22746. /**
  22747. * An event triggered when the postprocess applies its effect.
  22748. */
  22749. onApplyObservable: Observable<Effect>;
  22750. private _onApplyObserver;
  22751. /**
  22752. * A function that is added to the onApplyObservable
  22753. */
  22754. set onApply(callback: (effect: Effect) => void);
  22755. /**
  22756. * An event triggered before rendering the postprocess
  22757. */
  22758. onBeforeRenderObservable: Observable<Effect>;
  22759. private _onBeforeRenderObserver;
  22760. /**
  22761. * A function that is added to the onBeforeRenderObservable
  22762. */
  22763. set onBeforeRender(callback: (effect: Effect) => void);
  22764. /**
  22765. * An event triggered after rendering the postprocess
  22766. */
  22767. onAfterRenderObservable: Observable<Effect>;
  22768. private _onAfterRenderObserver;
  22769. /**
  22770. * A function that is added to the onAfterRenderObservable
  22771. */
  22772. set onAfterRender(callback: (efect: Effect) => void);
  22773. /**
  22774. * 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
  22775. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22776. */
  22777. get inputTexture(): InternalTexture;
  22778. set inputTexture(value: InternalTexture);
  22779. /**
  22780. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22781. * the only way to unset it is to use this function to restore its internal state
  22782. */
  22783. restoreDefaultInputTexture(): void;
  22784. /**
  22785. * Gets the camera which post process is applied to.
  22786. * @returns The camera the post process is applied to.
  22787. */
  22788. getCamera(): Camera;
  22789. /**
  22790. * Gets the texel size of the postprocess.
  22791. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22792. */
  22793. get texelSize(): Vector2;
  22794. /**
  22795. * Creates a new instance PostProcess
  22796. * @param name The name of the PostProcess.
  22797. * @param fragmentUrl The url of the fragment shader to be used.
  22798. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22799. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22800. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22801. * @param camera The camera to apply the render pass to.
  22802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22803. * @param engine The engine which the post process will be applied. (default: current engine)
  22804. * @param reusable If the post process can be reused on the same frame. (default: false)
  22805. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22806. * @param textureType Type of textures used when performing the post process. (default: 0)
  22807. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22808. * @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
  22809. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22810. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22811. */
  22812. 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);
  22813. /**
  22814. * Gets a string identifying the name of the class
  22815. * @returns "PostProcess" string
  22816. */
  22817. getClassName(): string;
  22818. /**
  22819. * Gets the engine which this post process belongs to.
  22820. * @returns The engine the post process was enabled with.
  22821. */
  22822. getEngine(): Engine;
  22823. /**
  22824. * The effect that is created when initializing the post process.
  22825. * @returns The created effect corresponding the the postprocess.
  22826. */
  22827. getEffect(): Effect;
  22828. /**
  22829. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22830. * @param postProcess The post process to share the output with.
  22831. * @returns This post process.
  22832. */
  22833. shareOutputWith(postProcess: PostProcess): PostProcess;
  22834. /**
  22835. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22836. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22837. */
  22838. useOwnOutput(): void;
  22839. /**
  22840. * Updates the effect with the current post process compile time values and recompiles the shader.
  22841. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22842. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22843. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22844. * @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
  22845. * @param onCompiled Called when the shader has been compiled.
  22846. * @param onError Called if there is an error when compiling a shader.
  22847. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22848. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22849. */
  22850. 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;
  22851. /**
  22852. * The post process is reusable if it can be used multiple times within one frame.
  22853. * @returns If the post process is reusable
  22854. */
  22855. isReusable(): boolean;
  22856. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22857. markTextureDirty(): void;
  22858. /**
  22859. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22860. * 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.
  22861. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22862. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22863. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22864. * @returns The target texture that was bound to be written to.
  22865. */
  22866. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22867. /**
  22868. * If the post process is supported.
  22869. */
  22870. get isSupported(): boolean;
  22871. /**
  22872. * The aspect ratio of the output texture.
  22873. */
  22874. get aspectRatio(): number;
  22875. /**
  22876. * Get a value indicating if the post-process is ready to be used
  22877. * @returns true if the post-process is ready (shader is compiled)
  22878. */
  22879. isReady(): boolean;
  22880. /**
  22881. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22882. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22883. */
  22884. apply(): Nullable<Effect>;
  22885. private _disposeTextures;
  22886. /**
  22887. * Disposes the post process.
  22888. * @param camera The camera to dispose the post process on.
  22889. */
  22890. dispose(camera?: Camera): void;
  22891. /**
  22892. * Serializes the particle system to a JSON object
  22893. * @returns the JSON object
  22894. */
  22895. serialize(): any;
  22896. /**
  22897. * Creates a material from parsed material data
  22898. * @param parsedPostProcess defines parsed post process data
  22899. * @param scene defines the hosting scene
  22900. * @param rootUrl defines the root URL to use to load textures
  22901. * @returns a new post process
  22902. */
  22903. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22904. }
  22905. }
  22906. declare module BABYLON {
  22907. /** @hidden */
  22908. export var kernelBlurVaryingDeclaration: {
  22909. name: string;
  22910. shader: string;
  22911. };
  22912. }
  22913. declare module BABYLON {
  22914. /** @hidden */
  22915. export var kernelBlurFragment: {
  22916. name: string;
  22917. shader: string;
  22918. };
  22919. }
  22920. declare module BABYLON {
  22921. /** @hidden */
  22922. export var kernelBlurFragment2: {
  22923. name: string;
  22924. shader: string;
  22925. };
  22926. }
  22927. declare module BABYLON {
  22928. /** @hidden */
  22929. export var kernelBlurPixelShader: {
  22930. name: string;
  22931. shader: string;
  22932. };
  22933. }
  22934. declare module BABYLON {
  22935. /** @hidden */
  22936. export var kernelBlurVertex: {
  22937. name: string;
  22938. shader: string;
  22939. };
  22940. }
  22941. declare module BABYLON {
  22942. /** @hidden */
  22943. export var kernelBlurVertexShader: {
  22944. name: string;
  22945. shader: string;
  22946. };
  22947. }
  22948. declare module BABYLON {
  22949. /**
  22950. * The Blur Post Process which blurs an image based on a kernel and direction.
  22951. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22952. */
  22953. export class BlurPostProcess extends PostProcess {
  22954. private blockCompilation;
  22955. protected _kernel: number;
  22956. protected _idealKernel: number;
  22957. protected _packedFloat: boolean;
  22958. private _staticDefines;
  22959. /** The direction in which to blur the image. */
  22960. direction: Vector2;
  22961. /**
  22962. * Sets the length in pixels of the blur sample region
  22963. */
  22964. set kernel(v: number);
  22965. /**
  22966. * Gets the length in pixels of the blur sample region
  22967. */
  22968. get kernel(): number;
  22969. /**
  22970. * Sets wether or not the blur needs to unpack/repack floats
  22971. */
  22972. set packedFloat(v: boolean);
  22973. /**
  22974. * Gets wether or not the blur is unpacking/repacking floats
  22975. */
  22976. get packedFloat(): boolean;
  22977. /**
  22978. * Gets a string identifying the name of the class
  22979. * @returns "BlurPostProcess" string
  22980. */
  22981. getClassName(): string;
  22982. /**
  22983. * Creates a new instance BlurPostProcess
  22984. * @param name The name of the effect.
  22985. * @param direction The direction in which to blur the image.
  22986. * @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.
  22987. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22988. * @param camera The camera to apply the render pass to.
  22989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22990. * @param engine The engine which the post process will be applied. (default: current engine)
  22991. * @param reusable If the post process can be reused on the same frame. (default: false)
  22992. * @param textureType Type of textures used when performing the post process. (default: 0)
  22993. * @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)
  22994. */
  22995. 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);
  22996. /**
  22997. * Updates the effect with the current post process compile time values and recompiles the shader.
  22998. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22999. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23000. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23001. * @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
  23002. * @param onCompiled Called when the shader has been compiled.
  23003. * @param onError Called if there is an error when compiling a shader.
  23004. */
  23005. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23006. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23007. /**
  23008. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23009. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23010. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23011. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23012. * The gaps between physical kernels are compensated for in the weighting of the samples
  23013. * @param idealKernel Ideal blur kernel.
  23014. * @return Nearest best kernel.
  23015. */
  23016. protected _nearestBestKernel(idealKernel: number): number;
  23017. /**
  23018. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23019. * @param x The point on the Gaussian distribution to sample.
  23020. * @return the value of the Gaussian function at x.
  23021. */
  23022. protected _gaussianWeight(x: number): number;
  23023. /**
  23024. * Generates a string that can be used as a floating point number in GLSL.
  23025. * @param x Value to print.
  23026. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23027. * @return GLSL float string.
  23028. */
  23029. protected _glslFloat(x: number, decimalFigures?: number): string;
  23030. /** @hidden */
  23031. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23032. }
  23033. }
  23034. declare module BABYLON {
  23035. /**
  23036. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23037. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23038. * You can then easily use it as a reflectionTexture on a flat surface.
  23039. * In case the surface is not a plane, please consider relying on reflection probes.
  23040. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23041. */
  23042. export class MirrorTexture extends RenderTargetTexture {
  23043. private scene;
  23044. /**
  23045. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23046. * 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.
  23047. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23048. */
  23049. mirrorPlane: Plane;
  23050. /**
  23051. * Define the blur ratio used to blur the reflection if needed.
  23052. */
  23053. set blurRatio(value: number);
  23054. get blurRatio(): number;
  23055. /**
  23056. * Define the adaptive blur kernel used to blur the reflection if needed.
  23057. * This will autocompute the closest best match for the `blurKernel`
  23058. */
  23059. set adaptiveBlurKernel(value: number);
  23060. /**
  23061. * Define the blur kernel used to blur the reflection if needed.
  23062. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23063. */
  23064. set blurKernel(value: number);
  23065. /**
  23066. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23067. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23068. */
  23069. set blurKernelX(value: number);
  23070. get blurKernelX(): number;
  23071. /**
  23072. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23073. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23074. */
  23075. set blurKernelY(value: number);
  23076. get blurKernelY(): number;
  23077. private _autoComputeBlurKernel;
  23078. protected _onRatioRescale(): void;
  23079. private _updateGammaSpace;
  23080. private _imageProcessingConfigChangeObserver;
  23081. private _transformMatrix;
  23082. private _mirrorMatrix;
  23083. private _savedViewMatrix;
  23084. private _blurX;
  23085. private _blurY;
  23086. private _adaptiveBlurKernel;
  23087. private _blurKernelX;
  23088. private _blurKernelY;
  23089. private _blurRatio;
  23090. /**
  23091. * Instantiates a Mirror Texture.
  23092. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23093. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23094. * You can then easily use it as a reflectionTexture on a flat surface.
  23095. * In case the surface is not a plane, please consider relying on reflection probes.
  23096. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23097. * @param name
  23098. * @param size
  23099. * @param scene
  23100. * @param generateMipMaps
  23101. * @param type
  23102. * @param samplingMode
  23103. * @param generateDepthBuffer
  23104. */
  23105. constructor(name: string, size: number | {
  23106. width: number;
  23107. height: number;
  23108. } | {
  23109. ratio: number;
  23110. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23111. private _preparePostProcesses;
  23112. /**
  23113. * Clone the mirror texture.
  23114. * @returns the cloned texture
  23115. */
  23116. clone(): MirrorTexture;
  23117. /**
  23118. * Serialize the texture to a JSON representation you could use in Parse later on
  23119. * @returns the serialized JSON representation
  23120. */
  23121. serialize(): any;
  23122. /**
  23123. * Dispose the texture and release its associated resources.
  23124. */
  23125. dispose(): void;
  23126. }
  23127. }
  23128. declare module BABYLON {
  23129. /**
  23130. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23131. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23132. */
  23133. export class Texture extends BaseTexture {
  23134. /**
  23135. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23136. */
  23137. static SerializeBuffers: boolean;
  23138. /** @hidden */
  23139. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23140. /** @hidden */
  23141. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23142. /** @hidden */
  23143. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23144. /** nearest is mag = nearest and min = nearest and mip = linear */
  23145. static readonly NEAREST_SAMPLINGMODE: number;
  23146. /** nearest is mag = nearest and min = nearest and mip = linear */
  23147. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23148. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23149. static readonly BILINEAR_SAMPLINGMODE: number;
  23150. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23151. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23152. /** Trilinear is mag = linear and min = linear and mip = linear */
  23153. static readonly TRILINEAR_SAMPLINGMODE: number;
  23154. /** Trilinear is mag = linear and min = linear and mip = linear */
  23155. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23156. /** mag = nearest and min = nearest and mip = nearest */
  23157. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23158. /** mag = nearest and min = linear and mip = nearest */
  23159. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23160. /** mag = nearest and min = linear and mip = linear */
  23161. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23162. /** mag = nearest and min = linear and mip = none */
  23163. static readonly NEAREST_LINEAR: number;
  23164. /** mag = nearest and min = nearest and mip = none */
  23165. static readonly NEAREST_NEAREST: number;
  23166. /** mag = linear and min = nearest and mip = nearest */
  23167. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23168. /** mag = linear and min = nearest and mip = linear */
  23169. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23170. /** mag = linear and min = linear and mip = none */
  23171. static readonly LINEAR_LINEAR: number;
  23172. /** mag = linear and min = nearest and mip = none */
  23173. static readonly LINEAR_NEAREST: number;
  23174. /** Explicit coordinates mode */
  23175. static readonly EXPLICIT_MODE: number;
  23176. /** Spherical coordinates mode */
  23177. static readonly SPHERICAL_MODE: number;
  23178. /** Planar coordinates mode */
  23179. static readonly PLANAR_MODE: number;
  23180. /** Cubic coordinates mode */
  23181. static readonly CUBIC_MODE: number;
  23182. /** Projection coordinates mode */
  23183. static readonly PROJECTION_MODE: number;
  23184. /** Inverse Cubic coordinates mode */
  23185. static readonly SKYBOX_MODE: number;
  23186. /** Inverse Cubic coordinates mode */
  23187. static readonly INVCUBIC_MODE: number;
  23188. /** Equirectangular coordinates mode */
  23189. static readonly EQUIRECTANGULAR_MODE: number;
  23190. /** Equirectangular Fixed coordinates mode */
  23191. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23192. /** Equirectangular Fixed Mirrored coordinates mode */
  23193. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23194. /** Texture is not repeating outside of 0..1 UVs */
  23195. static readonly CLAMP_ADDRESSMODE: number;
  23196. /** Texture is repeating outside of 0..1 UVs */
  23197. static readonly WRAP_ADDRESSMODE: number;
  23198. /** Texture is repeating and mirrored */
  23199. static readonly MIRROR_ADDRESSMODE: number;
  23200. /**
  23201. * 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
  23202. */
  23203. static UseSerializedUrlIfAny: boolean;
  23204. /**
  23205. * Define the url of the texture.
  23206. */
  23207. url: Nullable<string>;
  23208. /**
  23209. * Define an offset on the texture to offset the u coordinates of the UVs
  23210. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23211. */
  23212. uOffset: number;
  23213. /**
  23214. * Define an offset on the texture to offset the v coordinates of the UVs
  23215. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23216. */
  23217. vOffset: number;
  23218. /**
  23219. * Define an offset on the texture to scale the u coordinates of the UVs
  23220. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23221. */
  23222. uScale: number;
  23223. /**
  23224. * Define an offset on the texture to scale the v coordinates of the UVs
  23225. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23226. */
  23227. vScale: number;
  23228. /**
  23229. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23230. * @see https://doc.babylonjs.com/how_to/more_materials
  23231. */
  23232. uAng: number;
  23233. /**
  23234. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23235. * @see https://doc.babylonjs.com/how_to/more_materials
  23236. */
  23237. vAng: number;
  23238. /**
  23239. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23240. * @see https://doc.babylonjs.com/how_to/more_materials
  23241. */
  23242. wAng: number;
  23243. /**
  23244. * Defines the center of rotation (U)
  23245. */
  23246. uRotationCenter: number;
  23247. /**
  23248. * Defines the center of rotation (V)
  23249. */
  23250. vRotationCenter: number;
  23251. /**
  23252. * Defines the center of rotation (W)
  23253. */
  23254. wRotationCenter: number;
  23255. /**
  23256. * Are mip maps generated for this texture or not.
  23257. */
  23258. get noMipmap(): boolean;
  23259. /**
  23260. * List of inspectable custom properties (used by the Inspector)
  23261. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23262. */
  23263. inspectableCustomProperties: Nullable<IInspectable[]>;
  23264. private _noMipmap;
  23265. /** @hidden */
  23266. _invertY: boolean;
  23267. private _rowGenerationMatrix;
  23268. private _cachedTextureMatrix;
  23269. private _projectionModeMatrix;
  23270. private _t0;
  23271. private _t1;
  23272. private _t2;
  23273. private _cachedUOffset;
  23274. private _cachedVOffset;
  23275. private _cachedUScale;
  23276. private _cachedVScale;
  23277. private _cachedUAng;
  23278. private _cachedVAng;
  23279. private _cachedWAng;
  23280. private _cachedProjectionMatrixId;
  23281. private _cachedCoordinatesMode;
  23282. /** @hidden */
  23283. protected _initialSamplingMode: number;
  23284. /** @hidden */
  23285. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23286. private _deleteBuffer;
  23287. protected _format: Nullable<number>;
  23288. private _delayedOnLoad;
  23289. private _delayedOnError;
  23290. private _mimeType?;
  23291. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23292. get mimeType(): string | undefined;
  23293. /**
  23294. * Observable triggered once the texture has been loaded.
  23295. */
  23296. onLoadObservable: Observable<Texture>;
  23297. protected _isBlocking: boolean;
  23298. /**
  23299. * Is the texture preventing material to render while loading.
  23300. * If false, a default texture will be used instead of the loading one during the preparation step.
  23301. */
  23302. set isBlocking(value: boolean);
  23303. get isBlocking(): boolean;
  23304. /**
  23305. * Get the current sampling mode associated with the texture.
  23306. */
  23307. get samplingMode(): number;
  23308. /**
  23309. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23310. */
  23311. get invertY(): boolean;
  23312. /**
  23313. * Instantiates a new texture.
  23314. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23315. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23316. * @param url defines the url of the picture to load as a texture
  23317. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23318. * @param noMipmap defines if the texture will require mip maps or not
  23319. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23320. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23321. * @param onLoad defines a callback triggered when the texture has been loaded
  23322. * @param onError defines a callback triggered when an error occurred during the loading session
  23323. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23324. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23325. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23326. * @param mimeType defines an optional mime type information
  23327. */
  23328. 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);
  23329. /**
  23330. * Update the url (and optional buffer) of this texture if url was null during construction.
  23331. * @param url the url of the texture
  23332. * @param buffer the buffer of the texture (defaults to null)
  23333. * @param onLoad callback called when the texture is loaded (defaults to null)
  23334. */
  23335. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23336. /**
  23337. * Finish the loading sequence of a texture flagged as delayed load.
  23338. * @hidden
  23339. */
  23340. delayLoad(): void;
  23341. private _prepareRowForTextureGeneration;
  23342. /**
  23343. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23344. * @returns the transform matrix of the texture.
  23345. */
  23346. getTextureMatrix(uBase?: number): Matrix;
  23347. /**
  23348. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23349. * @returns The reflection texture transform
  23350. */
  23351. getReflectionTextureMatrix(): Matrix;
  23352. /**
  23353. * Clones the texture.
  23354. * @returns the cloned texture
  23355. */
  23356. clone(): Texture;
  23357. /**
  23358. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23359. * @returns The JSON representation of the texture
  23360. */
  23361. serialize(): any;
  23362. /**
  23363. * Get the current class name of the texture useful for serialization or dynamic coding.
  23364. * @returns "Texture"
  23365. */
  23366. getClassName(): string;
  23367. /**
  23368. * Dispose the texture and release its associated resources.
  23369. */
  23370. dispose(): void;
  23371. /**
  23372. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23373. * @param parsedTexture Define the JSON representation of the texture
  23374. * @param scene Define the scene the parsed texture should be instantiated in
  23375. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23376. * @returns The parsed texture if successful
  23377. */
  23378. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23379. /**
  23380. * Creates a texture from its base 64 representation.
  23381. * @param data Define the base64 payload without the data: prefix
  23382. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23383. * @param scene Define the scene the texture should belong to
  23384. * @param noMipmap Forces the texture to not create mip map information if true
  23385. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23386. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23387. * @param onLoad define a callback triggered when the texture has been loaded
  23388. * @param onError define a callback triggered when an error occurred during the loading session
  23389. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23390. * @returns the created texture
  23391. */
  23392. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23393. /**
  23394. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23395. * @param data Define the base64 payload without the data: prefix
  23396. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23397. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23398. * @param scene Define the scene the texture should belong to
  23399. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23400. * @param noMipmap Forces the texture to not create mip map information if true
  23401. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23402. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23403. * @param onLoad define a callback triggered when the texture has been loaded
  23404. * @param onError define a callback triggered when an error occurred during the loading session
  23405. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23406. * @returns the created texture
  23407. */
  23408. 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;
  23409. }
  23410. }
  23411. declare module BABYLON {
  23412. /**
  23413. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23414. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23415. */
  23416. export class PostProcessManager {
  23417. private _scene;
  23418. private _indexBuffer;
  23419. private _vertexBuffers;
  23420. /**
  23421. * Creates a new instance PostProcess
  23422. * @param scene The scene that the post process is associated with.
  23423. */
  23424. constructor(scene: Scene);
  23425. private _prepareBuffers;
  23426. private _buildIndexBuffer;
  23427. /**
  23428. * Rebuilds the vertex buffers of the manager.
  23429. * @hidden
  23430. */
  23431. _rebuild(): void;
  23432. /**
  23433. * Prepares a frame to be run through a post process.
  23434. * @param sourceTexture The input texture to the post procesess. (default: null)
  23435. * @param postProcesses An array of post processes to be run. (default: null)
  23436. * @returns True if the post processes were able to be run.
  23437. * @hidden
  23438. */
  23439. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23440. /**
  23441. * Manually render a set of post processes to a texture.
  23442. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23443. * @param postProcesses An array of post processes to be run.
  23444. * @param targetTexture The target texture to render to.
  23445. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23446. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23447. * @param lodLevel defines which lod of the texture to render to
  23448. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23449. */
  23450. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23451. /**
  23452. * Finalize the result of the output of the postprocesses.
  23453. * @param doNotPresent If true the result will not be displayed to the screen.
  23454. * @param targetTexture The target texture to render to.
  23455. * @param faceIndex The index of the face to bind the target texture to.
  23456. * @param postProcesses The array of post processes to render.
  23457. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23458. * @hidden
  23459. */
  23460. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23461. /**
  23462. * Disposes of the post process manager.
  23463. */
  23464. dispose(): void;
  23465. }
  23466. }
  23467. declare module BABYLON {
  23468. /**
  23469. * This Helps creating a texture that will be created from a camera in your scene.
  23470. * It is basically a dynamic texture that could be used to create special effects for instance.
  23471. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23472. */
  23473. export class RenderTargetTexture extends Texture {
  23474. /**
  23475. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23476. */
  23477. static readonly REFRESHRATE_RENDER_ONCE: number;
  23478. /**
  23479. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23480. */
  23481. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23482. /**
  23483. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23484. * the central point of your effect and can save a lot of performances.
  23485. */
  23486. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23487. /**
  23488. * Use this predicate to dynamically define the list of mesh you want to render.
  23489. * If set, the renderList property will be overwritten.
  23490. */
  23491. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23492. private _renderList;
  23493. /**
  23494. * Use this list to define the list of mesh you want to render.
  23495. */
  23496. get renderList(): Nullable<Array<AbstractMesh>>;
  23497. set renderList(value: Nullable<Array<AbstractMesh>>);
  23498. /**
  23499. * Use this function to overload the renderList array at rendering time.
  23500. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23501. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23502. * the cube (if the RTT is a cube, else layerOrFace=0).
  23503. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23504. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23505. * hold dummy elements!
  23506. */
  23507. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23508. private _hookArray;
  23509. /**
  23510. * Define if particles should be rendered in your texture.
  23511. */
  23512. renderParticles: boolean;
  23513. /**
  23514. * Define if sprites should be rendered in your texture.
  23515. */
  23516. renderSprites: boolean;
  23517. /**
  23518. * Define the camera used to render the texture.
  23519. */
  23520. activeCamera: Nullable<Camera>;
  23521. /**
  23522. * Override the mesh isReady function with your own one.
  23523. */
  23524. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23525. /**
  23526. * Override the render function of the texture with your own one.
  23527. */
  23528. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23529. /**
  23530. * Define if camera post processes should be use while rendering the texture.
  23531. */
  23532. useCameraPostProcesses: boolean;
  23533. /**
  23534. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23535. */
  23536. ignoreCameraViewport: boolean;
  23537. private _postProcessManager;
  23538. private _postProcesses;
  23539. private _resizeObserver;
  23540. /**
  23541. * An event triggered when the texture is unbind.
  23542. */
  23543. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23544. /**
  23545. * An event triggered when the texture is unbind.
  23546. */
  23547. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23548. private _onAfterUnbindObserver;
  23549. /**
  23550. * Set a after unbind callback in the texture.
  23551. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23552. */
  23553. set onAfterUnbind(callback: () => void);
  23554. /**
  23555. * An event triggered before rendering the texture
  23556. */
  23557. onBeforeRenderObservable: Observable<number>;
  23558. private _onBeforeRenderObserver;
  23559. /**
  23560. * Set a before render callback in the texture.
  23561. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23562. */
  23563. set onBeforeRender(callback: (faceIndex: number) => void);
  23564. /**
  23565. * An event triggered after rendering the texture
  23566. */
  23567. onAfterRenderObservable: Observable<number>;
  23568. private _onAfterRenderObserver;
  23569. /**
  23570. * Set a after render callback in the texture.
  23571. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23572. */
  23573. set onAfterRender(callback: (faceIndex: number) => void);
  23574. /**
  23575. * An event triggered after the texture clear
  23576. */
  23577. onClearObservable: Observable<Engine>;
  23578. private _onClearObserver;
  23579. /**
  23580. * Set a clear callback in the texture.
  23581. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23582. */
  23583. set onClear(callback: (Engine: Engine) => void);
  23584. /**
  23585. * An event triggered when the texture is resized.
  23586. */
  23587. onResizeObservable: Observable<RenderTargetTexture>;
  23588. /**
  23589. * Define the clear color of the Render Target if it should be different from the scene.
  23590. */
  23591. clearColor: Color4;
  23592. protected _size: number | {
  23593. width: number;
  23594. height: number;
  23595. layers?: number;
  23596. };
  23597. protected _initialSizeParameter: number | {
  23598. width: number;
  23599. height: number;
  23600. } | {
  23601. ratio: number;
  23602. };
  23603. protected _sizeRatio: Nullable<number>;
  23604. /** @hidden */
  23605. _generateMipMaps: boolean;
  23606. protected _renderingManager: RenderingManager;
  23607. /** @hidden */
  23608. _waitingRenderList?: string[];
  23609. protected _doNotChangeAspectRatio: boolean;
  23610. protected _currentRefreshId: number;
  23611. protected _refreshRate: number;
  23612. protected _textureMatrix: Matrix;
  23613. protected _samples: number;
  23614. protected _renderTargetOptions: RenderTargetCreationOptions;
  23615. /**
  23616. * Gets render target creation options that were used.
  23617. */
  23618. get renderTargetOptions(): RenderTargetCreationOptions;
  23619. protected _onRatioRescale(): void;
  23620. /**
  23621. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23622. * It must define where the camera used to render the texture is set
  23623. */
  23624. boundingBoxPosition: Vector3;
  23625. private _boundingBoxSize;
  23626. /**
  23627. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23628. * When defined, the cubemap will switch to local mode
  23629. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23630. * @example https://www.babylonjs-playground.com/#RNASML
  23631. */
  23632. set boundingBoxSize(value: Vector3);
  23633. get boundingBoxSize(): Vector3;
  23634. /**
  23635. * In case the RTT has been created with a depth texture, get the associated
  23636. * depth texture.
  23637. * Otherwise, return null.
  23638. */
  23639. get depthStencilTexture(): Nullable<InternalTexture>;
  23640. /**
  23641. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23642. * or used a shadow, depth texture...
  23643. * @param name The friendly name of the texture
  23644. * @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)
  23645. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23646. * @param generateMipMaps True if mip maps need to be generated after render.
  23647. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23648. * @param type The type of the buffer in the RTT (int, half float, float...)
  23649. * @param isCube True if a cube texture needs to be created
  23650. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23651. * @param generateDepthBuffer True to generate a depth buffer
  23652. * @param generateStencilBuffer True to generate a stencil buffer
  23653. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23654. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23655. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23656. */
  23657. constructor(name: string, size: number | {
  23658. width: number;
  23659. height: number;
  23660. layers?: number;
  23661. } | {
  23662. ratio: number;
  23663. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23664. /**
  23665. * Creates a depth stencil texture.
  23666. * This is only available in WebGL 2 or with the depth texture extension available.
  23667. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23668. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23669. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23670. */
  23671. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23672. private _processSizeParameter;
  23673. /**
  23674. * Define the number of samples to use in case of MSAA.
  23675. * It defaults to one meaning no MSAA has been enabled.
  23676. */
  23677. get samples(): number;
  23678. set samples(value: number);
  23679. /**
  23680. * Resets the refresh counter of the texture and start bak from scratch.
  23681. * Could be useful to regenerate the texture if it is setup to render only once.
  23682. */
  23683. resetRefreshCounter(): void;
  23684. /**
  23685. * Define the refresh rate of the texture or the rendering frequency.
  23686. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23687. */
  23688. get refreshRate(): number;
  23689. set refreshRate(value: number);
  23690. /**
  23691. * Adds a post process to the render target rendering passes.
  23692. * @param postProcess define the post process to add
  23693. */
  23694. addPostProcess(postProcess: PostProcess): void;
  23695. /**
  23696. * Clear all the post processes attached to the render target
  23697. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23698. */
  23699. clearPostProcesses(dispose?: boolean): void;
  23700. /**
  23701. * Remove one of the post process from the list of attached post processes to the texture
  23702. * @param postProcess define the post process to remove from the list
  23703. */
  23704. removePostProcess(postProcess: PostProcess): void;
  23705. /** @hidden */
  23706. _shouldRender(): boolean;
  23707. /**
  23708. * Gets the actual render size of the texture.
  23709. * @returns the width of the render size
  23710. */
  23711. getRenderSize(): number;
  23712. /**
  23713. * Gets the actual render width of the texture.
  23714. * @returns the width of the render size
  23715. */
  23716. getRenderWidth(): number;
  23717. /**
  23718. * Gets the actual render height of the texture.
  23719. * @returns the height of the render size
  23720. */
  23721. getRenderHeight(): number;
  23722. /**
  23723. * Gets the actual number of layers of the texture.
  23724. * @returns the number of layers
  23725. */
  23726. getRenderLayers(): number;
  23727. /**
  23728. * Get if the texture can be rescaled or not.
  23729. */
  23730. get canRescale(): boolean;
  23731. /**
  23732. * Resize the texture using a ratio.
  23733. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23734. */
  23735. scale(ratio: number): void;
  23736. /**
  23737. * Get the texture reflection matrix used to rotate/transform the reflection.
  23738. * @returns the reflection matrix
  23739. */
  23740. getReflectionTextureMatrix(): Matrix;
  23741. /**
  23742. * Resize the texture to a new desired size.
  23743. * Be carrefull as it will recreate all the data in the new texture.
  23744. * @param size Define the new size. It can be:
  23745. * - a number for squared texture,
  23746. * - an object containing { width: number, height: number }
  23747. * - or an object containing a ratio { ratio: number }
  23748. */
  23749. resize(size: number | {
  23750. width: number;
  23751. height: number;
  23752. } | {
  23753. ratio: number;
  23754. }): void;
  23755. private _defaultRenderListPrepared;
  23756. /**
  23757. * Renders all the objects from the render list into the texture.
  23758. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23759. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23760. */
  23761. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23762. private _bestReflectionRenderTargetDimension;
  23763. private _prepareRenderingManager;
  23764. /**
  23765. * @hidden
  23766. * @param faceIndex face index to bind to if this is a cubetexture
  23767. * @param layer defines the index of the texture to bind in the array
  23768. */
  23769. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23770. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23771. private renderToTarget;
  23772. /**
  23773. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23774. * This allowed control for front to back rendering or reversly depending of the special needs.
  23775. *
  23776. * @param renderingGroupId The rendering group id corresponding to its index
  23777. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23778. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23779. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23780. */
  23781. 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;
  23782. /**
  23783. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23784. *
  23785. * @param renderingGroupId The rendering group id corresponding to its index
  23786. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23787. */
  23788. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23789. /**
  23790. * Clones the texture.
  23791. * @returns the cloned texture
  23792. */
  23793. clone(): RenderTargetTexture;
  23794. /**
  23795. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23796. * @returns The JSON representation of the texture
  23797. */
  23798. serialize(): any;
  23799. /**
  23800. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23801. */
  23802. disposeFramebufferObjects(): void;
  23803. /**
  23804. * Dispose the texture and release its associated resources.
  23805. */
  23806. dispose(): void;
  23807. /** @hidden */
  23808. _rebuild(): void;
  23809. /**
  23810. * Clear the info related to rendering groups preventing retention point in material dispose.
  23811. */
  23812. freeRenderingGroups(): void;
  23813. /**
  23814. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23815. * @returns the view count
  23816. */
  23817. getViewCount(): number;
  23818. }
  23819. }
  23820. declare module BABYLON {
  23821. /**
  23822. * Class used to manipulate GUIDs
  23823. */
  23824. export class GUID {
  23825. /**
  23826. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23827. * Be aware Math.random() could cause collisions, but:
  23828. * "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"
  23829. * @returns a pseudo random id
  23830. */
  23831. static RandomId(): string;
  23832. }
  23833. }
  23834. declare module BABYLON {
  23835. /**
  23836. * Options to be used when creating a shadow depth material
  23837. */
  23838. export interface IIOptionShadowDepthMaterial {
  23839. /** Variables in the vertex shader code that need to have their names remapped.
  23840. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23841. * "var_name" should be either: worldPos or vNormalW
  23842. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23843. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23844. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23845. */
  23846. remappedVariables?: string[];
  23847. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23848. standalone?: boolean;
  23849. }
  23850. /**
  23851. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23852. */
  23853. export class ShadowDepthWrapper {
  23854. private _scene;
  23855. private _options?;
  23856. private _baseMaterial;
  23857. private _onEffectCreatedObserver;
  23858. private _subMeshToEffect;
  23859. private _subMeshToDepthEffect;
  23860. private _meshes;
  23861. /** @hidden */
  23862. _matriceNames: any;
  23863. /** Gets the standalone status of the wrapper */
  23864. get standalone(): boolean;
  23865. /** Gets the base material the wrapper is built upon */
  23866. get baseMaterial(): Material;
  23867. /**
  23868. * Instantiate a new shadow depth wrapper.
  23869. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23870. * generate the shadow depth map. For more information, please refer to the documentation:
  23871. * https://doc.babylonjs.com/babylon101/shadows
  23872. * @param baseMaterial Material to wrap
  23873. * @param scene Define the scene the material belongs to
  23874. * @param options Options used to create the wrapper
  23875. */
  23876. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23877. /**
  23878. * Gets the effect to use to generate the depth map
  23879. * @param subMesh subMesh to get the effect for
  23880. * @param shadowGenerator shadow generator to get the effect for
  23881. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23882. */
  23883. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23884. /**
  23885. * Specifies that the submesh is ready to be used for depth rendering
  23886. * @param subMesh submesh to check
  23887. * @param defines the list of defines to take into account when checking the effect
  23888. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23889. * @param useInstances specifies that instances should be used
  23890. * @returns a boolean indicating that the submesh is ready or not
  23891. */
  23892. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23893. /**
  23894. * Disposes the resources
  23895. */
  23896. dispose(): void;
  23897. private _makeEffect;
  23898. }
  23899. }
  23900. declare module BABYLON {
  23901. interface ThinEngine {
  23902. /**
  23903. * Unbind a list of render target textures from the webGL context
  23904. * This is used only when drawBuffer extension or webGL2 are active
  23905. * @param textures defines the render target textures to unbind
  23906. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23907. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23908. */
  23909. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23910. /**
  23911. * Create a multi render target texture
  23912. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23913. * @param size defines the size of the texture
  23914. * @param options defines the creation options
  23915. * @returns the cube texture as an InternalTexture
  23916. */
  23917. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23918. /**
  23919. * Update the sample count for a given multiple render target texture
  23920. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23921. * @param textures defines the textures to update
  23922. * @param samples defines the sample count to set
  23923. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23924. */
  23925. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23926. /**
  23927. * Select a subsets of attachments to draw to.
  23928. * @param attachments gl attachments
  23929. */
  23930. bindAttachments(attachments: number[]): void;
  23931. }
  23932. }
  23933. declare module BABYLON {
  23934. /**
  23935. * Creation options of the multi render target texture.
  23936. */
  23937. export interface IMultiRenderTargetOptions {
  23938. /**
  23939. * Define if the texture needs to create mip maps after render.
  23940. */
  23941. generateMipMaps?: boolean;
  23942. /**
  23943. * Define the types of all the draw buffers we want to create
  23944. */
  23945. types?: number[];
  23946. /**
  23947. * Define the sampling modes of all the draw buffers we want to create
  23948. */
  23949. samplingModes?: number[];
  23950. /**
  23951. * Define if a depth buffer is required
  23952. */
  23953. generateDepthBuffer?: boolean;
  23954. /**
  23955. * Define if a stencil buffer is required
  23956. */
  23957. generateStencilBuffer?: boolean;
  23958. /**
  23959. * Define if a depth texture is required instead of a depth buffer
  23960. */
  23961. generateDepthTexture?: boolean;
  23962. /**
  23963. * Define the number of desired draw buffers
  23964. */
  23965. textureCount?: number;
  23966. /**
  23967. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23968. */
  23969. doNotChangeAspectRatio?: boolean;
  23970. /**
  23971. * Define the default type of the buffers we are creating
  23972. */
  23973. defaultType?: number;
  23974. }
  23975. /**
  23976. * A multi render target, like a render target provides the ability to render to a texture.
  23977. * Unlike the render target, it can render to several draw buffers in one draw.
  23978. * This is specially interesting in deferred rendering or for any effects requiring more than
  23979. * just one color from a single pass.
  23980. */
  23981. export class MultiRenderTarget extends RenderTargetTexture {
  23982. private _internalTextures;
  23983. private _textures;
  23984. private _multiRenderTargetOptions;
  23985. private _count;
  23986. /**
  23987. * Get if draw buffers are currently supported by the used hardware and browser.
  23988. */
  23989. get isSupported(): boolean;
  23990. /**
  23991. * Get the list of textures generated by the multi render target.
  23992. */
  23993. get textures(): Texture[];
  23994. /**
  23995. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23996. */
  23997. get count(): number;
  23998. /**
  23999. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24000. */
  24001. get depthTexture(): Texture;
  24002. /**
  24003. * Set the wrapping mode on U of all the textures we are rendering to.
  24004. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24005. */
  24006. set wrapU(wrap: number);
  24007. /**
  24008. * Set the wrapping mode on V of all the textures we are rendering to.
  24009. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24010. */
  24011. set wrapV(wrap: number);
  24012. /**
  24013. * Instantiate a new multi render target texture.
  24014. * A multi render target, like a render target provides the ability to render to a texture.
  24015. * Unlike the render target, it can render to several draw buffers in one draw.
  24016. * This is specially interesting in deferred rendering or for any effects requiring more than
  24017. * just one color from a single pass.
  24018. * @param name Define the name of the texture
  24019. * @param size Define the size of the buffers to render to
  24020. * @param count Define the number of target we are rendering into
  24021. * @param scene Define the scene the texture belongs to
  24022. * @param options Define the options used to create the multi render target
  24023. */
  24024. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24025. /** @hidden */
  24026. _rebuild(): void;
  24027. private _createInternalTextures;
  24028. private _createTextures;
  24029. /**
  24030. * Define the number of samples used if MSAA is enabled.
  24031. */
  24032. get samples(): number;
  24033. set samples(value: number);
  24034. /**
  24035. * Resize all the textures in the multi render target.
  24036. * Be carrefull as it will recreate all the data in the new texture.
  24037. * @param size Define the new size
  24038. */
  24039. resize(size: any): void;
  24040. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24041. /**
  24042. * Dispose the render targets and their associated resources
  24043. */
  24044. dispose(): void;
  24045. /**
  24046. * Release all the underlying texture used as draw buffers.
  24047. */
  24048. releaseInternalTextures(): void;
  24049. }
  24050. }
  24051. declare module BABYLON {
  24052. /** @hidden */
  24053. export var imageProcessingPixelShader: {
  24054. name: string;
  24055. shader: string;
  24056. };
  24057. }
  24058. declare module BABYLON {
  24059. /**
  24060. * ImageProcessingPostProcess
  24061. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24062. */
  24063. export class ImageProcessingPostProcess extends PostProcess {
  24064. /**
  24065. * Default configuration related to image processing available in the PBR Material.
  24066. */
  24067. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24068. /**
  24069. * Gets the image processing configuration used either in this material.
  24070. */
  24071. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24072. /**
  24073. * Sets the Default image processing configuration used either in the this material.
  24074. *
  24075. * If sets to null, the scene one is in use.
  24076. */
  24077. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24078. /**
  24079. * Keep track of the image processing observer to allow dispose and replace.
  24080. */
  24081. private _imageProcessingObserver;
  24082. /**
  24083. * Attaches a new image processing configuration to the PBR Material.
  24084. * @param configuration
  24085. */
  24086. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24087. /**
  24088. * If the post process is supported.
  24089. */
  24090. get isSupported(): boolean;
  24091. /**
  24092. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24093. */
  24094. get colorCurves(): Nullable<ColorCurves>;
  24095. /**
  24096. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24097. */
  24098. set colorCurves(value: Nullable<ColorCurves>);
  24099. /**
  24100. * Gets wether the color curves effect is enabled.
  24101. */
  24102. get colorCurvesEnabled(): boolean;
  24103. /**
  24104. * Sets wether the color curves effect is enabled.
  24105. */
  24106. set colorCurvesEnabled(value: boolean);
  24107. /**
  24108. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24109. */
  24110. get colorGradingTexture(): Nullable<BaseTexture>;
  24111. /**
  24112. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24113. */
  24114. set colorGradingTexture(value: Nullable<BaseTexture>);
  24115. /**
  24116. * Gets wether the color grading effect is enabled.
  24117. */
  24118. get colorGradingEnabled(): boolean;
  24119. /**
  24120. * Gets wether the color grading effect is enabled.
  24121. */
  24122. set colorGradingEnabled(value: boolean);
  24123. /**
  24124. * Gets exposure used in the effect.
  24125. */
  24126. get exposure(): number;
  24127. /**
  24128. * Sets exposure used in the effect.
  24129. */
  24130. set exposure(value: number);
  24131. /**
  24132. * Gets wether tonemapping is enabled or not.
  24133. */
  24134. get toneMappingEnabled(): boolean;
  24135. /**
  24136. * Sets wether tonemapping is enabled or not
  24137. */
  24138. set toneMappingEnabled(value: boolean);
  24139. /**
  24140. * Gets the type of tone mapping effect.
  24141. */
  24142. get toneMappingType(): number;
  24143. /**
  24144. * Sets the type of tone mapping effect.
  24145. */
  24146. set toneMappingType(value: number);
  24147. /**
  24148. * Gets contrast used in the effect.
  24149. */
  24150. get contrast(): number;
  24151. /**
  24152. * Sets contrast used in the effect.
  24153. */
  24154. set contrast(value: number);
  24155. /**
  24156. * Gets Vignette stretch size.
  24157. */
  24158. get vignetteStretch(): number;
  24159. /**
  24160. * Sets Vignette stretch size.
  24161. */
  24162. set vignetteStretch(value: number);
  24163. /**
  24164. * Gets Vignette centre X Offset.
  24165. */
  24166. get vignetteCentreX(): number;
  24167. /**
  24168. * Sets Vignette centre X Offset.
  24169. */
  24170. set vignetteCentreX(value: number);
  24171. /**
  24172. * Gets Vignette centre Y Offset.
  24173. */
  24174. get vignetteCentreY(): number;
  24175. /**
  24176. * Sets Vignette centre Y Offset.
  24177. */
  24178. set vignetteCentreY(value: number);
  24179. /**
  24180. * Gets Vignette weight or intensity of the vignette effect.
  24181. */
  24182. get vignetteWeight(): number;
  24183. /**
  24184. * Sets Vignette weight or intensity of the vignette effect.
  24185. */
  24186. set vignetteWeight(value: number);
  24187. /**
  24188. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24189. * if vignetteEnabled is set to true.
  24190. */
  24191. get vignetteColor(): Color4;
  24192. /**
  24193. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24194. * if vignetteEnabled is set to true.
  24195. */
  24196. set vignetteColor(value: Color4);
  24197. /**
  24198. * Gets Camera field of view used by the Vignette effect.
  24199. */
  24200. get vignetteCameraFov(): number;
  24201. /**
  24202. * Sets Camera field of view used by the Vignette effect.
  24203. */
  24204. set vignetteCameraFov(value: number);
  24205. /**
  24206. * Gets the vignette blend mode allowing different kind of effect.
  24207. */
  24208. get vignetteBlendMode(): number;
  24209. /**
  24210. * Sets the vignette blend mode allowing different kind of effect.
  24211. */
  24212. set vignetteBlendMode(value: number);
  24213. /**
  24214. * Gets wether the vignette effect is enabled.
  24215. */
  24216. get vignetteEnabled(): boolean;
  24217. /**
  24218. * Sets wether the vignette effect is enabled.
  24219. */
  24220. set vignetteEnabled(value: boolean);
  24221. private _fromLinearSpace;
  24222. /**
  24223. * Gets wether the input of the processing is in Gamma or Linear Space.
  24224. */
  24225. get fromLinearSpace(): boolean;
  24226. /**
  24227. * Sets wether the input of the processing is in Gamma or Linear Space.
  24228. */
  24229. set fromLinearSpace(value: boolean);
  24230. /**
  24231. * Defines cache preventing GC.
  24232. */
  24233. private _defines;
  24234. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24235. /**
  24236. * "ImageProcessingPostProcess"
  24237. * @returns "ImageProcessingPostProcess"
  24238. */
  24239. getClassName(): string;
  24240. /**
  24241. * @hidden
  24242. */
  24243. _updateParameters(): void;
  24244. dispose(camera?: Camera): void;
  24245. }
  24246. }
  24247. declare module BABYLON {
  24248. /** @hidden */
  24249. export var fibonacci: {
  24250. name: string;
  24251. shader: string;
  24252. };
  24253. }
  24254. declare module BABYLON {
  24255. /** @hidden */
  24256. export var subSurfaceScatteringFunctions: {
  24257. name: string;
  24258. shader: string;
  24259. };
  24260. }
  24261. declare module BABYLON {
  24262. /** @hidden */
  24263. export var diffusionProfile: {
  24264. name: string;
  24265. shader: string;
  24266. };
  24267. }
  24268. declare module BABYLON {
  24269. /** @hidden */
  24270. export var subSurfaceScatteringPixelShader: {
  24271. name: string;
  24272. shader: string;
  24273. };
  24274. }
  24275. declare module BABYLON {
  24276. /**
  24277. * Sub surface scattering post process
  24278. */
  24279. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24280. /**
  24281. * Gets a string identifying the name of the class
  24282. * @returns "SubSurfaceScatteringPostProcess" string
  24283. */
  24284. getClassName(): string;
  24285. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24286. }
  24287. }
  24288. declare module BABYLON {
  24289. /**
  24290. * Interface for defining prepass effects in the prepass post-process pipeline
  24291. */
  24292. export interface PrePassEffectConfiguration {
  24293. /**
  24294. * Post process to attach for this effect
  24295. */
  24296. postProcess: PostProcess;
  24297. /**
  24298. * Is the effect enabled
  24299. */
  24300. enabled: boolean;
  24301. /**
  24302. * Disposes the effect configuration
  24303. */
  24304. dispose(): void;
  24305. /**
  24306. * Disposes the effect configuration
  24307. */
  24308. createPostProcess: () => PostProcess;
  24309. }
  24310. }
  24311. declare module BABYLON {
  24312. /**
  24313. * Contains all parameters needed for the prepass to perform
  24314. * screen space subsurface scattering
  24315. */
  24316. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24317. private _ssDiffusionS;
  24318. private _ssFilterRadii;
  24319. private _ssDiffusionD;
  24320. /**
  24321. * Post process to attach for screen space subsurface scattering
  24322. */
  24323. postProcess: SubSurfaceScatteringPostProcess;
  24324. /**
  24325. * Diffusion profile color for subsurface scattering
  24326. */
  24327. get ssDiffusionS(): number[];
  24328. /**
  24329. * Diffusion profile max color channel value for subsurface scattering
  24330. */
  24331. get ssDiffusionD(): number[];
  24332. /**
  24333. * Diffusion profile filter radius for subsurface scattering
  24334. */
  24335. get ssFilterRadii(): number[];
  24336. /**
  24337. * Is subsurface enabled
  24338. */
  24339. enabled: boolean;
  24340. /**
  24341. * Diffusion profile colors for subsurface scattering
  24342. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24343. * See ...
  24344. * Note that you can only store up to 5 of them
  24345. */
  24346. ssDiffusionProfileColors: Color3[];
  24347. /**
  24348. * Defines the ratio real world => scene units.
  24349. * Used for subsurface scattering
  24350. */
  24351. metersPerUnit: number;
  24352. private _scene;
  24353. /**
  24354. * Builds a subsurface configuration object
  24355. * @param scene The scene
  24356. */
  24357. constructor(scene: Scene);
  24358. /**
  24359. * Adds a new diffusion profile.
  24360. * Useful for more realistic subsurface scattering on diverse materials.
  24361. * @param color The color of the diffusion profile. Should be the average color of the material.
  24362. * @return The index of the diffusion profile for the material subsurface configuration
  24363. */
  24364. addDiffusionProfile(color: Color3): number;
  24365. /**
  24366. * Creates the sss post process
  24367. * @return The created post process
  24368. */
  24369. createPostProcess(): SubSurfaceScatteringPostProcess;
  24370. /**
  24371. * Deletes all diffusion profiles.
  24372. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24373. */
  24374. clearAllDiffusionProfiles(): void;
  24375. /**
  24376. * Disposes this object
  24377. */
  24378. dispose(): void;
  24379. /**
  24380. * @hidden
  24381. * https://zero-radiance.github.io/post/sampling-diffusion/
  24382. *
  24383. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24384. * ------------------------------------------------------------------------------------
  24385. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24386. * PDF[r, phi, s] = r * R[r, phi, s]
  24387. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24388. * ------------------------------------------------------------------------------------
  24389. * We importance sample the color channel with the widest scattering distance.
  24390. */
  24391. getDiffusionProfileParameters(color: Color3): number;
  24392. /**
  24393. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24394. * 'u' is the random number (the value of the CDF): [0, 1).
  24395. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24396. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24397. */
  24398. private _sampleBurleyDiffusionProfile;
  24399. }
  24400. }
  24401. declare module BABYLON {
  24402. /**
  24403. * Renders a pre pass of the scene
  24404. * This means every mesh in the scene will be rendered to a render target texture
  24405. * And then this texture will be composited to the rendering canvas with post processes
  24406. * It is necessary for effects like subsurface scattering or deferred shading
  24407. */
  24408. export class PrePassRenderer {
  24409. /** @hidden */
  24410. static _SceneComponentInitialization: (scene: Scene) => void;
  24411. private _scene;
  24412. private _engine;
  24413. private _isDirty;
  24414. /**
  24415. * Number of textures in the multi render target texture where the scene is directly rendered
  24416. */
  24417. readonly mrtCount: number;
  24418. /**
  24419. * The render target where the scene is directly rendered
  24420. */
  24421. prePassRT: MultiRenderTarget;
  24422. private _mrtTypes;
  24423. private _multiRenderAttachments;
  24424. private _defaultAttachments;
  24425. private _clearAttachments;
  24426. private _postProcesses;
  24427. private readonly _clearColor;
  24428. /**
  24429. * Image processing post process for composition
  24430. */
  24431. imageProcessingPostProcess: ImageProcessingPostProcess;
  24432. /**
  24433. * Configuration for sub surface scattering post process
  24434. */
  24435. subSurfaceConfiguration: SubSurfaceConfiguration;
  24436. /**
  24437. * Should materials render their geometry on the MRT
  24438. */
  24439. materialsShouldRenderGeometry: boolean;
  24440. /**
  24441. * Should materials render the irradiance information on the MRT
  24442. */
  24443. materialsShouldRenderIrradiance: boolean;
  24444. private _enabled;
  24445. /**
  24446. * Indicates if the prepass is enabled
  24447. */
  24448. get enabled(): boolean;
  24449. /**
  24450. * How many samples are used for MSAA of the scene render target
  24451. */
  24452. get samples(): number;
  24453. set samples(n: number);
  24454. /**
  24455. * Instanciates a prepass renderer
  24456. * @param scene The scene
  24457. */
  24458. constructor(scene: Scene);
  24459. private _initializeAttachments;
  24460. private _createCompositionEffect;
  24461. /**
  24462. * Indicates if rendering a prepass is supported
  24463. */
  24464. get isSupported(): boolean;
  24465. /**
  24466. * Sets the proper output textures to draw in the engine.
  24467. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24468. */
  24469. bindAttachmentsForEffect(effect: Effect): void;
  24470. /**
  24471. * @hidden
  24472. */
  24473. _beforeCameraDraw(): void;
  24474. /**
  24475. * @hidden
  24476. */
  24477. _afterCameraDraw(): void;
  24478. private _checkRTSize;
  24479. private _bindFrameBuffer;
  24480. /**
  24481. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24482. */
  24483. clear(): void;
  24484. private _setState;
  24485. private _enable;
  24486. private _disable;
  24487. private _resetPostProcessChain;
  24488. private _bindPostProcessChain;
  24489. /**
  24490. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24491. */
  24492. markAsDirty(): void;
  24493. private _update;
  24494. /**
  24495. * Disposes the prepass renderer.
  24496. */
  24497. dispose(): void;
  24498. }
  24499. }
  24500. declare module BABYLON {
  24501. /**
  24502. * Options for compiling materials.
  24503. */
  24504. export interface IMaterialCompilationOptions {
  24505. /**
  24506. * Defines whether clip planes are enabled.
  24507. */
  24508. clipPlane: boolean;
  24509. /**
  24510. * Defines whether instances are enabled.
  24511. */
  24512. useInstances: boolean;
  24513. }
  24514. /**
  24515. * Options passed when calling customShaderNameResolve
  24516. */
  24517. export interface ICustomShaderNameResolveOptions {
  24518. /**
  24519. * 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
  24520. */
  24521. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24522. }
  24523. /**
  24524. * Base class for the main features of a material in Babylon.js
  24525. */
  24526. export class Material implements IAnimatable {
  24527. /**
  24528. * Returns the triangle fill mode
  24529. */
  24530. static readonly TriangleFillMode: number;
  24531. /**
  24532. * Returns the wireframe mode
  24533. */
  24534. static readonly WireFrameFillMode: number;
  24535. /**
  24536. * Returns the point fill mode
  24537. */
  24538. static readonly PointFillMode: number;
  24539. /**
  24540. * Returns the point list draw mode
  24541. */
  24542. static readonly PointListDrawMode: number;
  24543. /**
  24544. * Returns the line list draw mode
  24545. */
  24546. static readonly LineListDrawMode: number;
  24547. /**
  24548. * Returns the line loop draw mode
  24549. */
  24550. static readonly LineLoopDrawMode: number;
  24551. /**
  24552. * Returns the line strip draw mode
  24553. */
  24554. static readonly LineStripDrawMode: number;
  24555. /**
  24556. * Returns the triangle strip draw mode
  24557. */
  24558. static readonly TriangleStripDrawMode: number;
  24559. /**
  24560. * Returns the triangle fan draw mode
  24561. */
  24562. static readonly TriangleFanDrawMode: number;
  24563. /**
  24564. * Stores the clock-wise side orientation
  24565. */
  24566. static readonly ClockWiseSideOrientation: number;
  24567. /**
  24568. * Stores the counter clock-wise side orientation
  24569. */
  24570. static readonly CounterClockWiseSideOrientation: number;
  24571. /**
  24572. * The dirty texture flag value
  24573. */
  24574. static readonly TextureDirtyFlag: number;
  24575. /**
  24576. * The dirty light flag value
  24577. */
  24578. static readonly LightDirtyFlag: number;
  24579. /**
  24580. * The dirty fresnel flag value
  24581. */
  24582. static readonly FresnelDirtyFlag: number;
  24583. /**
  24584. * The dirty attribute flag value
  24585. */
  24586. static readonly AttributesDirtyFlag: number;
  24587. /**
  24588. * The dirty misc flag value
  24589. */
  24590. static readonly MiscDirtyFlag: number;
  24591. /**
  24592. * The all dirty flag value
  24593. */
  24594. static readonly AllDirtyFlag: number;
  24595. /**
  24596. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24597. */
  24598. static readonly MATERIAL_OPAQUE: number;
  24599. /**
  24600. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24601. */
  24602. static readonly MATERIAL_ALPHATEST: number;
  24603. /**
  24604. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24605. */
  24606. static readonly MATERIAL_ALPHABLEND: number;
  24607. /**
  24608. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24609. * They are also discarded below the alpha cutoff threshold to improve performances.
  24610. */
  24611. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24612. /**
  24613. * The Whiteout method is used to blend normals.
  24614. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24615. */
  24616. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24617. /**
  24618. * The Reoriented Normal Mapping method is used to blend normals.
  24619. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24620. */
  24621. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24622. /**
  24623. * Custom callback helping to override the default shader used in the material.
  24624. */
  24625. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24626. /**
  24627. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24628. */
  24629. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24630. /**
  24631. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24632. * This means that the material can keep using a previous shader while a new one is being compiled.
  24633. * This is mostly used when shader parallel compilation is supported (true by default)
  24634. */
  24635. allowShaderHotSwapping: boolean;
  24636. /**
  24637. * The ID of the material
  24638. */
  24639. id: string;
  24640. /**
  24641. * Gets or sets the unique id of the material
  24642. */
  24643. uniqueId: number;
  24644. /**
  24645. * The name of the material
  24646. */
  24647. name: string;
  24648. /**
  24649. * Gets or sets user defined metadata
  24650. */
  24651. metadata: any;
  24652. /**
  24653. * For internal use only. Please do not use.
  24654. */
  24655. reservedDataStore: any;
  24656. /**
  24657. * Specifies if the ready state should be checked on each call
  24658. */
  24659. checkReadyOnEveryCall: boolean;
  24660. /**
  24661. * Specifies if the ready state should be checked once
  24662. */
  24663. checkReadyOnlyOnce: boolean;
  24664. /**
  24665. * The state of the material
  24666. */
  24667. state: string;
  24668. /**
  24669. * If the material can be rendered to several textures with MRT extension
  24670. */
  24671. get canRenderToMRT(): boolean;
  24672. /**
  24673. * The alpha value of the material
  24674. */
  24675. protected _alpha: number;
  24676. /**
  24677. * List of inspectable custom properties (used by the Inspector)
  24678. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24679. */
  24680. inspectableCustomProperties: IInspectable[];
  24681. /**
  24682. * Sets the alpha value of the material
  24683. */
  24684. set alpha(value: number);
  24685. /**
  24686. * Gets the alpha value of the material
  24687. */
  24688. get alpha(): number;
  24689. /**
  24690. * Specifies if back face culling is enabled
  24691. */
  24692. protected _backFaceCulling: boolean;
  24693. /**
  24694. * Sets the back-face culling state
  24695. */
  24696. set backFaceCulling(value: boolean);
  24697. /**
  24698. * Gets the back-face culling state
  24699. */
  24700. get backFaceCulling(): boolean;
  24701. /**
  24702. * Stores the value for side orientation
  24703. */
  24704. sideOrientation: number;
  24705. /**
  24706. * Callback triggered when the material is compiled
  24707. */
  24708. onCompiled: Nullable<(effect: Effect) => void>;
  24709. /**
  24710. * Callback triggered when an error occurs
  24711. */
  24712. onError: Nullable<(effect: Effect, errors: string) => void>;
  24713. /**
  24714. * Callback triggered to get the render target textures
  24715. */
  24716. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24717. /**
  24718. * Gets a boolean indicating that current material needs to register RTT
  24719. */
  24720. get hasRenderTargetTextures(): boolean;
  24721. /**
  24722. * Specifies if the material should be serialized
  24723. */
  24724. doNotSerialize: boolean;
  24725. /**
  24726. * @hidden
  24727. */
  24728. _storeEffectOnSubMeshes: boolean;
  24729. /**
  24730. * Stores the animations for the material
  24731. */
  24732. animations: Nullable<Array<Animation>>;
  24733. /**
  24734. * An event triggered when the material is disposed
  24735. */
  24736. onDisposeObservable: Observable<Material>;
  24737. /**
  24738. * An observer which watches for dispose events
  24739. */
  24740. private _onDisposeObserver;
  24741. private _onUnBindObservable;
  24742. /**
  24743. * Called during a dispose event
  24744. */
  24745. set onDispose(callback: () => void);
  24746. private _onBindObservable;
  24747. /**
  24748. * An event triggered when the material is bound
  24749. */
  24750. get onBindObservable(): Observable<AbstractMesh>;
  24751. /**
  24752. * An observer which watches for bind events
  24753. */
  24754. private _onBindObserver;
  24755. /**
  24756. * Called during a bind event
  24757. */
  24758. set onBind(callback: (Mesh: AbstractMesh) => void);
  24759. /**
  24760. * An event triggered when the material is unbound
  24761. */
  24762. get onUnBindObservable(): Observable<Material>;
  24763. protected _onEffectCreatedObservable: Nullable<Observable<{
  24764. effect: Effect;
  24765. subMesh: Nullable<SubMesh>;
  24766. }>>;
  24767. /**
  24768. * An event triggered when the effect is (re)created
  24769. */
  24770. get onEffectCreatedObservable(): Observable<{
  24771. effect: Effect;
  24772. subMesh: Nullable<SubMesh>;
  24773. }>;
  24774. /**
  24775. * Stores the value of the alpha mode
  24776. */
  24777. private _alphaMode;
  24778. /**
  24779. * Sets the value of the alpha mode.
  24780. *
  24781. * | Value | Type | Description |
  24782. * | --- | --- | --- |
  24783. * | 0 | ALPHA_DISABLE | |
  24784. * | 1 | ALPHA_ADD | |
  24785. * | 2 | ALPHA_COMBINE | |
  24786. * | 3 | ALPHA_SUBTRACT | |
  24787. * | 4 | ALPHA_MULTIPLY | |
  24788. * | 5 | ALPHA_MAXIMIZED | |
  24789. * | 6 | ALPHA_ONEONE | |
  24790. * | 7 | ALPHA_PREMULTIPLIED | |
  24791. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24792. * | 9 | ALPHA_INTERPOLATE | |
  24793. * | 10 | ALPHA_SCREENMODE | |
  24794. *
  24795. */
  24796. set alphaMode(value: number);
  24797. /**
  24798. * Gets the value of the alpha mode
  24799. */
  24800. get alphaMode(): number;
  24801. /**
  24802. * Stores the state of the need depth pre-pass value
  24803. */
  24804. private _needDepthPrePass;
  24805. /**
  24806. * Sets the need depth pre-pass value
  24807. */
  24808. set needDepthPrePass(value: boolean);
  24809. /**
  24810. * Gets the depth pre-pass value
  24811. */
  24812. get needDepthPrePass(): boolean;
  24813. /**
  24814. * Specifies if depth writing should be disabled
  24815. */
  24816. disableDepthWrite: boolean;
  24817. /**
  24818. * Specifies if color writing should be disabled
  24819. */
  24820. disableColorWrite: boolean;
  24821. /**
  24822. * Specifies if depth writing should be forced
  24823. */
  24824. forceDepthWrite: boolean;
  24825. /**
  24826. * Specifies the depth function that should be used. 0 means the default engine function
  24827. */
  24828. depthFunction: number;
  24829. /**
  24830. * Specifies if there should be a separate pass for culling
  24831. */
  24832. separateCullingPass: boolean;
  24833. /**
  24834. * Stores the state specifing if fog should be enabled
  24835. */
  24836. private _fogEnabled;
  24837. /**
  24838. * Sets the state for enabling fog
  24839. */
  24840. set fogEnabled(value: boolean);
  24841. /**
  24842. * Gets the value of the fog enabled state
  24843. */
  24844. get fogEnabled(): boolean;
  24845. /**
  24846. * Stores the size of points
  24847. */
  24848. pointSize: number;
  24849. /**
  24850. * Stores the z offset value
  24851. */
  24852. zOffset: number;
  24853. get wireframe(): boolean;
  24854. /**
  24855. * Sets the state of wireframe mode
  24856. */
  24857. set wireframe(value: boolean);
  24858. /**
  24859. * Gets the value specifying if point clouds are enabled
  24860. */
  24861. get pointsCloud(): boolean;
  24862. /**
  24863. * Sets the state of point cloud mode
  24864. */
  24865. set pointsCloud(value: boolean);
  24866. /**
  24867. * Gets the material fill mode
  24868. */
  24869. get fillMode(): number;
  24870. /**
  24871. * Sets the material fill mode
  24872. */
  24873. set fillMode(value: number);
  24874. /**
  24875. * @hidden
  24876. * Stores the effects for the material
  24877. */
  24878. _effect: Nullable<Effect>;
  24879. /**
  24880. * Specifies if uniform buffers should be used
  24881. */
  24882. private _useUBO;
  24883. /**
  24884. * Stores a reference to the scene
  24885. */
  24886. private _scene;
  24887. /**
  24888. * Stores the fill mode state
  24889. */
  24890. private _fillMode;
  24891. /**
  24892. * Specifies if the depth write state should be cached
  24893. */
  24894. private _cachedDepthWriteState;
  24895. /**
  24896. * Specifies if the color write state should be cached
  24897. */
  24898. private _cachedColorWriteState;
  24899. /**
  24900. * Specifies if the depth function state should be cached
  24901. */
  24902. private _cachedDepthFunctionState;
  24903. /**
  24904. * Stores the uniform buffer
  24905. */
  24906. protected _uniformBuffer: UniformBuffer;
  24907. /** @hidden */
  24908. _indexInSceneMaterialArray: number;
  24909. /** @hidden */
  24910. meshMap: Nullable<{
  24911. [id: string]: AbstractMesh | undefined;
  24912. }>;
  24913. /**
  24914. * Creates a material instance
  24915. * @param name defines the name of the material
  24916. * @param scene defines the scene to reference
  24917. * @param doNotAdd specifies if the material should be added to the scene
  24918. */
  24919. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24920. /**
  24921. * Returns a string representation of the current material
  24922. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24923. * @returns a string with material information
  24924. */
  24925. toString(fullDetails?: boolean): string;
  24926. /**
  24927. * Gets the class name of the material
  24928. * @returns a string with the class name of the material
  24929. */
  24930. getClassName(): string;
  24931. /**
  24932. * Specifies if updates for the material been locked
  24933. */
  24934. get isFrozen(): boolean;
  24935. /**
  24936. * Locks updates for the material
  24937. */
  24938. freeze(): void;
  24939. /**
  24940. * Unlocks updates for the material
  24941. */
  24942. unfreeze(): void;
  24943. /**
  24944. * Specifies if the material is ready to be used
  24945. * @param mesh defines the mesh to check
  24946. * @param useInstances specifies if instances should be used
  24947. * @returns a boolean indicating if the material is ready to be used
  24948. */
  24949. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24950. /**
  24951. * Specifies that the submesh is ready to be used
  24952. * @param mesh defines the mesh to check
  24953. * @param subMesh defines which submesh to check
  24954. * @param useInstances specifies that instances should be used
  24955. * @returns a boolean indicating that the submesh is ready or not
  24956. */
  24957. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24958. /**
  24959. * Returns the material effect
  24960. * @returns the effect associated with the material
  24961. */
  24962. getEffect(): Nullable<Effect>;
  24963. /**
  24964. * Returns the current scene
  24965. * @returns a Scene
  24966. */
  24967. getScene(): Scene;
  24968. /**
  24969. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24970. */
  24971. protected _forceAlphaTest: boolean;
  24972. /**
  24973. * The transparency mode of the material.
  24974. */
  24975. protected _transparencyMode: Nullable<number>;
  24976. /**
  24977. * Gets the current transparency mode.
  24978. */
  24979. get transparencyMode(): Nullable<number>;
  24980. /**
  24981. * Sets the transparency mode of the material.
  24982. *
  24983. * | Value | Type | Description |
  24984. * | ----- | ----------------------------------- | ----------- |
  24985. * | 0 | OPAQUE | |
  24986. * | 1 | ALPHATEST | |
  24987. * | 2 | ALPHABLEND | |
  24988. * | 3 | ALPHATESTANDBLEND | |
  24989. *
  24990. */
  24991. set transparencyMode(value: Nullable<number>);
  24992. /**
  24993. * Returns true if alpha blending should be disabled.
  24994. */
  24995. protected get _disableAlphaBlending(): boolean;
  24996. /**
  24997. * Specifies whether or not this material should be rendered in alpha blend mode.
  24998. * @returns a boolean specifying if alpha blending is needed
  24999. */
  25000. needAlphaBlending(): boolean;
  25001. /**
  25002. * Specifies if the mesh will require alpha blending
  25003. * @param mesh defines the mesh to check
  25004. * @returns a boolean specifying if alpha blending is needed for the mesh
  25005. */
  25006. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25007. /**
  25008. * Specifies whether or not this material should be rendered in alpha test mode.
  25009. * @returns a boolean specifying if an alpha test is needed.
  25010. */
  25011. needAlphaTesting(): boolean;
  25012. /**
  25013. * Specifies if material alpha testing should be turned on for the mesh
  25014. * @param mesh defines the mesh to check
  25015. */
  25016. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25017. /**
  25018. * Gets the texture used for the alpha test
  25019. * @returns the texture to use for alpha testing
  25020. */
  25021. getAlphaTestTexture(): Nullable<BaseTexture>;
  25022. /**
  25023. * Marks the material to indicate that it needs to be re-calculated
  25024. */
  25025. markDirty(): void;
  25026. /** @hidden */
  25027. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25028. /**
  25029. * Binds the material to the mesh
  25030. * @param world defines the world transformation matrix
  25031. * @param mesh defines the mesh to bind the material to
  25032. */
  25033. bind(world: Matrix, mesh?: Mesh): void;
  25034. /**
  25035. * Binds the submesh to the material
  25036. * @param world defines the world transformation matrix
  25037. * @param mesh defines the mesh containing the submesh
  25038. * @param subMesh defines the submesh to bind the material to
  25039. */
  25040. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25041. /**
  25042. * Binds the world matrix to the material
  25043. * @param world defines the world transformation matrix
  25044. */
  25045. bindOnlyWorldMatrix(world: Matrix): void;
  25046. /**
  25047. * Binds the scene's uniform buffer to the effect.
  25048. * @param effect defines the effect to bind to the scene uniform buffer
  25049. * @param sceneUbo defines the uniform buffer storing scene data
  25050. */
  25051. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25052. /**
  25053. * Binds the view matrix to the effect
  25054. * @param effect defines the effect to bind the view matrix to
  25055. */
  25056. bindView(effect: Effect): void;
  25057. /**
  25058. * Binds the view projection matrix to the effect
  25059. * @param effect defines the effect to bind the view projection matrix to
  25060. */
  25061. bindViewProjection(effect: Effect): void;
  25062. /**
  25063. * Processes to execute after binding the material to a mesh
  25064. * @param mesh defines the rendered mesh
  25065. */
  25066. protected _afterBind(mesh?: Mesh): void;
  25067. /**
  25068. * Unbinds the material from the mesh
  25069. */
  25070. unbind(): void;
  25071. /**
  25072. * Gets the active textures from the material
  25073. * @returns an array of textures
  25074. */
  25075. getActiveTextures(): BaseTexture[];
  25076. /**
  25077. * Specifies if the material uses a texture
  25078. * @param texture defines the texture to check against the material
  25079. * @returns a boolean specifying if the material uses the texture
  25080. */
  25081. hasTexture(texture: BaseTexture): boolean;
  25082. /**
  25083. * Makes a duplicate of the material, and gives it a new name
  25084. * @param name defines the new name for the duplicated material
  25085. * @returns the cloned material
  25086. */
  25087. clone(name: string): Nullable<Material>;
  25088. /**
  25089. * Gets the meshes bound to the material
  25090. * @returns an array of meshes bound to the material
  25091. */
  25092. getBindedMeshes(): AbstractMesh[];
  25093. /**
  25094. * Force shader compilation
  25095. * @param mesh defines the mesh associated with this material
  25096. * @param onCompiled defines a function to execute once the material is compiled
  25097. * @param options defines the options to configure the compilation
  25098. * @param onError defines a function to execute if the material fails compiling
  25099. */
  25100. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25101. /**
  25102. * Force shader compilation
  25103. * @param mesh defines the mesh that will use this material
  25104. * @param options defines additional options for compiling the shaders
  25105. * @returns a promise that resolves when the compilation completes
  25106. */
  25107. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25108. private static readonly _AllDirtyCallBack;
  25109. private static readonly _ImageProcessingDirtyCallBack;
  25110. private static readonly _TextureDirtyCallBack;
  25111. private static readonly _FresnelDirtyCallBack;
  25112. private static readonly _MiscDirtyCallBack;
  25113. private static readonly _LightsDirtyCallBack;
  25114. private static readonly _AttributeDirtyCallBack;
  25115. private static _FresnelAndMiscDirtyCallBack;
  25116. private static _TextureAndMiscDirtyCallBack;
  25117. private static readonly _DirtyCallbackArray;
  25118. private static readonly _RunDirtyCallBacks;
  25119. /**
  25120. * Marks a define in the material to indicate that it needs to be re-computed
  25121. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25122. */
  25123. markAsDirty(flag: number): void;
  25124. /**
  25125. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25126. * @param func defines a function which checks material defines against the submeshes
  25127. */
  25128. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25129. /**
  25130. * Indicates that the scene should check if the rendering now needs a prepass
  25131. */
  25132. protected _markScenePrePassDirty(): void;
  25133. /**
  25134. * Indicates that we need to re-calculated for all submeshes
  25135. */
  25136. protected _markAllSubMeshesAsAllDirty(): void;
  25137. /**
  25138. * Indicates that image processing needs to be re-calculated for all submeshes
  25139. */
  25140. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25141. /**
  25142. * Indicates that textures need to be re-calculated for all submeshes
  25143. */
  25144. protected _markAllSubMeshesAsTexturesDirty(): void;
  25145. /**
  25146. * Indicates that fresnel needs to be re-calculated for all submeshes
  25147. */
  25148. protected _markAllSubMeshesAsFresnelDirty(): void;
  25149. /**
  25150. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25151. */
  25152. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25153. /**
  25154. * Indicates that lights need to be re-calculated for all submeshes
  25155. */
  25156. protected _markAllSubMeshesAsLightsDirty(): void;
  25157. /**
  25158. * Indicates that attributes need to be re-calculated for all submeshes
  25159. */
  25160. protected _markAllSubMeshesAsAttributesDirty(): void;
  25161. /**
  25162. * Indicates that misc needs to be re-calculated for all submeshes
  25163. */
  25164. protected _markAllSubMeshesAsMiscDirty(): void;
  25165. /**
  25166. * Indicates that textures and misc need to be re-calculated for all submeshes
  25167. */
  25168. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25169. /**
  25170. * Sets the required values to the prepass renderer.
  25171. * @param prePassRenderer defines the prepass renderer to setup.
  25172. * @returns true if the pre pass is needed.
  25173. */
  25174. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25175. /**
  25176. * Disposes the material
  25177. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25178. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25179. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25180. */
  25181. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25182. /** @hidden */
  25183. private releaseVertexArrayObject;
  25184. /**
  25185. * Serializes this material
  25186. * @returns the serialized material object
  25187. */
  25188. serialize(): any;
  25189. /**
  25190. * Creates a material from parsed material data
  25191. * @param parsedMaterial defines parsed material data
  25192. * @param scene defines the hosting scene
  25193. * @param rootUrl defines the root URL to use to load textures
  25194. * @returns a new material
  25195. */
  25196. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25197. }
  25198. }
  25199. declare module BABYLON {
  25200. /**
  25201. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25202. * separate meshes. This can be use to improve performances.
  25203. * @see https://doc.babylonjs.com/how_to/multi_materials
  25204. */
  25205. export class MultiMaterial extends Material {
  25206. private _subMaterials;
  25207. /**
  25208. * Gets or Sets the list of Materials used within the multi material.
  25209. * They need to be ordered according to the submeshes order in the associated mesh
  25210. */
  25211. get subMaterials(): Nullable<Material>[];
  25212. set subMaterials(value: Nullable<Material>[]);
  25213. /**
  25214. * Function used to align with Node.getChildren()
  25215. * @returns the list of Materials used within the multi material
  25216. */
  25217. getChildren(): Nullable<Material>[];
  25218. /**
  25219. * Instantiates a new Multi Material
  25220. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25221. * separate meshes. This can be use to improve performances.
  25222. * @see https://doc.babylonjs.com/how_to/multi_materials
  25223. * @param name Define the name in the scene
  25224. * @param scene Define the scene the material belongs to
  25225. */
  25226. constructor(name: string, scene: Scene);
  25227. private _hookArray;
  25228. /**
  25229. * Get one of the submaterial by its index in the submaterials array
  25230. * @param index The index to look the sub material at
  25231. * @returns The Material if the index has been defined
  25232. */
  25233. getSubMaterial(index: number): Nullable<Material>;
  25234. /**
  25235. * Get the list of active textures for the whole sub materials list.
  25236. * @returns All the textures that will be used during the rendering
  25237. */
  25238. getActiveTextures(): BaseTexture[];
  25239. /**
  25240. * Gets the current class name of the material e.g. "MultiMaterial"
  25241. * Mainly use in serialization.
  25242. * @returns the class name
  25243. */
  25244. getClassName(): string;
  25245. /**
  25246. * Checks if the material is ready to render the requested sub mesh
  25247. * @param mesh Define the mesh the submesh belongs to
  25248. * @param subMesh Define the sub mesh to look readyness for
  25249. * @param useInstances Define whether or not the material is used with instances
  25250. * @returns true if ready, otherwise false
  25251. */
  25252. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25253. /**
  25254. * Clones the current material and its related sub materials
  25255. * @param name Define the name of the newly cloned material
  25256. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25257. * @returns the cloned material
  25258. */
  25259. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25260. /**
  25261. * Serializes the materials into a JSON representation.
  25262. * @returns the JSON representation
  25263. */
  25264. serialize(): any;
  25265. /**
  25266. * Dispose the material and release its associated resources
  25267. * @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)
  25268. * @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)
  25269. * @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)
  25270. */
  25271. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25272. /**
  25273. * Creates a MultiMaterial from parsed MultiMaterial data.
  25274. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25275. * @param scene defines the hosting scene
  25276. * @returns a new MultiMaterial
  25277. */
  25278. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25279. }
  25280. }
  25281. declare module BABYLON {
  25282. /**
  25283. * Defines a subdivision inside a mesh
  25284. */
  25285. export class SubMesh implements ICullable {
  25286. /** the material index to use */
  25287. materialIndex: number;
  25288. /** vertex index start */
  25289. verticesStart: number;
  25290. /** vertices count */
  25291. verticesCount: number;
  25292. /** index start */
  25293. indexStart: number;
  25294. /** indices count */
  25295. indexCount: number;
  25296. /** @hidden */
  25297. _materialDefines: Nullable<MaterialDefines>;
  25298. /** @hidden */
  25299. _materialEffect: Nullable<Effect>;
  25300. /** @hidden */
  25301. _effectOverride: Nullable<Effect>;
  25302. /**
  25303. * Gets material defines used by the effect associated to the sub mesh
  25304. */
  25305. get materialDefines(): Nullable<MaterialDefines>;
  25306. /**
  25307. * Sets material defines used by the effect associated to the sub mesh
  25308. */
  25309. set materialDefines(defines: Nullable<MaterialDefines>);
  25310. /**
  25311. * Gets associated effect
  25312. */
  25313. get effect(): Nullable<Effect>;
  25314. /**
  25315. * Sets associated effect (effect used to render this submesh)
  25316. * @param effect defines the effect to associate with
  25317. * @param defines defines the set of defines used to compile this effect
  25318. */
  25319. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25320. /** @hidden */
  25321. _linesIndexCount: number;
  25322. private _mesh;
  25323. private _renderingMesh;
  25324. private _boundingInfo;
  25325. private _linesIndexBuffer;
  25326. /** @hidden */
  25327. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25328. /** @hidden */
  25329. _trianglePlanes: Plane[];
  25330. /** @hidden */
  25331. _lastColliderTransformMatrix: Nullable<Matrix>;
  25332. /** @hidden */
  25333. _renderId: number;
  25334. /** @hidden */
  25335. _alphaIndex: number;
  25336. /** @hidden */
  25337. _distanceToCamera: number;
  25338. /** @hidden */
  25339. _id: number;
  25340. private _currentMaterial;
  25341. /**
  25342. * Add a new submesh to a mesh
  25343. * @param materialIndex defines the material index to use
  25344. * @param verticesStart defines vertex index start
  25345. * @param verticesCount defines vertices count
  25346. * @param indexStart defines index start
  25347. * @param indexCount defines indices count
  25348. * @param mesh defines the parent mesh
  25349. * @param renderingMesh defines an optional rendering mesh
  25350. * @param createBoundingBox defines if bounding box should be created for this submesh
  25351. * @returns the new submesh
  25352. */
  25353. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25354. /**
  25355. * Creates a new submesh
  25356. * @param materialIndex defines the material index to use
  25357. * @param verticesStart defines vertex index start
  25358. * @param verticesCount defines vertices count
  25359. * @param indexStart defines index start
  25360. * @param indexCount defines indices count
  25361. * @param mesh defines the parent mesh
  25362. * @param renderingMesh defines an optional rendering mesh
  25363. * @param createBoundingBox defines if bounding box should be created for this submesh
  25364. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25365. */
  25366. constructor(
  25367. /** the material index to use */
  25368. materialIndex: number,
  25369. /** vertex index start */
  25370. verticesStart: number,
  25371. /** vertices count */
  25372. verticesCount: number,
  25373. /** index start */
  25374. indexStart: number,
  25375. /** indices count */
  25376. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25377. /**
  25378. * Returns true if this submesh covers the entire parent mesh
  25379. * @ignorenaming
  25380. */
  25381. get IsGlobal(): boolean;
  25382. /**
  25383. * Returns the submesh BoudingInfo object
  25384. * @returns current bounding info (or mesh's one if the submesh is global)
  25385. */
  25386. getBoundingInfo(): BoundingInfo;
  25387. /**
  25388. * Sets the submesh BoundingInfo
  25389. * @param boundingInfo defines the new bounding info to use
  25390. * @returns the SubMesh
  25391. */
  25392. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25393. /**
  25394. * Returns the mesh of the current submesh
  25395. * @return the parent mesh
  25396. */
  25397. getMesh(): AbstractMesh;
  25398. /**
  25399. * Returns the rendering mesh of the submesh
  25400. * @returns the rendering mesh (could be different from parent mesh)
  25401. */
  25402. getRenderingMesh(): Mesh;
  25403. /**
  25404. * Returns the replacement mesh of the submesh
  25405. * @returns the replacement mesh (could be different from parent mesh)
  25406. */
  25407. getReplacementMesh(): Nullable<AbstractMesh>;
  25408. /**
  25409. * Returns the effective mesh of the submesh
  25410. * @returns the effective mesh (could be different from parent mesh)
  25411. */
  25412. getEffectiveMesh(): AbstractMesh;
  25413. /**
  25414. * Returns the submesh material
  25415. * @returns null or the current material
  25416. */
  25417. getMaterial(): Nullable<Material>;
  25418. private _IsMultiMaterial;
  25419. /**
  25420. * Sets a new updated BoundingInfo object to the submesh
  25421. * @param data defines an optional position array to use to determine the bounding info
  25422. * @returns the SubMesh
  25423. */
  25424. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25425. /** @hidden */
  25426. _checkCollision(collider: Collider): boolean;
  25427. /**
  25428. * Updates the submesh BoundingInfo
  25429. * @param world defines the world matrix to use to update the bounding info
  25430. * @returns the submesh
  25431. */
  25432. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25433. /**
  25434. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25435. * @param frustumPlanes defines the frustum planes
  25436. * @returns true if the submesh is intersecting with the frustum
  25437. */
  25438. isInFrustum(frustumPlanes: Plane[]): boolean;
  25439. /**
  25440. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25441. * @param frustumPlanes defines the frustum planes
  25442. * @returns true if the submesh is inside the frustum
  25443. */
  25444. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25445. /**
  25446. * Renders the submesh
  25447. * @param enableAlphaMode defines if alpha needs to be used
  25448. * @returns the submesh
  25449. */
  25450. render(enableAlphaMode: boolean): SubMesh;
  25451. /**
  25452. * @hidden
  25453. */
  25454. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25455. /**
  25456. * Checks if the submesh intersects with a ray
  25457. * @param ray defines the ray to test
  25458. * @returns true is the passed ray intersects the submesh bounding box
  25459. */
  25460. canIntersects(ray: Ray): boolean;
  25461. /**
  25462. * Intersects current submesh with a ray
  25463. * @param ray defines the ray to test
  25464. * @param positions defines mesh's positions array
  25465. * @param indices defines mesh's indices array
  25466. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25467. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25468. * @returns intersection info or null if no intersection
  25469. */
  25470. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25471. /** @hidden */
  25472. private _intersectLines;
  25473. /** @hidden */
  25474. private _intersectUnIndexedLines;
  25475. /** @hidden */
  25476. private _intersectTriangles;
  25477. /** @hidden */
  25478. private _intersectUnIndexedTriangles;
  25479. /** @hidden */
  25480. _rebuild(): void;
  25481. /**
  25482. * Creates a new submesh from the passed mesh
  25483. * @param newMesh defines the new hosting mesh
  25484. * @param newRenderingMesh defines an optional rendering mesh
  25485. * @returns the new submesh
  25486. */
  25487. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25488. /**
  25489. * Release associated resources
  25490. */
  25491. dispose(): void;
  25492. /**
  25493. * Gets the class name
  25494. * @returns the string "SubMesh".
  25495. */
  25496. getClassName(): string;
  25497. /**
  25498. * Creates a new submesh from indices data
  25499. * @param materialIndex the index of the main mesh material
  25500. * @param startIndex the index where to start the copy in the mesh indices array
  25501. * @param indexCount the number of indices to copy then from the startIndex
  25502. * @param mesh the main mesh to create the submesh from
  25503. * @param renderingMesh the optional rendering mesh
  25504. * @returns a new submesh
  25505. */
  25506. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25507. }
  25508. }
  25509. declare module BABYLON {
  25510. /**
  25511. * Class used to represent data loading progression
  25512. */
  25513. export class SceneLoaderFlags {
  25514. private static _ForceFullSceneLoadingForIncremental;
  25515. private static _ShowLoadingScreen;
  25516. private static _CleanBoneMatrixWeights;
  25517. private static _loggingLevel;
  25518. /**
  25519. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25520. */
  25521. static get ForceFullSceneLoadingForIncremental(): boolean;
  25522. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25523. /**
  25524. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25525. */
  25526. static get ShowLoadingScreen(): boolean;
  25527. static set ShowLoadingScreen(value: boolean);
  25528. /**
  25529. * Defines the current logging level (while loading the scene)
  25530. * @ignorenaming
  25531. */
  25532. static get loggingLevel(): number;
  25533. static set loggingLevel(value: number);
  25534. /**
  25535. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25536. */
  25537. static get CleanBoneMatrixWeights(): boolean;
  25538. static set CleanBoneMatrixWeights(value: boolean);
  25539. }
  25540. }
  25541. declare module BABYLON {
  25542. /**
  25543. * Class used to store geometry data (vertex buffers + index buffer)
  25544. */
  25545. export class Geometry implements IGetSetVerticesData {
  25546. /**
  25547. * Gets or sets the ID of the geometry
  25548. */
  25549. id: string;
  25550. /**
  25551. * Gets or sets the unique ID of the geometry
  25552. */
  25553. uniqueId: number;
  25554. /**
  25555. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25556. */
  25557. delayLoadState: number;
  25558. /**
  25559. * Gets the file containing the data to load when running in delay load state
  25560. */
  25561. delayLoadingFile: Nullable<string>;
  25562. /**
  25563. * Callback called when the geometry is updated
  25564. */
  25565. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25566. private _scene;
  25567. private _engine;
  25568. private _meshes;
  25569. private _totalVertices;
  25570. /** @hidden */
  25571. _indices: IndicesArray;
  25572. /** @hidden */
  25573. _vertexBuffers: {
  25574. [key: string]: VertexBuffer;
  25575. };
  25576. private _isDisposed;
  25577. private _extend;
  25578. private _boundingBias;
  25579. /** @hidden */
  25580. _delayInfo: Array<string>;
  25581. private _indexBuffer;
  25582. private _indexBufferIsUpdatable;
  25583. /** @hidden */
  25584. _boundingInfo: Nullable<BoundingInfo>;
  25585. /** @hidden */
  25586. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25587. /** @hidden */
  25588. _softwareSkinningFrameId: number;
  25589. private _vertexArrayObjects;
  25590. private _updatable;
  25591. /** @hidden */
  25592. _positions: Nullable<Vector3[]>;
  25593. /**
  25594. * 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
  25595. */
  25596. get boundingBias(): Vector2;
  25597. /**
  25598. * 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
  25599. */
  25600. set boundingBias(value: Vector2);
  25601. /**
  25602. * Static function used to attach a new empty geometry to a mesh
  25603. * @param mesh defines the mesh to attach the geometry to
  25604. * @returns the new Geometry
  25605. */
  25606. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25607. /** Get the list of meshes using this geometry */
  25608. get meshes(): Mesh[];
  25609. /**
  25610. * 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
  25611. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25612. */
  25613. useBoundingInfoFromGeometry: boolean;
  25614. /**
  25615. * Creates a new geometry
  25616. * @param id defines the unique ID
  25617. * @param scene defines the hosting scene
  25618. * @param vertexData defines the VertexData used to get geometry data
  25619. * @param updatable defines if geometry must be updatable (false by default)
  25620. * @param mesh defines the mesh that will be associated with the geometry
  25621. */
  25622. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25623. /**
  25624. * Gets the current extend of the geometry
  25625. */
  25626. get extend(): {
  25627. minimum: Vector3;
  25628. maximum: Vector3;
  25629. };
  25630. /**
  25631. * Gets the hosting scene
  25632. * @returns the hosting Scene
  25633. */
  25634. getScene(): Scene;
  25635. /**
  25636. * Gets the hosting engine
  25637. * @returns the hosting Engine
  25638. */
  25639. getEngine(): Engine;
  25640. /**
  25641. * Defines if the geometry is ready to use
  25642. * @returns true if the geometry is ready to be used
  25643. */
  25644. isReady(): boolean;
  25645. /**
  25646. * Gets a value indicating that the geometry should not be serialized
  25647. */
  25648. get doNotSerialize(): boolean;
  25649. /** @hidden */
  25650. _rebuild(): void;
  25651. /**
  25652. * Affects all geometry data in one call
  25653. * @param vertexData defines the geometry data
  25654. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25655. */
  25656. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25657. /**
  25658. * Set specific vertex data
  25659. * @param kind defines the data kind (Position, normal, etc...)
  25660. * @param data defines the vertex data to use
  25661. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25662. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25663. */
  25664. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25665. /**
  25666. * Removes a specific vertex data
  25667. * @param kind defines the data kind (Position, normal, etc...)
  25668. */
  25669. removeVerticesData(kind: string): void;
  25670. /**
  25671. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25672. * @param buffer defines the vertex buffer to use
  25673. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25674. */
  25675. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25676. /**
  25677. * Update a specific vertex buffer
  25678. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25679. * It will do nothing if the buffer is not updatable
  25680. * @param kind defines the data kind (Position, normal, etc...)
  25681. * @param data defines the data to use
  25682. * @param offset defines the offset in the target buffer where to store the data
  25683. * @param useBytes set to true if the offset is in bytes
  25684. */
  25685. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25686. /**
  25687. * Update a specific vertex buffer
  25688. * This function will create a new buffer if the current one is not updatable
  25689. * @param kind defines the data kind (Position, normal, etc...)
  25690. * @param data defines the data to use
  25691. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25692. */
  25693. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25694. private _updateBoundingInfo;
  25695. /** @hidden */
  25696. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25697. /**
  25698. * Gets total number of vertices
  25699. * @returns the total number of vertices
  25700. */
  25701. getTotalVertices(): number;
  25702. /**
  25703. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25704. * @param kind defines the data kind (Position, normal, etc...)
  25705. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25706. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25707. * @returns a float array containing vertex data
  25708. */
  25709. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25710. /**
  25711. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25712. * @param kind defines the data kind (Position, normal, etc...)
  25713. * @returns true if the vertex buffer with the specified kind is updatable
  25714. */
  25715. isVertexBufferUpdatable(kind: string): boolean;
  25716. /**
  25717. * Gets a specific vertex buffer
  25718. * @param kind defines the data kind (Position, normal, etc...)
  25719. * @returns a VertexBuffer
  25720. */
  25721. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25722. /**
  25723. * Returns all vertex buffers
  25724. * @return an object holding all vertex buffers indexed by kind
  25725. */
  25726. getVertexBuffers(): Nullable<{
  25727. [key: string]: VertexBuffer;
  25728. }>;
  25729. /**
  25730. * Gets a boolean indicating if specific vertex buffer is present
  25731. * @param kind defines the data kind (Position, normal, etc...)
  25732. * @returns true if data is present
  25733. */
  25734. isVerticesDataPresent(kind: string): boolean;
  25735. /**
  25736. * Gets a list of all attached data kinds (Position, normal, etc...)
  25737. * @returns a list of string containing all kinds
  25738. */
  25739. getVerticesDataKinds(): string[];
  25740. /**
  25741. * Update index buffer
  25742. * @param indices defines the indices to store in the index buffer
  25743. * @param offset defines the offset in the target buffer where to store the data
  25744. * @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)
  25745. */
  25746. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25747. /**
  25748. * Creates a new index buffer
  25749. * @param indices defines the indices to store in the index buffer
  25750. * @param totalVertices defines the total number of vertices (could be null)
  25751. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25752. */
  25753. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25754. /**
  25755. * Return the total number of indices
  25756. * @returns the total number of indices
  25757. */
  25758. getTotalIndices(): number;
  25759. /**
  25760. * Gets the index buffer array
  25761. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25762. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25763. * @returns the index buffer array
  25764. */
  25765. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25766. /**
  25767. * Gets the index buffer
  25768. * @return the index buffer
  25769. */
  25770. getIndexBuffer(): Nullable<DataBuffer>;
  25771. /** @hidden */
  25772. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25773. /**
  25774. * Release the associated resources for a specific mesh
  25775. * @param mesh defines the source mesh
  25776. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25777. */
  25778. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25779. /**
  25780. * Apply current geometry to a given mesh
  25781. * @param mesh defines the mesh to apply geometry to
  25782. */
  25783. applyToMesh(mesh: Mesh): void;
  25784. private _updateExtend;
  25785. private _applyToMesh;
  25786. private notifyUpdate;
  25787. /**
  25788. * Load the geometry if it was flagged as delay loaded
  25789. * @param scene defines the hosting scene
  25790. * @param onLoaded defines a callback called when the geometry is loaded
  25791. */
  25792. load(scene: Scene, onLoaded?: () => void): void;
  25793. private _queueLoad;
  25794. /**
  25795. * Invert the geometry to move from a right handed system to a left handed one.
  25796. */
  25797. toLeftHanded(): void;
  25798. /** @hidden */
  25799. _resetPointsArrayCache(): void;
  25800. /** @hidden */
  25801. _generatePointsArray(): boolean;
  25802. /**
  25803. * Gets a value indicating if the geometry is disposed
  25804. * @returns true if the geometry was disposed
  25805. */
  25806. isDisposed(): boolean;
  25807. private _disposeVertexArrayObjects;
  25808. /**
  25809. * Free all associated resources
  25810. */
  25811. dispose(): void;
  25812. /**
  25813. * Clone the current geometry into a new geometry
  25814. * @param id defines the unique ID of the new geometry
  25815. * @returns a new geometry object
  25816. */
  25817. copy(id: string): Geometry;
  25818. /**
  25819. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25820. * @return a JSON representation of the current geometry data (without the vertices data)
  25821. */
  25822. serialize(): any;
  25823. private toNumberArray;
  25824. /**
  25825. * Serialize all vertices data into a JSON oject
  25826. * @returns a JSON representation of the current geometry data
  25827. */
  25828. serializeVerticeData(): any;
  25829. /**
  25830. * Extracts a clone of a mesh geometry
  25831. * @param mesh defines the source mesh
  25832. * @param id defines the unique ID of the new geometry object
  25833. * @returns the new geometry object
  25834. */
  25835. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25836. /**
  25837. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25838. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25839. * Be aware Math.random() could cause collisions, but:
  25840. * "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"
  25841. * @returns a string containing a new GUID
  25842. */
  25843. static RandomId(): string;
  25844. /** @hidden */
  25845. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25846. private static _CleanMatricesWeights;
  25847. /**
  25848. * Create a new geometry from persisted data (Using .babylon file format)
  25849. * @param parsedVertexData defines the persisted data
  25850. * @param scene defines the hosting scene
  25851. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25852. * @returns the new geometry object
  25853. */
  25854. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25855. }
  25856. }
  25857. declare module BABYLON {
  25858. /**
  25859. * Define an interface for all classes that will get and set the data on vertices
  25860. */
  25861. export interface IGetSetVerticesData {
  25862. /**
  25863. * Gets a boolean indicating if specific vertex data is present
  25864. * @param kind defines the vertex data kind to use
  25865. * @returns true is data kind is present
  25866. */
  25867. isVerticesDataPresent(kind: string): boolean;
  25868. /**
  25869. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25870. * @param kind defines the data kind (Position, normal, etc...)
  25871. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25872. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25873. * @returns a float array containing vertex data
  25874. */
  25875. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25876. /**
  25877. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25878. * @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.
  25879. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25880. * @returns the indices array or an empty array if the mesh has no geometry
  25881. */
  25882. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25883. /**
  25884. * Set specific vertex data
  25885. * @param kind defines the data kind (Position, normal, etc...)
  25886. * @param data defines the vertex data to use
  25887. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25888. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25889. */
  25890. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25891. /**
  25892. * Update a specific associated vertex buffer
  25893. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25894. * - VertexBuffer.PositionKind
  25895. * - VertexBuffer.UVKind
  25896. * - VertexBuffer.UV2Kind
  25897. * - VertexBuffer.UV3Kind
  25898. * - VertexBuffer.UV4Kind
  25899. * - VertexBuffer.UV5Kind
  25900. * - VertexBuffer.UV6Kind
  25901. * - VertexBuffer.ColorKind
  25902. * - VertexBuffer.MatricesIndicesKind
  25903. * - VertexBuffer.MatricesIndicesExtraKind
  25904. * - VertexBuffer.MatricesWeightsKind
  25905. * - VertexBuffer.MatricesWeightsExtraKind
  25906. * @param data defines the data source
  25907. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25908. * @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)
  25909. */
  25910. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25911. /**
  25912. * Creates a new index buffer
  25913. * @param indices defines the indices to store in the index buffer
  25914. * @param totalVertices defines the total number of vertices (could be null)
  25915. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25916. */
  25917. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25918. }
  25919. /**
  25920. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25921. */
  25922. export class VertexData {
  25923. /**
  25924. * Mesh side orientation : usually the external or front surface
  25925. */
  25926. static readonly FRONTSIDE: number;
  25927. /**
  25928. * Mesh side orientation : usually the internal or back surface
  25929. */
  25930. static readonly BACKSIDE: number;
  25931. /**
  25932. * Mesh side orientation : both internal and external or front and back surfaces
  25933. */
  25934. static readonly DOUBLESIDE: number;
  25935. /**
  25936. * Mesh side orientation : by default, `FRONTSIDE`
  25937. */
  25938. static readonly DEFAULTSIDE: number;
  25939. /**
  25940. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25941. */
  25942. positions: Nullable<FloatArray>;
  25943. /**
  25944. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25945. */
  25946. normals: Nullable<FloatArray>;
  25947. /**
  25948. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25949. */
  25950. tangents: Nullable<FloatArray>;
  25951. /**
  25952. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25953. */
  25954. uvs: Nullable<FloatArray>;
  25955. /**
  25956. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25957. */
  25958. uvs2: Nullable<FloatArray>;
  25959. /**
  25960. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25961. */
  25962. uvs3: Nullable<FloatArray>;
  25963. /**
  25964. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25965. */
  25966. uvs4: Nullable<FloatArray>;
  25967. /**
  25968. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25969. */
  25970. uvs5: Nullable<FloatArray>;
  25971. /**
  25972. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25973. */
  25974. uvs6: Nullable<FloatArray>;
  25975. /**
  25976. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25977. */
  25978. colors: Nullable<FloatArray>;
  25979. /**
  25980. * 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).
  25981. */
  25982. matricesIndices: Nullable<FloatArray>;
  25983. /**
  25984. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25985. */
  25986. matricesWeights: Nullable<FloatArray>;
  25987. /**
  25988. * An array extending the number of possible indices
  25989. */
  25990. matricesIndicesExtra: Nullable<FloatArray>;
  25991. /**
  25992. * An array extending the number of possible weights when the number of indices is extended
  25993. */
  25994. matricesWeightsExtra: Nullable<FloatArray>;
  25995. /**
  25996. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25997. */
  25998. indices: Nullable<IndicesArray>;
  25999. /**
  26000. * Uses the passed data array to set the set the values for the specified kind of data
  26001. * @param data a linear array of floating numbers
  26002. * @param kind the type of data that is being set, eg positions, colors etc
  26003. */
  26004. set(data: FloatArray, kind: string): void;
  26005. /**
  26006. * Associates the vertexData to the passed Mesh.
  26007. * Sets it as updatable or not (default `false`)
  26008. * @param mesh the mesh the vertexData is applied to
  26009. * @param updatable when used and having the value true allows new data to update the vertexData
  26010. * @returns the VertexData
  26011. */
  26012. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26013. /**
  26014. * Associates the vertexData to the passed Geometry.
  26015. * Sets it as updatable or not (default `false`)
  26016. * @param geometry the geometry the vertexData is applied to
  26017. * @param updatable when used and having the value true allows new data to update the vertexData
  26018. * @returns VertexData
  26019. */
  26020. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26021. /**
  26022. * Updates the associated mesh
  26023. * @param mesh the mesh to be updated
  26024. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26025. * @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
  26026. * @returns VertexData
  26027. */
  26028. updateMesh(mesh: Mesh): VertexData;
  26029. /**
  26030. * Updates the associated geometry
  26031. * @param geometry the geometry to be updated
  26032. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26033. * @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
  26034. * @returns VertexData.
  26035. */
  26036. updateGeometry(geometry: Geometry): VertexData;
  26037. private _applyTo;
  26038. private _update;
  26039. /**
  26040. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26041. * @param matrix the transforming matrix
  26042. * @returns the VertexData
  26043. */
  26044. transform(matrix: Matrix): VertexData;
  26045. /**
  26046. * Merges the passed VertexData into the current one
  26047. * @param other the VertexData to be merged into the current one
  26048. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26049. * @returns the modified VertexData
  26050. */
  26051. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26052. private _mergeElement;
  26053. private _validate;
  26054. /**
  26055. * Serializes the VertexData
  26056. * @returns a serialized object
  26057. */
  26058. serialize(): any;
  26059. /**
  26060. * Extracts the vertexData from a mesh
  26061. * @param mesh the mesh from which to extract the VertexData
  26062. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26063. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26064. * @returns the object VertexData associated to the passed mesh
  26065. */
  26066. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26067. /**
  26068. * Extracts the vertexData from the geometry
  26069. * @param geometry the geometry from which to extract the VertexData
  26070. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26071. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26072. * @returns the object VertexData associated to the passed mesh
  26073. */
  26074. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26075. private static _ExtractFrom;
  26076. /**
  26077. * Creates the VertexData for a Ribbon
  26078. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26079. * * pathArray array of paths, each of which an array of successive Vector3
  26080. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26081. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26082. * * 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
  26083. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26084. * * 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)
  26085. * * 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)
  26086. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26087. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26088. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26089. * @returns the VertexData of the ribbon
  26090. */
  26091. static CreateRibbon(options: {
  26092. pathArray: Vector3[][];
  26093. closeArray?: boolean;
  26094. closePath?: boolean;
  26095. offset?: number;
  26096. sideOrientation?: number;
  26097. frontUVs?: Vector4;
  26098. backUVs?: Vector4;
  26099. invertUV?: boolean;
  26100. uvs?: Vector2[];
  26101. colors?: Color4[];
  26102. }): VertexData;
  26103. /**
  26104. * Creates the VertexData for a box
  26105. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26106. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26107. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26108. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26109. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26110. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26111. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26112. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26113. * * 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)
  26114. * * 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)
  26115. * @returns the VertexData of the box
  26116. */
  26117. static CreateBox(options: {
  26118. size?: number;
  26119. width?: number;
  26120. height?: number;
  26121. depth?: number;
  26122. faceUV?: Vector4[];
  26123. faceColors?: Color4[];
  26124. sideOrientation?: number;
  26125. frontUVs?: Vector4;
  26126. backUVs?: Vector4;
  26127. }): VertexData;
  26128. /**
  26129. * Creates the VertexData for a tiled box
  26130. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26131. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26132. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26133. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26134. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26135. * @returns the VertexData of the box
  26136. */
  26137. static CreateTiledBox(options: {
  26138. pattern?: number;
  26139. width?: number;
  26140. height?: number;
  26141. depth?: number;
  26142. tileSize?: number;
  26143. tileWidth?: number;
  26144. tileHeight?: number;
  26145. alignHorizontal?: number;
  26146. alignVertical?: number;
  26147. faceUV?: Vector4[];
  26148. faceColors?: Color4[];
  26149. sideOrientation?: number;
  26150. }): VertexData;
  26151. /**
  26152. * Creates the VertexData for a tiled plane
  26153. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26154. * * pattern a limited pattern arrangement depending on the number
  26155. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26156. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26157. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26158. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26159. * * 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)
  26160. * * 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)
  26161. * @returns the VertexData of the tiled plane
  26162. */
  26163. static CreateTiledPlane(options: {
  26164. pattern?: number;
  26165. tileSize?: number;
  26166. tileWidth?: number;
  26167. tileHeight?: number;
  26168. size?: number;
  26169. width?: number;
  26170. height?: number;
  26171. alignHorizontal?: number;
  26172. alignVertical?: number;
  26173. sideOrientation?: number;
  26174. frontUVs?: Vector4;
  26175. backUVs?: Vector4;
  26176. }): VertexData;
  26177. /**
  26178. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26179. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26180. * * segments sets the number of horizontal strips optional, default 32
  26181. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26182. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26183. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26184. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26185. * * 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
  26186. * * 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
  26187. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26188. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26189. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26190. * @returns the VertexData of the ellipsoid
  26191. */
  26192. static CreateSphere(options: {
  26193. segments?: number;
  26194. diameter?: number;
  26195. diameterX?: number;
  26196. diameterY?: number;
  26197. diameterZ?: number;
  26198. arc?: number;
  26199. slice?: number;
  26200. sideOrientation?: number;
  26201. frontUVs?: Vector4;
  26202. backUVs?: Vector4;
  26203. }): VertexData;
  26204. /**
  26205. * Creates the VertexData for a cylinder, cone or prism
  26206. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26207. * * height sets the height (y direction) of the cylinder, optional, default 2
  26208. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26209. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26210. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26211. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26212. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26213. * * 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
  26214. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26215. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26216. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26217. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26219. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26220. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26221. * @returns the VertexData of the cylinder, cone or prism
  26222. */
  26223. static CreateCylinder(options: {
  26224. height?: number;
  26225. diameterTop?: number;
  26226. diameterBottom?: number;
  26227. diameter?: number;
  26228. tessellation?: number;
  26229. subdivisions?: number;
  26230. arc?: number;
  26231. faceColors?: Color4[];
  26232. faceUV?: Vector4[];
  26233. hasRings?: boolean;
  26234. enclose?: boolean;
  26235. sideOrientation?: number;
  26236. frontUVs?: Vector4;
  26237. backUVs?: Vector4;
  26238. }): VertexData;
  26239. /**
  26240. * Creates the VertexData for a torus
  26241. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26242. * * diameter the diameter of the torus, optional default 1
  26243. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26244. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26246. * * 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)
  26247. * * 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)
  26248. * @returns the VertexData of the torus
  26249. */
  26250. static CreateTorus(options: {
  26251. diameter?: number;
  26252. thickness?: number;
  26253. tessellation?: number;
  26254. sideOrientation?: number;
  26255. frontUVs?: Vector4;
  26256. backUVs?: Vector4;
  26257. }): VertexData;
  26258. /**
  26259. * Creates the VertexData of the LineSystem
  26260. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26261. * - lines an array of lines, each line being an array of successive Vector3
  26262. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26263. * @returns the VertexData of the LineSystem
  26264. */
  26265. static CreateLineSystem(options: {
  26266. lines: Vector3[][];
  26267. colors?: Nullable<Color4[][]>;
  26268. }): VertexData;
  26269. /**
  26270. * Create the VertexData for a DashedLines
  26271. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26272. * - points an array successive Vector3
  26273. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26274. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26275. * - dashNb the intended total number of dashes, optional, default 200
  26276. * @returns the VertexData for the DashedLines
  26277. */
  26278. static CreateDashedLines(options: {
  26279. points: Vector3[];
  26280. dashSize?: number;
  26281. gapSize?: number;
  26282. dashNb?: number;
  26283. }): VertexData;
  26284. /**
  26285. * Creates the VertexData for a Ground
  26286. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26287. * - width the width (x direction) of the ground, optional, default 1
  26288. * - height the height (z direction) of the ground, optional, default 1
  26289. * - subdivisions the number of subdivisions per side, optional, default 1
  26290. * @returns the VertexData of the Ground
  26291. */
  26292. static CreateGround(options: {
  26293. width?: number;
  26294. height?: number;
  26295. subdivisions?: number;
  26296. subdivisionsX?: number;
  26297. subdivisionsY?: number;
  26298. }): VertexData;
  26299. /**
  26300. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26301. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26302. * * xmin the ground minimum X coordinate, optional, default -1
  26303. * * zmin the ground minimum Z coordinate, optional, default -1
  26304. * * xmax the ground maximum X coordinate, optional, default 1
  26305. * * zmax the ground maximum Z coordinate, optional, default 1
  26306. * * 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}
  26307. * * 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}
  26308. * @returns the VertexData of the TiledGround
  26309. */
  26310. static CreateTiledGround(options: {
  26311. xmin: number;
  26312. zmin: number;
  26313. xmax: number;
  26314. zmax: number;
  26315. subdivisions?: {
  26316. w: number;
  26317. h: number;
  26318. };
  26319. precision?: {
  26320. w: number;
  26321. h: number;
  26322. };
  26323. }): VertexData;
  26324. /**
  26325. * Creates the VertexData of the Ground designed from a heightmap
  26326. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26327. * * width the width (x direction) of the ground
  26328. * * height the height (z direction) of the ground
  26329. * * subdivisions the number of subdivisions per side
  26330. * * minHeight the minimum altitude on the ground, optional, default 0
  26331. * * maxHeight the maximum altitude on the ground, optional default 1
  26332. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26333. * * buffer the array holding the image color data
  26334. * * bufferWidth the width of image
  26335. * * bufferHeight the height of image
  26336. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26337. * @returns the VertexData of the Ground designed from a heightmap
  26338. */
  26339. static CreateGroundFromHeightMap(options: {
  26340. width: number;
  26341. height: number;
  26342. subdivisions: number;
  26343. minHeight: number;
  26344. maxHeight: number;
  26345. colorFilter: Color3;
  26346. buffer: Uint8Array;
  26347. bufferWidth: number;
  26348. bufferHeight: number;
  26349. alphaFilter: number;
  26350. }): VertexData;
  26351. /**
  26352. * Creates the VertexData for a Plane
  26353. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26354. * * size sets the width and height of the plane to the value of size, optional default 1
  26355. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26356. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26357. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26358. * * 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)
  26359. * * 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)
  26360. * @returns the VertexData of the box
  26361. */
  26362. static CreatePlane(options: {
  26363. size?: number;
  26364. width?: number;
  26365. height?: number;
  26366. sideOrientation?: number;
  26367. frontUVs?: Vector4;
  26368. backUVs?: Vector4;
  26369. }): VertexData;
  26370. /**
  26371. * Creates the VertexData of the Disc or regular Polygon
  26372. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26373. * * radius the radius of the disc, optional default 0.5
  26374. * * tessellation the number of polygon sides, optional, default 64
  26375. * * 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
  26376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26377. * * 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)
  26378. * * 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)
  26379. * @returns the VertexData of the box
  26380. */
  26381. static CreateDisc(options: {
  26382. radius?: number;
  26383. tessellation?: number;
  26384. arc?: number;
  26385. sideOrientation?: number;
  26386. frontUVs?: Vector4;
  26387. backUVs?: Vector4;
  26388. }): VertexData;
  26389. /**
  26390. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26391. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26392. * @param polygon a mesh built from polygonTriangulation.build()
  26393. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26394. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26395. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26396. * @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)
  26397. * @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)
  26398. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26399. * @returns the VertexData of the Polygon
  26400. */
  26401. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26402. /**
  26403. * Creates the VertexData of the IcoSphere
  26404. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26405. * * radius the radius of the IcoSphere, optional default 1
  26406. * * radiusX allows stretching in the x direction, optional, default radius
  26407. * * radiusY allows stretching in the y direction, optional, default radius
  26408. * * radiusZ allows stretching in the z direction, optional, default radius
  26409. * * flat when true creates a flat shaded mesh, optional, default true
  26410. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26412. * * 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)
  26413. * * 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)
  26414. * @returns the VertexData of the IcoSphere
  26415. */
  26416. static CreateIcoSphere(options: {
  26417. radius?: number;
  26418. radiusX?: number;
  26419. radiusY?: number;
  26420. radiusZ?: number;
  26421. flat?: boolean;
  26422. subdivisions?: number;
  26423. sideOrientation?: number;
  26424. frontUVs?: Vector4;
  26425. backUVs?: Vector4;
  26426. }): VertexData;
  26427. /**
  26428. * Creates the VertexData for a Polyhedron
  26429. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26430. * * type provided types are:
  26431. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26432. * * 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)
  26433. * * size the size of the IcoSphere, optional default 1
  26434. * * sizeX allows stretching in the x direction, optional, default size
  26435. * * sizeY allows stretching in the y direction, optional, default size
  26436. * * sizeZ allows stretching in the z direction, optional, default size
  26437. * * 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
  26438. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26439. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26440. * * flat when true creates a flat shaded mesh, optional, default true
  26441. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26442. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26443. * * 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)
  26444. * * 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)
  26445. * @returns the VertexData of the Polyhedron
  26446. */
  26447. static CreatePolyhedron(options: {
  26448. type?: number;
  26449. size?: number;
  26450. sizeX?: number;
  26451. sizeY?: number;
  26452. sizeZ?: number;
  26453. custom?: any;
  26454. faceUV?: Vector4[];
  26455. faceColors?: Color4[];
  26456. flat?: boolean;
  26457. sideOrientation?: number;
  26458. frontUVs?: Vector4;
  26459. backUVs?: Vector4;
  26460. }): VertexData;
  26461. /**
  26462. * Creates the VertexData for a TorusKnot
  26463. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26464. * * radius the radius of the torus knot, optional, default 2
  26465. * * tube the thickness of the tube, optional, default 0.5
  26466. * * radialSegments the number of sides on each tube segments, optional, default 32
  26467. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26468. * * p the number of windings around the z axis, optional, default 2
  26469. * * q the number of windings around the x axis, optional, default 3
  26470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26471. * * 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)
  26472. * * 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)
  26473. * @returns the VertexData of the Torus Knot
  26474. */
  26475. static CreateTorusKnot(options: {
  26476. radius?: number;
  26477. tube?: number;
  26478. radialSegments?: number;
  26479. tubularSegments?: number;
  26480. p?: number;
  26481. q?: number;
  26482. sideOrientation?: number;
  26483. frontUVs?: Vector4;
  26484. backUVs?: Vector4;
  26485. }): VertexData;
  26486. /**
  26487. * Compute normals for given positions and indices
  26488. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26489. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26490. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26491. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26492. * * facetNormals : optional array of facet normals (vector3)
  26493. * * facetPositions : optional array of facet positions (vector3)
  26494. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26495. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26496. * * bInfo : optional bounding info, required for facetPartitioning computation
  26497. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26498. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26499. * * useRightHandedSystem: optional boolean to for right handed system computation
  26500. * * depthSort : optional boolean to enable the facet depth sort computation
  26501. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26502. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26503. */
  26504. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26505. facetNormals?: any;
  26506. facetPositions?: any;
  26507. facetPartitioning?: any;
  26508. ratio?: number;
  26509. bInfo?: any;
  26510. bbSize?: Vector3;
  26511. subDiv?: any;
  26512. useRightHandedSystem?: boolean;
  26513. depthSort?: boolean;
  26514. distanceTo?: Vector3;
  26515. depthSortedFacets?: any;
  26516. }): void;
  26517. /** @hidden */
  26518. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26519. /**
  26520. * Applies VertexData created from the imported parameters to the geometry
  26521. * @param parsedVertexData the parsed data from an imported file
  26522. * @param geometry the geometry to apply the VertexData to
  26523. */
  26524. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26525. }
  26526. }
  26527. declare module BABYLON {
  26528. /**
  26529. * Defines a target to use with MorphTargetManager
  26530. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26531. */
  26532. export class MorphTarget implements IAnimatable {
  26533. /** defines the name of the target */
  26534. name: string;
  26535. /**
  26536. * Gets or sets the list of animations
  26537. */
  26538. animations: Animation[];
  26539. private _scene;
  26540. private _positions;
  26541. private _normals;
  26542. private _tangents;
  26543. private _uvs;
  26544. private _influence;
  26545. private _uniqueId;
  26546. /**
  26547. * Observable raised when the influence changes
  26548. */
  26549. onInfluenceChanged: Observable<boolean>;
  26550. /** @hidden */
  26551. _onDataLayoutChanged: Observable<void>;
  26552. /**
  26553. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26554. */
  26555. get influence(): number;
  26556. set influence(influence: number);
  26557. /**
  26558. * Gets or sets the id of the morph Target
  26559. */
  26560. id: string;
  26561. private _animationPropertiesOverride;
  26562. /**
  26563. * Gets or sets the animation properties override
  26564. */
  26565. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26566. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26567. /**
  26568. * Creates a new MorphTarget
  26569. * @param name defines the name of the target
  26570. * @param influence defines the influence to use
  26571. * @param scene defines the scene the morphtarget belongs to
  26572. */
  26573. constructor(
  26574. /** defines the name of the target */
  26575. name: string, influence?: number, scene?: Nullable<Scene>);
  26576. /**
  26577. * Gets the unique ID of this manager
  26578. */
  26579. get uniqueId(): number;
  26580. /**
  26581. * Gets a boolean defining if the target contains position data
  26582. */
  26583. get hasPositions(): boolean;
  26584. /**
  26585. * Gets a boolean defining if the target contains normal data
  26586. */
  26587. get hasNormals(): boolean;
  26588. /**
  26589. * Gets a boolean defining if the target contains tangent data
  26590. */
  26591. get hasTangents(): boolean;
  26592. /**
  26593. * Gets a boolean defining if the target contains texture coordinates data
  26594. */
  26595. get hasUVs(): boolean;
  26596. /**
  26597. * Affects position data to this target
  26598. * @param data defines the position data to use
  26599. */
  26600. setPositions(data: Nullable<FloatArray>): void;
  26601. /**
  26602. * Gets the position data stored in this target
  26603. * @returns a FloatArray containing the position data (or null if not present)
  26604. */
  26605. getPositions(): Nullable<FloatArray>;
  26606. /**
  26607. * Affects normal data to this target
  26608. * @param data defines the normal data to use
  26609. */
  26610. setNormals(data: Nullable<FloatArray>): void;
  26611. /**
  26612. * Gets the normal data stored in this target
  26613. * @returns a FloatArray containing the normal data (or null if not present)
  26614. */
  26615. getNormals(): Nullable<FloatArray>;
  26616. /**
  26617. * Affects tangent data to this target
  26618. * @param data defines the tangent data to use
  26619. */
  26620. setTangents(data: Nullable<FloatArray>): void;
  26621. /**
  26622. * Gets the tangent data stored in this target
  26623. * @returns a FloatArray containing the tangent data (or null if not present)
  26624. */
  26625. getTangents(): Nullable<FloatArray>;
  26626. /**
  26627. * Affects texture coordinates data to this target
  26628. * @param data defines the texture coordinates data to use
  26629. */
  26630. setUVs(data: Nullable<FloatArray>): void;
  26631. /**
  26632. * Gets the texture coordinates data stored in this target
  26633. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26634. */
  26635. getUVs(): Nullable<FloatArray>;
  26636. /**
  26637. * Clone the current target
  26638. * @returns a new MorphTarget
  26639. */
  26640. clone(): MorphTarget;
  26641. /**
  26642. * Serializes the current target into a Serialization object
  26643. * @returns the serialized object
  26644. */
  26645. serialize(): any;
  26646. /**
  26647. * Returns the string "MorphTarget"
  26648. * @returns "MorphTarget"
  26649. */
  26650. getClassName(): string;
  26651. /**
  26652. * Creates a new target from serialized data
  26653. * @param serializationObject defines the serialized data to use
  26654. * @returns a new MorphTarget
  26655. */
  26656. static Parse(serializationObject: any): MorphTarget;
  26657. /**
  26658. * Creates a MorphTarget from mesh data
  26659. * @param mesh defines the source mesh
  26660. * @param name defines the name to use for the new target
  26661. * @param influence defines the influence to attach to the target
  26662. * @returns a new MorphTarget
  26663. */
  26664. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26665. }
  26666. }
  26667. declare module BABYLON {
  26668. /**
  26669. * This class is used to deform meshes using morphing between different targets
  26670. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26671. */
  26672. export class MorphTargetManager {
  26673. private _targets;
  26674. private _targetInfluenceChangedObservers;
  26675. private _targetDataLayoutChangedObservers;
  26676. private _activeTargets;
  26677. private _scene;
  26678. private _influences;
  26679. private _supportsNormals;
  26680. private _supportsTangents;
  26681. private _supportsUVs;
  26682. private _vertexCount;
  26683. private _uniqueId;
  26684. private _tempInfluences;
  26685. /**
  26686. * Gets or sets a boolean indicating if normals must be morphed
  26687. */
  26688. enableNormalMorphing: boolean;
  26689. /**
  26690. * Gets or sets a boolean indicating if tangents must be morphed
  26691. */
  26692. enableTangentMorphing: boolean;
  26693. /**
  26694. * Gets or sets a boolean indicating if UV must be morphed
  26695. */
  26696. enableUVMorphing: boolean;
  26697. /**
  26698. * Creates a new MorphTargetManager
  26699. * @param scene defines the current scene
  26700. */
  26701. constructor(scene?: Nullable<Scene>);
  26702. /**
  26703. * Gets the unique ID of this manager
  26704. */
  26705. get uniqueId(): number;
  26706. /**
  26707. * Gets the number of vertices handled by this manager
  26708. */
  26709. get vertexCount(): number;
  26710. /**
  26711. * Gets a boolean indicating if this manager supports morphing of normals
  26712. */
  26713. get supportsNormals(): boolean;
  26714. /**
  26715. * Gets a boolean indicating if this manager supports morphing of tangents
  26716. */
  26717. get supportsTangents(): boolean;
  26718. /**
  26719. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26720. */
  26721. get supportsUVs(): boolean;
  26722. /**
  26723. * Gets the number of targets stored in this manager
  26724. */
  26725. get numTargets(): number;
  26726. /**
  26727. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26728. */
  26729. get numInfluencers(): number;
  26730. /**
  26731. * Gets the list of influences (one per target)
  26732. */
  26733. get influences(): Float32Array;
  26734. /**
  26735. * Gets the active target at specified index. An active target is a target with an influence > 0
  26736. * @param index defines the index to check
  26737. * @returns the requested target
  26738. */
  26739. getActiveTarget(index: number): MorphTarget;
  26740. /**
  26741. * Gets the target at specified index
  26742. * @param index defines the index to check
  26743. * @returns the requested target
  26744. */
  26745. getTarget(index: number): MorphTarget;
  26746. /**
  26747. * Add a new target to this manager
  26748. * @param target defines the target to add
  26749. */
  26750. addTarget(target: MorphTarget): void;
  26751. /**
  26752. * Removes a target from the manager
  26753. * @param target defines the target to remove
  26754. */
  26755. removeTarget(target: MorphTarget): void;
  26756. /**
  26757. * Clone the current manager
  26758. * @returns a new MorphTargetManager
  26759. */
  26760. clone(): MorphTargetManager;
  26761. /**
  26762. * Serializes the current manager into a Serialization object
  26763. * @returns the serialized object
  26764. */
  26765. serialize(): any;
  26766. private _syncActiveTargets;
  26767. /**
  26768. * Syncrhonize the targets with all the meshes using this morph target manager
  26769. */
  26770. synchronize(): void;
  26771. /**
  26772. * Creates a new MorphTargetManager from serialized data
  26773. * @param serializationObject defines the serialized data
  26774. * @param scene defines the hosting scene
  26775. * @returns the new MorphTargetManager
  26776. */
  26777. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26778. }
  26779. }
  26780. declare module BABYLON {
  26781. /**
  26782. * Class used to represent a specific level of detail of a mesh
  26783. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26784. */
  26785. export class MeshLODLevel {
  26786. /** Defines the distance where this level should start being displayed */
  26787. distance: number;
  26788. /** Defines the mesh to use to render this level */
  26789. mesh: Nullable<Mesh>;
  26790. /**
  26791. * Creates a new LOD level
  26792. * @param distance defines the distance where this level should star being displayed
  26793. * @param mesh defines the mesh to use to render this level
  26794. */
  26795. constructor(
  26796. /** Defines the distance where this level should start being displayed */
  26797. distance: number,
  26798. /** Defines the mesh to use to render this level */
  26799. mesh: Nullable<Mesh>);
  26800. }
  26801. }
  26802. declare module BABYLON {
  26803. /**
  26804. * Helper class used to generate a canvas to manipulate images
  26805. */
  26806. export class CanvasGenerator {
  26807. /**
  26808. * Create a new canvas (or offscreen canvas depending on the context)
  26809. * @param width defines the expected width
  26810. * @param height defines the expected height
  26811. * @return a new canvas or offscreen canvas
  26812. */
  26813. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26814. }
  26815. }
  26816. declare module BABYLON {
  26817. /**
  26818. * Mesh representing the gorund
  26819. */
  26820. export class GroundMesh extends Mesh {
  26821. /** If octree should be generated */
  26822. generateOctree: boolean;
  26823. private _heightQuads;
  26824. /** @hidden */
  26825. _subdivisionsX: number;
  26826. /** @hidden */
  26827. _subdivisionsY: number;
  26828. /** @hidden */
  26829. _width: number;
  26830. /** @hidden */
  26831. _height: number;
  26832. /** @hidden */
  26833. _minX: number;
  26834. /** @hidden */
  26835. _maxX: number;
  26836. /** @hidden */
  26837. _minZ: number;
  26838. /** @hidden */
  26839. _maxZ: number;
  26840. constructor(name: string, scene: Scene);
  26841. /**
  26842. * "GroundMesh"
  26843. * @returns "GroundMesh"
  26844. */
  26845. getClassName(): string;
  26846. /**
  26847. * The minimum of x and y subdivisions
  26848. */
  26849. get subdivisions(): number;
  26850. /**
  26851. * X subdivisions
  26852. */
  26853. get subdivisionsX(): number;
  26854. /**
  26855. * Y subdivisions
  26856. */
  26857. get subdivisionsY(): number;
  26858. /**
  26859. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26860. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26861. * @param chunksCount the number of subdivisions for x and y
  26862. * @param octreeBlocksSize (Default: 32)
  26863. */
  26864. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26865. /**
  26866. * Returns a height (y) value in the Worl system :
  26867. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26868. * @param x x coordinate
  26869. * @param z z coordinate
  26870. * @returns the ground y position if (x, z) are outside the ground surface.
  26871. */
  26872. getHeightAtCoordinates(x: number, z: number): number;
  26873. /**
  26874. * Returns a normalized vector (Vector3) orthogonal to the ground
  26875. * at the ground coordinates (x, z) expressed in the World system.
  26876. * @param x x coordinate
  26877. * @param z z coordinate
  26878. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26879. */
  26880. getNormalAtCoordinates(x: number, z: number): Vector3;
  26881. /**
  26882. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26883. * at the ground coordinates (x, z) expressed in the World system.
  26884. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26885. * @param x x coordinate
  26886. * @param z z coordinate
  26887. * @param ref vector to store the result
  26888. * @returns the GroundMesh.
  26889. */
  26890. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26891. /**
  26892. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26893. * if the ground has been updated.
  26894. * This can be used in the render loop.
  26895. * @returns the GroundMesh.
  26896. */
  26897. updateCoordinateHeights(): GroundMesh;
  26898. private _getFacetAt;
  26899. private _initHeightQuads;
  26900. private _computeHeightQuads;
  26901. /**
  26902. * Serializes this ground mesh
  26903. * @param serializationObject object to write serialization to
  26904. */
  26905. serialize(serializationObject: any): void;
  26906. /**
  26907. * Parses a serialized ground mesh
  26908. * @param parsedMesh the serialized mesh
  26909. * @param scene the scene to create the ground mesh in
  26910. * @returns the created ground mesh
  26911. */
  26912. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26913. }
  26914. }
  26915. declare module BABYLON {
  26916. /**
  26917. * Interface for Physics-Joint data
  26918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26919. */
  26920. export interface PhysicsJointData {
  26921. /**
  26922. * The main pivot of the joint
  26923. */
  26924. mainPivot?: Vector3;
  26925. /**
  26926. * The connected pivot of the joint
  26927. */
  26928. connectedPivot?: Vector3;
  26929. /**
  26930. * The main axis of the joint
  26931. */
  26932. mainAxis?: Vector3;
  26933. /**
  26934. * The connected axis of the joint
  26935. */
  26936. connectedAxis?: Vector3;
  26937. /**
  26938. * The collision of the joint
  26939. */
  26940. collision?: boolean;
  26941. /**
  26942. * Native Oimo/Cannon/Energy data
  26943. */
  26944. nativeParams?: any;
  26945. }
  26946. /**
  26947. * This is a holder class for the physics joint created by the physics plugin
  26948. * It holds a set of functions to control the underlying joint
  26949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26950. */
  26951. export class PhysicsJoint {
  26952. /**
  26953. * The type of the physics joint
  26954. */
  26955. type: number;
  26956. /**
  26957. * The data for the physics joint
  26958. */
  26959. jointData: PhysicsJointData;
  26960. private _physicsJoint;
  26961. protected _physicsPlugin: IPhysicsEnginePlugin;
  26962. /**
  26963. * Initializes the physics joint
  26964. * @param type The type of the physics joint
  26965. * @param jointData The data for the physics joint
  26966. */
  26967. constructor(
  26968. /**
  26969. * The type of the physics joint
  26970. */
  26971. type: number,
  26972. /**
  26973. * The data for the physics joint
  26974. */
  26975. jointData: PhysicsJointData);
  26976. /**
  26977. * Gets the physics joint
  26978. */
  26979. get physicsJoint(): any;
  26980. /**
  26981. * Sets the physics joint
  26982. */
  26983. set physicsJoint(newJoint: any);
  26984. /**
  26985. * Sets the physics plugin
  26986. */
  26987. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26988. /**
  26989. * Execute a function that is physics-plugin specific.
  26990. * @param {Function} func the function that will be executed.
  26991. * It accepts two parameters: the physics world and the physics joint
  26992. */
  26993. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26994. /**
  26995. * Distance-Joint type
  26996. */
  26997. static DistanceJoint: number;
  26998. /**
  26999. * Hinge-Joint type
  27000. */
  27001. static HingeJoint: number;
  27002. /**
  27003. * Ball-and-Socket joint type
  27004. */
  27005. static BallAndSocketJoint: number;
  27006. /**
  27007. * Wheel-Joint type
  27008. */
  27009. static WheelJoint: number;
  27010. /**
  27011. * Slider-Joint type
  27012. */
  27013. static SliderJoint: number;
  27014. /**
  27015. * Prismatic-Joint type
  27016. */
  27017. static PrismaticJoint: number;
  27018. /**
  27019. * Universal-Joint type
  27020. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27021. */
  27022. static UniversalJoint: number;
  27023. /**
  27024. * Hinge-Joint 2 type
  27025. */
  27026. static Hinge2Joint: number;
  27027. /**
  27028. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27029. */
  27030. static PointToPointJoint: number;
  27031. /**
  27032. * Spring-Joint type
  27033. */
  27034. static SpringJoint: number;
  27035. /**
  27036. * Lock-Joint type
  27037. */
  27038. static LockJoint: number;
  27039. }
  27040. /**
  27041. * A class representing a physics distance joint
  27042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27043. */
  27044. export class DistanceJoint extends PhysicsJoint {
  27045. /**
  27046. *
  27047. * @param jointData The data for the Distance-Joint
  27048. */
  27049. constructor(jointData: DistanceJointData);
  27050. /**
  27051. * Update the predefined distance.
  27052. * @param maxDistance The maximum preferred distance
  27053. * @param minDistance The minimum preferred distance
  27054. */
  27055. updateDistance(maxDistance: number, minDistance?: number): void;
  27056. }
  27057. /**
  27058. * Represents a Motor-Enabled Joint
  27059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27060. */
  27061. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27062. /**
  27063. * Initializes the Motor-Enabled Joint
  27064. * @param type The type of the joint
  27065. * @param jointData The physica joint data for the joint
  27066. */
  27067. constructor(type: number, jointData: PhysicsJointData);
  27068. /**
  27069. * Set the motor values.
  27070. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27071. * @param force the force to apply
  27072. * @param maxForce max force for this motor.
  27073. */
  27074. setMotor(force?: number, maxForce?: number): void;
  27075. /**
  27076. * Set the motor's limits.
  27077. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27078. * @param upperLimit The upper limit of the motor
  27079. * @param lowerLimit The lower limit of the motor
  27080. */
  27081. setLimit(upperLimit: number, lowerLimit?: number): void;
  27082. }
  27083. /**
  27084. * This class represents a single physics Hinge-Joint
  27085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27086. */
  27087. export class HingeJoint extends MotorEnabledJoint {
  27088. /**
  27089. * Initializes the Hinge-Joint
  27090. * @param jointData The joint data for the Hinge-Joint
  27091. */
  27092. constructor(jointData: PhysicsJointData);
  27093. /**
  27094. * Set the motor values.
  27095. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27096. * @param {number} force the force to apply
  27097. * @param {number} maxForce max force for this motor.
  27098. */
  27099. setMotor(force?: number, maxForce?: number): void;
  27100. /**
  27101. * Set the motor's limits.
  27102. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27103. * @param upperLimit The upper limit of the motor
  27104. * @param lowerLimit The lower limit of the motor
  27105. */
  27106. setLimit(upperLimit: number, lowerLimit?: number): void;
  27107. }
  27108. /**
  27109. * This class represents a dual hinge physics joint (same as wheel joint)
  27110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27111. */
  27112. export class Hinge2Joint extends MotorEnabledJoint {
  27113. /**
  27114. * Initializes the Hinge2-Joint
  27115. * @param jointData The joint data for the Hinge2-Joint
  27116. */
  27117. constructor(jointData: PhysicsJointData);
  27118. /**
  27119. * Set the motor values.
  27120. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27121. * @param {number} targetSpeed the speed the motor is to reach
  27122. * @param {number} maxForce max force for this motor.
  27123. * @param {motorIndex} the motor's index, 0 or 1.
  27124. */
  27125. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27126. /**
  27127. * Set the motor limits.
  27128. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27129. * @param {number} upperLimit the upper limit
  27130. * @param {number} lowerLimit lower limit
  27131. * @param {motorIndex} the motor's index, 0 or 1.
  27132. */
  27133. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27134. }
  27135. /**
  27136. * Interface for a motor enabled joint
  27137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27138. */
  27139. export interface IMotorEnabledJoint {
  27140. /**
  27141. * Physics joint
  27142. */
  27143. physicsJoint: any;
  27144. /**
  27145. * Sets the motor of the motor-enabled joint
  27146. * @param force The force of the motor
  27147. * @param maxForce The maximum force of the motor
  27148. * @param motorIndex The index of the motor
  27149. */
  27150. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27151. /**
  27152. * Sets the limit of the motor
  27153. * @param upperLimit The upper limit of the motor
  27154. * @param lowerLimit The lower limit of the motor
  27155. * @param motorIndex The index of the motor
  27156. */
  27157. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27158. }
  27159. /**
  27160. * Joint data for a Distance-Joint
  27161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27162. */
  27163. export interface DistanceJointData extends PhysicsJointData {
  27164. /**
  27165. * Max distance the 2 joint objects can be apart
  27166. */
  27167. maxDistance: number;
  27168. }
  27169. /**
  27170. * Joint data from a spring joint
  27171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27172. */
  27173. export interface SpringJointData extends PhysicsJointData {
  27174. /**
  27175. * Length of the spring
  27176. */
  27177. length: number;
  27178. /**
  27179. * Stiffness of the spring
  27180. */
  27181. stiffness: number;
  27182. /**
  27183. * Damping of the spring
  27184. */
  27185. damping: number;
  27186. /** this callback will be called when applying the force to the impostors. */
  27187. forceApplicationCallback: () => void;
  27188. }
  27189. }
  27190. declare module BABYLON {
  27191. /**
  27192. * Holds the data for the raycast result
  27193. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27194. */
  27195. export class PhysicsRaycastResult {
  27196. private _hasHit;
  27197. private _hitDistance;
  27198. private _hitNormalWorld;
  27199. private _hitPointWorld;
  27200. private _rayFromWorld;
  27201. private _rayToWorld;
  27202. /**
  27203. * Gets if there was a hit
  27204. */
  27205. get hasHit(): boolean;
  27206. /**
  27207. * Gets the distance from the hit
  27208. */
  27209. get hitDistance(): number;
  27210. /**
  27211. * Gets the hit normal/direction in the world
  27212. */
  27213. get hitNormalWorld(): Vector3;
  27214. /**
  27215. * Gets the hit point in the world
  27216. */
  27217. get hitPointWorld(): Vector3;
  27218. /**
  27219. * Gets the ray "start point" of the ray in the world
  27220. */
  27221. get rayFromWorld(): Vector3;
  27222. /**
  27223. * Gets the ray "end point" of the ray in the world
  27224. */
  27225. get rayToWorld(): Vector3;
  27226. /**
  27227. * Sets the hit data (normal & point in world space)
  27228. * @param hitNormalWorld defines the normal in world space
  27229. * @param hitPointWorld defines the point in world space
  27230. */
  27231. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27232. /**
  27233. * Sets the distance from the start point to the hit point
  27234. * @param distance
  27235. */
  27236. setHitDistance(distance: number): void;
  27237. /**
  27238. * Calculates the distance manually
  27239. */
  27240. calculateHitDistance(): void;
  27241. /**
  27242. * Resets all the values to default
  27243. * @param from The from point on world space
  27244. * @param to The to point on world space
  27245. */
  27246. reset(from?: Vector3, to?: Vector3): void;
  27247. }
  27248. /**
  27249. * Interface for the size containing width and height
  27250. */
  27251. interface IXYZ {
  27252. /**
  27253. * X
  27254. */
  27255. x: number;
  27256. /**
  27257. * Y
  27258. */
  27259. y: number;
  27260. /**
  27261. * Z
  27262. */
  27263. z: number;
  27264. }
  27265. }
  27266. declare module BABYLON {
  27267. /**
  27268. * Interface used to describe a physics joint
  27269. */
  27270. export interface PhysicsImpostorJoint {
  27271. /** Defines the main impostor to which the joint is linked */
  27272. mainImpostor: PhysicsImpostor;
  27273. /** Defines the impostor that is connected to the main impostor using this joint */
  27274. connectedImpostor: PhysicsImpostor;
  27275. /** Defines the joint itself */
  27276. joint: PhysicsJoint;
  27277. }
  27278. /** @hidden */
  27279. export interface IPhysicsEnginePlugin {
  27280. world: any;
  27281. name: string;
  27282. setGravity(gravity: Vector3): void;
  27283. setTimeStep(timeStep: number): void;
  27284. getTimeStep(): number;
  27285. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27286. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27287. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27288. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27289. removePhysicsBody(impostor: PhysicsImpostor): void;
  27290. generateJoint(joint: PhysicsImpostorJoint): void;
  27291. removeJoint(joint: PhysicsImpostorJoint): void;
  27292. isSupported(): boolean;
  27293. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27294. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27295. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27296. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27297. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27298. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27299. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27300. getBodyMass(impostor: PhysicsImpostor): number;
  27301. getBodyFriction(impostor: PhysicsImpostor): number;
  27302. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27303. getBodyRestitution(impostor: PhysicsImpostor): number;
  27304. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27305. getBodyPressure?(impostor: PhysicsImpostor): number;
  27306. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27307. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27308. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27309. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27310. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27311. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27312. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27313. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27314. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27315. sleepBody(impostor: PhysicsImpostor): void;
  27316. wakeUpBody(impostor: PhysicsImpostor): void;
  27317. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27318. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27319. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27320. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27321. getRadius(impostor: PhysicsImpostor): number;
  27322. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27323. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27324. dispose(): void;
  27325. }
  27326. /**
  27327. * Interface used to define a physics engine
  27328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27329. */
  27330. export interface IPhysicsEngine {
  27331. /**
  27332. * Gets the gravity vector used by the simulation
  27333. */
  27334. gravity: Vector3;
  27335. /**
  27336. * Sets the gravity vector used by the simulation
  27337. * @param gravity defines the gravity vector to use
  27338. */
  27339. setGravity(gravity: Vector3): void;
  27340. /**
  27341. * Set the time step of the physics engine.
  27342. * Default is 1/60.
  27343. * To slow it down, enter 1/600 for example.
  27344. * To speed it up, 1/30
  27345. * @param newTimeStep the new timestep to apply to this world.
  27346. */
  27347. setTimeStep(newTimeStep: number): void;
  27348. /**
  27349. * Get the time step of the physics engine.
  27350. * @returns the current time step
  27351. */
  27352. getTimeStep(): number;
  27353. /**
  27354. * Set the sub time step of the physics engine.
  27355. * Default is 0 meaning there is no sub steps
  27356. * To increase physics resolution precision, set a small value (like 1 ms)
  27357. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27358. */
  27359. setSubTimeStep(subTimeStep: number): void;
  27360. /**
  27361. * Get the sub time step of the physics engine.
  27362. * @returns the current sub time step
  27363. */
  27364. getSubTimeStep(): number;
  27365. /**
  27366. * Release all resources
  27367. */
  27368. dispose(): void;
  27369. /**
  27370. * Gets the name of the current physics plugin
  27371. * @returns the name of the plugin
  27372. */
  27373. getPhysicsPluginName(): string;
  27374. /**
  27375. * Adding a new impostor for the impostor tracking.
  27376. * This will be done by the impostor itself.
  27377. * @param impostor the impostor to add
  27378. */
  27379. addImpostor(impostor: PhysicsImpostor): void;
  27380. /**
  27381. * Remove an impostor from the engine.
  27382. * This impostor and its mesh will not longer be updated by the physics engine.
  27383. * @param impostor the impostor to remove
  27384. */
  27385. removeImpostor(impostor: PhysicsImpostor): void;
  27386. /**
  27387. * Add a joint to the physics engine
  27388. * @param mainImpostor defines the main impostor to which the joint is added.
  27389. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27390. * @param joint defines the joint that will connect both impostors.
  27391. */
  27392. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27393. /**
  27394. * Removes a joint from the simulation
  27395. * @param mainImpostor defines the impostor used with the joint
  27396. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27397. * @param joint defines the joint to remove
  27398. */
  27399. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27400. /**
  27401. * Gets the current plugin used to run the simulation
  27402. * @returns current plugin
  27403. */
  27404. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27405. /**
  27406. * Gets the list of physic impostors
  27407. * @returns an array of PhysicsImpostor
  27408. */
  27409. getImpostors(): Array<PhysicsImpostor>;
  27410. /**
  27411. * Gets the impostor for a physics enabled object
  27412. * @param object defines the object impersonated by the impostor
  27413. * @returns the PhysicsImpostor or null if not found
  27414. */
  27415. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27416. /**
  27417. * Gets the impostor for a physics body object
  27418. * @param body defines physics body used by the impostor
  27419. * @returns the PhysicsImpostor or null if not found
  27420. */
  27421. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27422. /**
  27423. * Does a raycast in the physics world
  27424. * @param from when should the ray start?
  27425. * @param to when should the ray end?
  27426. * @returns PhysicsRaycastResult
  27427. */
  27428. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27429. /**
  27430. * Called by the scene. No need to call it.
  27431. * @param delta defines the timespam between frames
  27432. */
  27433. _step(delta: number): void;
  27434. }
  27435. }
  27436. declare module BABYLON {
  27437. /**
  27438. * The interface for the physics imposter parameters
  27439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27440. */
  27441. export interface PhysicsImpostorParameters {
  27442. /**
  27443. * The mass of the physics imposter
  27444. */
  27445. mass: number;
  27446. /**
  27447. * The friction of the physics imposter
  27448. */
  27449. friction?: number;
  27450. /**
  27451. * The coefficient of restitution of the physics imposter
  27452. */
  27453. restitution?: number;
  27454. /**
  27455. * The native options of the physics imposter
  27456. */
  27457. nativeOptions?: any;
  27458. /**
  27459. * Specifies if the parent should be ignored
  27460. */
  27461. ignoreParent?: boolean;
  27462. /**
  27463. * Specifies if bi-directional transformations should be disabled
  27464. */
  27465. disableBidirectionalTransformation?: boolean;
  27466. /**
  27467. * The pressure inside the physics imposter, soft object only
  27468. */
  27469. pressure?: number;
  27470. /**
  27471. * The stiffness the physics imposter, soft object only
  27472. */
  27473. stiffness?: number;
  27474. /**
  27475. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27476. */
  27477. velocityIterations?: number;
  27478. /**
  27479. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27480. */
  27481. positionIterations?: number;
  27482. /**
  27483. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27484. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27485. * Add to fix multiple points
  27486. */
  27487. fixedPoints?: number;
  27488. /**
  27489. * The collision margin around a soft object
  27490. */
  27491. margin?: number;
  27492. /**
  27493. * The collision margin around a soft object
  27494. */
  27495. damping?: number;
  27496. /**
  27497. * The path for a rope based on an extrusion
  27498. */
  27499. path?: any;
  27500. /**
  27501. * The shape of an extrusion used for a rope based on an extrusion
  27502. */
  27503. shape?: any;
  27504. }
  27505. /**
  27506. * Interface for a physics-enabled object
  27507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27508. */
  27509. export interface IPhysicsEnabledObject {
  27510. /**
  27511. * The position of the physics-enabled object
  27512. */
  27513. position: Vector3;
  27514. /**
  27515. * The rotation of the physics-enabled object
  27516. */
  27517. rotationQuaternion: Nullable<Quaternion>;
  27518. /**
  27519. * The scale of the physics-enabled object
  27520. */
  27521. scaling: Vector3;
  27522. /**
  27523. * The rotation of the physics-enabled object
  27524. */
  27525. rotation?: Vector3;
  27526. /**
  27527. * The parent of the physics-enabled object
  27528. */
  27529. parent?: any;
  27530. /**
  27531. * The bounding info of the physics-enabled object
  27532. * @returns The bounding info of the physics-enabled object
  27533. */
  27534. getBoundingInfo(): BoundingInfo;
  27535. /**
  27536. * Computes the world matrix
  27537. * @param force Specifies if the world matrix should be computed by force
  27538. * @returns A world matrix
  27539. */
  27540. computeWorldMatrix(force: boolean): Matrix;
  27541. /**
  27542. * Gets the world matrix
  27543. * @returns A world matrix
  27544. */
  27545. getWorldMatrix?(): Matrix;
  27546. /**
  27547. * Gets the child meshes
  27548. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27549. * @returns An array of abstract meshes
  27550. */
  27551. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27552. /**
  27553. * Gets the vertex data
  27554. * @param kind The type of vertex data
  27555. * @returns A nullable array of numbers, or a float32 array
  27556. */
  27557. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27558. /**
  27559. * Gets the indices from the mesh
  27560. * @returns A nullable array of index arrays
  27561. */
  27562. getIndices?(): Nullable<IndicesArray>;
  27563. /**
  27564. * Gets the scene from the mesh
  27565. * @returns the indices array or null
  27566. */
  27567. getScene?(): Scene;
  27568. /**
  27569. * Gets the absolute position from the mesh
  27570. * @returns the absolute position
  27571. */
  27572. getAbsolutePosition(): Vector3;
  27573. /**
  27574. * Gets the absolute pivot point from the mesh
  27575. * @returns the absolute pivot point
  27576. */
  27577. getAbsolutePivotPoint(): Vector3;
  27578. /**
  27579. * Rotates the mesh
  27580. * @param axis The axis of rotation
  27581. * @param amount The amount of rotation
  27582. * @param space The space of the rotation
  27583. * @returns The rotation transform node
  27584. */
  27585. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27586. /**
  27587. * Translates the mesh
  27588. * @param axis The axis of translation
  27589. * @param distance The distance of translation
  27590. * @param space The space of the translation
  27591. * @returns The transform node
  27592. */
  27593. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27594. /**
  27595. * Sets the absolute position of the mesh
  27596. * @param absolutePosition The absolute position of the mesh
  27597. * @returns The transform node
  27598. */
  27599. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27600. /**
  27601. * Gets the class name of the mesh
  27602. * @returns The class name
  27603. */
  27604. getClassName(): string;
  27605. }
  27606. /**
  27607. * Represents a physics imposter
  27608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27609. */
  27610. export class PhysicsImpostor {
  27611. /**
  27612. * The physics-enabled object used as the physics imposter
  27613. */
  27614. object: IPhysicsEnabledObject;
  27615. /**
  27616. * The type of the physics imposter
  27617. */
  27618. type: number;
  27619. private _options;
  27620. private _scene?;
  27621. /**
  27622. * The default object size of the imposter
  27623. */
  27624. static DEFAULT_OBJECT_SIZE: Vector3;
  27625. /**
  27626. * The identity quaternion of the imposter
  27627. */
  27628. static IDENTITY_QUATERNION: Quaternion;
  27629. /** @hidden */
  27630. _pluginData: any;
  27631. private _physicsEngine;
  27632. private _physicsBody;
  27633. private _bodyUpdateRequired;
  27634. private _onBeforePhysicsStepCallbacks;
  27635. private _onAfterPhysicsStepCallbacks;
  27636. /** @hidden */
  27637. _onPhysicsCollideCallbacks: Array<{
  27638. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27639. otherImpostors: Array<PhysicsImpostor>;
  27640. }>;
  27641. private _deltaPosition;
  27642. private _deltaRotation;
  27643. private _deltaRotationConjugated;
  27644. /** @hidden */
  27645. _isFromLine: boolean;
  27646. private _parent;
  27647. private _isDisposed;
  27648. private static _tmpVecs;
  27649. private static _tmpQuat;
  27650. /**
  27651. * Specifies if the physics imposter is disposed
  27652. */
  27653. get isDisposed(): boolean;
  27654. /**
  27655. * Gets the mass of the physics imposter
  27656. */
  27657. get mass(): number;
  27658. set mass(value: number);
  27659. /**
  27660. * Gets the coefficient of friction
  27661. */
  27662. get friction(): number;
  27663. /**
  27664. * Sets the coefficient of friction
  27665. */
  27666. set friction(value: number);
  27667. /**
  27668. * Gets the coefficient of restitution
  27669. */
  27670. get restitution(): number;
  27671. /**
  27672. * Sets the coefficient of restitution
  27673. */
  27674. set restitution(value: number);
  27675. /**
  27676. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27677. */
  27678. get pressure(): number;
  27679. /**
  27680. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27681. */
  27682. set pressure(value: number);
  27683. /**
  27684. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27685. */
  27686. get stiffness(): number;
  27687. /**
  27688. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27689. */
  27690. set stiffness(value: number);
  27691. /**
  27692. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27693. */
  27694. get velocityIterations(): number;
  27695. /**
  27696. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27697. */
  27698. set velocityIterations(value: number);
  27699. /**
  27700. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27701. */
  27702. get positionIterations(): number;
  27703. /**
  27704. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27705. */
  27706. set positionIterations(value: number);
  27707. /**
  27708. * The unique id of the physics imposter
  27709. * set by the physics engine when adding this impostor to the array
  27710. */
  27711. uniqueId: number;
  27712. /**
  27713. * @hidden
  27714. */
  27715. soft: boolean;
  27716. /**
  27717. * @hidden
  27718. */
  27719. segments: number;
  27720. private _joints;
  27721. /**
  27722. * Initializes the physics imposter
  27723. * @param object The physics-enabled object used as the physics imposter
  27724. * @param type The type of the physics imposter
  27725. * @param _options The options for the physics imposter
  27726. * @param _scene The Babylon scene
  27727. */
  27728. constructor(
  27729. /**
  27730. * The physics-enabled object used as the physics imposter
  27731. */
  27732. object: IPhysicsEnabledObject,
  27733. /**
  27734. * The type of the physics imposter
  27735. */
  27736. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27737. /**
  27738. * This function will completly initialize this impostor.
  27739. * It will create a new body - but only if this mesh has no parent.
  27740. * If it has, this impostor will not be used other than to define the impostor
  27741. * of the child mesh.
  27742. * @hidden
  27743. */
  27744. _init(): void;
  27745. private _getPhysicsParent;
  27746. /**
  27747. * Should a new body be generated.
  27748. * @returns boolean specifying if body initialization is required
  27749. */
  27750. isBodyInitRequired(): boolean;
  27751. /**
  27752. * Sets the updated scaling
  27753. * @param updated Specifies if the scaling is updated
  27754. */
  27755. setScalingUpdated(): void;
  27756. /**
  27757. * Force a regeneration of this or the parent's impostor's body.
  27758. * Use under cautious - This will remove all joints already implemented.
  27759. */
  27760. forceUpdate(): void;
  27761. /**
  27762. * Gets the body that holds this impostor. Either its own, or its parent.
  27763. */
  27764. get physicsBody(): any;
  27765. /**
  27766. * Get the parent of the physics imposter
  27767. * @returns Physics imposter or null
  27768. */
  27769. get parent(): Nullable<PhysicsImpostor>;
  27770. /**
  27771. * Sets the parent of the physics imposter
  27772. */
  27773. set parent(value: Nullable<PhysicsImpostor>);
  27774. /**
  27775. * Set the physics body. Used mainly by the physics engine/plugin
  27776. */
  27777. set physicsBody(physicsBody: any);
  27778. /**
  27779. * Resets the update flags
  27780. */
  27781. resetUpdateFlags(): void;
  27782. /**
  27783. * Gets the object extend size
  27784. * @returns the object extend size
  27785. */
  27786. getObjectExtendSize(): Vector3;
  27787. /**
  27788. * Gets the object center
  27789. * @returns The object center
  27790. */
  27791. getObjectCenter(): Vector3;
  27792. /**
  27793. * Get a specific parameter from the options parameters
  27794. * @param paramName The object parameter name
  27795. * @returns The object parameter
  27796. */
  27797. getParam(paramName: string): any;
  27798. /**
  27799. * Sets a specific parameter in the options given to the physics plugin
  27800. * @param paramName The parameter name
  27801. * @param value The value of the parameter
  27802. */
  27803. setParam(paramName: string, value: number): void;
  27804. /**
  27805. * Specifically change the body's mass option. Won't recreate the physics body object
  27806. * @param mass The mass of the physics imposter
  27807. */
  27808. setMass(mass: number): void;
  27809. /**
  27810. * Gets the linear velocity
  27811. * @returns linear velocity or null
  27812. */
  27813. getLinearVelocity(): Nullable<Vector3>;
  27814. /**
  27815. * Sets the linear velocity
  27816. * @param velocity linear velocity or null
  27817. */
  27818. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27819. /**
  27820. * Gets the angular velocity
  27821. * @returns angular velocity or null
  27822. */
  27823. getAngularVelocity(): Nullable<Vector3>;
  27824. /**
  27825. * Sets the angular velocity
  27826. * @param velocity The velocity or null
  27827. */
  27828. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27829. /**
  27830. * Execute a function with the physics plugin native code
  27831. * Provide a function the will have two variables - the world object and the physics body object
  27832. * @param func The function to execute with the physics plugin native code
  27833. */
  27834. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27835. /**
  27836. * Register a function that will be executed before the physics world is stepping forward
  27837. * @param func The function to execute before the physics world is stepped forward
  27838. */
  27839. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27840. /**
  27841. * Unregister a function that will be executed before the physics world is stepping forward
  27842. * @param func The function to execute before the physics world is stepped forward
  27843. */
  27844. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27845. /**
  27846. * Register a function that will be executed after the physics step
  27847. * @param func The function to execute after physics step
  27848. */
  27849. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27850. /**
  27851. * Unregisters a function that will be executed after the physics step
  27852. * @param func The function to execute after physics step
  27853. */
  27854. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27855. /**
  27856. * register a function that will be executed when this impostor collides against a different body
  27857. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27858. * @param func Callback that is executed on collision
  27859. */
  27860. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27861. /**
  27862. * Unregisters the physics imposter on contact
  27863. * @param collideAgainst The physics object to collide against
  27864. * @param func Callback to execute on collision
  27865. */
  27866. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27867. private _tmpQuat;
  27868. private _tmpQuat2;
  27869. /**
  27870. * Get the parent rotation
  27871. * @returns The parent rotation
  27872. */
  27873. getParentsRotation(): Quaternion;
  27874. /**
  27875. * this function is executed by the physics engine.
  27876. */
  27877. beforeStep: () => void;
  27878. /**
  27879. * this function is executed by the physics engine
  27880. */
  27881. afterStep: () => void;
  27882. /**
  27883. * Legacy collision detection event support
  27884. */
  27885. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27886. /**
  27887. * event and body object due to cannon's event-based architecture.
  27888. */
  27889. onCollide: (e: {
  27890. body: any;
  27891. }) => void;
  27892. /**
  27893. * Apply a force
  27894. * @param force The force to apply
  27895. * @param contactPoint The contact point for the force
  27896. * @returns The physics imposter
  27897. */
  27898. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27899. /**
  27900. * Apply an impulse
  27901. * @param force The impulse force
  27902. * @param contactPoint The contact point for the impulse force
  27903. * @returns The physics imposter
  27904. */
  27905. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27906. /**
  27907. * A help function to create a joint
  27908. * @param otherImpostor A physics imposter used to create a joint
  27909. * @param jointType The type of joint
  27910. * @param jointData The data for the joint
  27911. * @returns The physics imposter
  27912. */
  27913. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27914. /**
  27915. * Add a joint to this impostor with a different impostor
  27916. * @param otherImpostor A physics imposter used to add a joint
  27917. * @param joint The joint to add
  27918. * @returns The physics imposter
  27919. */
  27920. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27921. /**
  27922. * Add an anchor to a cloth impostor
  27923. * @param otherImpostor rigid impostor to anchor to
  27924. * @param width ratio across width from 0 to 1
  27925. * @param height ratio up height from 0 to 1
  27926. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27927. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27928. * @returns impostor the soft imposter
  27929. */
  27930. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27931. /**
  27932. * Add a hook to a rope impostor
  27933. * @param otherImpostor rigid impostor to anchor to
  27934. * @param length ratio across rope from 0 to 1
  27935. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27936. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27937. * @returns impostor the rope imposter
  27938. */
  27939. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27940. /**
  27941. * Will keep this body still, in a sleep mode.
  27942. * @returns the physics imposter
  27943. */
  27944. sleep(): PhysicsImpostor;
  27945. /**
  27946. * Wake the body up.
  27947. * @returns The physics imposter
  27948. */
  27949. wakeUp(): PhysicsImpostor;
  27950. /**
  27951. * Clones the physics imposter
  27952. * @param newObject The physics imposter clones to this physics-enabled object
  27953. * @returns A nullable physics imposter
  27954. */
  27955. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27956. /**
  27957. * Disposes the physics imposter
  27958. */
  27959. dispose(): void;
  27960. /**
  27961. * Sets the delta position
  27962. * @param position The delta position amount
  27963. */
  27964. setDeltaPosition(position: Vector3): void;
  27965. /**
  27966. * Sets the delta rotation
  27967. * @param rotation The delta rotation amount
  27968. */
  27969. setDeltaRotation(rotation: Quaternion): void;
  27970. /**
  27971. * Gets the box size of the physics imposter and stores the result in the input parameter
  27972. * @param result Stores the box size
  27973. * @returns The physics imposter
  27974. */
  27975. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27976. /**
  27977. * Gets the radius of the physics imposter
  27978. * @returns Radius of the physics imposter
  27979. */
  27980. getRadius(): number;
  27981. /**
  27982. * Sync a bone with this impostor
  27983. * @param bone The bone to sync to the impostor.
  27984. * @param boneMesh The mesh that the bone is influencing.
  27985. * @param jointPivot The pivot of the joint / bone in local space.
  27986. * @param distToJoint Optional distance from the impostor to the joint.
  27987. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27988. */
  27989. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27990. /**
  27991. * Sync impostor to a bone
  27992. * @param bone The bone that the impostor will be synced to.
  27993. * @param boneMesh The mesh that the bone is influencing.
  27994. * @param jointPivot The pivot of the joint / bone in local space.
  27995. * @param distToJoint Optional distance from the impostor to the joint.
  27996. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27997. * @param boneAxis Optional vector3 axis the bone is aligned with
  27998. */
  27999. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28000. /**
  28001. * No-Imposter type
  28002. */
  28003. static NoImpostor: number;
  28004. /**
  28005. * Sphere-Imposter type
  28006. */
  28007. static SphereImpostor: number;
  28008. /**
  28009. * Box-Imposter type
  28010. */
  28011. static BoxImpostor: number;
  28012. /**
  28013. * Plane-Imposter type
  28014. */
  28015. static PlaneImpostor: number;
  28016. /**
  28017. * Mesh-imposter type
  28018. */
  28019. static MeshImpostor: number;
  28020. /**
  28021. * Capsule-Impostor type (Ammo.js plugin only)
  28022. */
  28023. static CapsuleImpostor: number;
  28024. /**
  28025. * Cylinder-Imposter type
  28026. */
  28027. static CylinderImpostor: number;
  28028. /**
  28029. * Particle-Imposter type
  28030. */
  28031. static ParticleImpostor: number;
  28032. /**
  28033. * Heightmap-Imposter type
  28034. */
  28035. static HeightmapImpostor: number;
  28036. /**
  28037. * ConvexHull-Impostor type (Ammo.js plugin only)
  28038. */
  28039. static ConvexHullImpostor: number;
  28040. /**
  28041. * Custom-Imposter type (Ammo.js plugin only)
  28042. */
  28043. static CustomImpostor: number;
  28044. /**
  28045. * Rope-Imposter type
  28046. */
  28047. static RopeImpostor: number;
  28048. /**
  28049. * Cloth-Imposter type
  28050. */
  28051. static ClothImpostor: number;
  28052. /**
  28053. * Softbody-Imposter type
  28054. */
  28055. static SoftbodyImpostor: number;
  28056. }
  28057. }
  28058. declare module BABYLON {
  28059. /**
  28060. * @hidden
  28061. **/
  28062. export class _CreationDataStorage {
  28063. closePath?: boolean;
  28064. closeArray?: boolean;
  28065. idx: number[];
  28066. dashSize: number;
  28067. gapSize: number;
  28068. path3D: Path3D;
  28069. pathArray: Vector3[][];
  28070. arc: number;
  28071. radius: number;
  28072. cap: number;
  28073. tessellation: number;
  28074. }
  28075. /**
  28076. * @hidden
  28077. **/
  28078. class _InstanceDataStorage {
  28079. visibleInstances: any;
  28080. batchCache: _InstancesBatch;
  28081. instancesBufferSize: number;
  28082. instancesBuffer: Nullable<Buffer>;
  28083. instancesData: Float32Array;
  28084. overridenInstanceCount: number;
  28085. isFrozen: boolean;
  28086. previousBatch: Nullable<_InstancesBatch>;
  28087. hardwareInstancedRendering: boolean;
  28088. sideOrientation: number;
  28089. manualUpdate: boolean;
  28090. }
  28091. /**
  28092. * @hidden
  28093. **/
  28094. export class _InstancesBatch {
  28095. mustReturn: boolean;
  28096. visibleInstances: Nullable<InstancedMesh[]>[];
  28097. renderSelf: boolean[];
  28098. hardwareInstancedRendering: boolean[];
  28099. }
  28100. /**
  28101. * @hidden
  28102. **/
  28103. class _ThinInstanceDataStorage {
  28104. instancesCount: number;
  28105. matrixBuffer: Nullable<Buffer>;
  28106. matrixBufferSize: number;
  28107. matrixData: Nullable<Float32Array>;
  28108. boundingVectors: Array<Vector3>;
  28109. worldMatrices: Nullable<Matrix[]>;
  28110. }
  28111. /**
  28112. * Class used to represent renderable models
  28113. */
  28114. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28115. /**
  28116. * Mesh side orientation : usually the external or front surface
  28117. */
  28118. static readonly FRONTSIDE: number;
  28119. /**
  28120. * Mesh side orientation : usually the internal or back surface
  28121. */
  28122. static readonly BACKSIDE: number;
  28123. /**
  28124. * Mesh side orientation : both internal and external or front and back surfaces
  28125. */
  28126. static readonly DOUBLESIDE: number;
  28127. /**
  28128. * Mesh side orientation : by default, `FRONTSIDE`
  28129. */
  28130. static readonly DEFAULTSIDE: number;
  28131. /**
  28132. * Mesh cap setting : no cap
  28133. */
  28134. static readonly NO_CAP: number;
  28135. /**
  28136. * Mesh cap setting : one cap at the beginning of the mesh
  28137. */
  28138. static readonly CAP_START: number;
  28139. /**
  28140. * Mesh cap setting : one cap at the end of the mesh
  28141. */
  28142. static readonly CAP_END: number;
  28143. /**
  28144. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28145. */
  28146. static readonly CAP_ALL: number;
  28147. /**
  28148. * Mesh pattern setting : no flip or rotate
  28149. */
  28150. static readonly NO_FLIP: number;
  28151. /**
  28152. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28153. */
  28154. static readonly FLIP_TILE: number;
  28155. /**
  28156. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28157. */
  28158. static readonly ROTATE_TILE: number;
  28159. /**
  28160. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28161. */
  28162. static readonly FLIP_ROW: number;
  28163. /**
  28164. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28165. */
  28166. static readonly ROTATE_ROW: number;
  28167. /**
  28168. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28169. */
  28170. static readonly FLIP_N_ROTATE_TILE: number;
  28171. /**
  28172. * Mesh pattern setting : rotate pattern and rotate
  28173. */
  28174. static readonly FLIP_N_ROTATE_ROW: number;
  28175. /**
  28176. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28177. */
  28178. static readonly CENTER: number;
  28179. /**
  28180. * Mesh tile positioning : part tiles on left
  28181. */
  28182. static readonly LEFT: number;
  28183. /**
  28184. * Mesh tile positioning : part tiles on right
  28185. */
  28186. static readonly RIGHT: number;
  28187. /**
  28188. * Mesh tile positioning : part tiles on top
  28189. */
  28190. static readonly TOP: number;
  28191. /**
  28192. * Mesh tile positioning : part tiles on bottom
  28193. */
  28194. static readonly BOTTOM: number;
  28195. /**
  28196. * Gets the default side orientation.
  28197. * @param orientation the orientation to value to attempt to get
  28198. * @returns the default orientation
  28199. * @hidden
  28200. */
  28201. static _GetDefaultSideOrientation(orientation?: number): number;
  28202. private _internalMeshDataInfo;
  28203. get computeBonesUsingShaders(): boolean;
  28204. set computeBonesUsingShaders(value: boolean);
  28205. /**
  28206. * An event triggered before rendering the mesh
  28207. */
  28208. get onBeforeRenderObservable(): Observable<Mesh>;
  28209. /**
  28210. * An event triggered before binding the mesh
  28211. */
  28212. get onBeforeBindObservable(): Observable<Mesh>;
  28213. /**
  28214. * An event triggered after rendering the mesh
  28215. */
  28216. get onAfterRenderObservable(): Observable<Mesh>;
  28217. /**
  28218. * An event triggered before drawing the mesh
  28219. */
  28220. get onBeforeDrawObservable(): Observable<Mesh>;
  28221. private _onBeforeDrawObserver;
  28222. /**
  28223. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28224. */
  28225. set onBeforeDraw(callback: () => void);
  28226. get hasInstances(): boolean;
  28227. get hasThinInstances(): boolean;
  28228. /**
  28229. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28230. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28231. */
  28232. delayLoadState: number;
  28233. /**
  28234. * Gets the list of instances created from this mesh
  28235. * it is not supposed to be modified manually.
  28236. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28237. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28238. */
  28239. instances: InstancedMesh[];
  28240. /**
  28241. * Gets the file containing delay loading data for this mesh
  28242. */
  28243. delayLoadingFile: string;
  28244. /** @hidden */
  28245. _binaryInfo: any;
  28246. /**
  28247. * User defined function used to change how LOD level selection is done
  28248. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28249. */
  28250. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28251. /**
  28252. * Gets or sets the morph target manager
  28253. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28254. */
  28255. get morphTargetManager(): Nullable<MorphTargetManager>;
  28256. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28257. /** @hidden */
  28258. _creationDataStorage: Nullable<_CreationDataStorage>;
  28259. /** @hidden */
  28260. _geometry: Nullable<Geometry>;
  28261. /** @hidden */
  28262. _delayInfo: Array<string>;
  28263. /** @hidden */
  28264. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28265. /** @hidden */
  28266. _instanceDataStorage: _InstanceDataStorage;
  28267. /** @hidden */
  28268. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28269. private _effectiveMaterial;
  28270. /** @hidden */
  28271. _shouldGenerateFlatShading: boolean;
  28272. /** @hidden */
  28273. _originalBuilderSideOrientation: number;
  28274. /**
  28275. * Use this property to change the original side orientation defined at construction time
  28276. */
  28277. overrideMaterialSideOrientation: Nullable<number>;
  28278. /**
  28279. * Gets the source mesh (the one used to clone this one from)
  28280. */
  28281. get source(): Nullable<Mesh>;
  28282. /**
  28283. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28284. */
  28285. get isUnIndexed(): boolean;
  28286. set isUnIndexed(value: boolean);
  28287. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28288. get worldMatrixInstancedBuffer(): Float32Array;
  28289. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28290. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28291. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28292. /**
  28293. * @constructor
  28294. * @param name The value used by scene.getMeshByName() to do a lookup.
  28295. * @param scene The scene to add this mesh to.
  28296. * @param parent The parent of this mesh, if it has one
  28297. * @param source An optional Mesh from which geometry is shared, cloned.
  28298. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28299. * When false, achieved by calling a clone(), also passing False.
  28300. * This will make creation of children, recursive.
  28301. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28302. */
  28303. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28304. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28305. doNotInstantiate: boolean;
  28306. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28307. /**
  28308. * Gets the class name
  28309. * @returns the string "Mesh".
  28310. */
  28311. getClassName(): string;
  28312. /** @hidden */
  28313. get _isMesh(): boolean;
  28314. /**
  28315. * Returns a description of this mesh
  28316. * @param fullDetails define if full details about this mesh must be used
  28317. * @returns a descriptive string representing this mesh
  28318. */
  28319. toString(fullDetails?: boolean): string;
  28320. /** @hidden */
  28321. _unBindEffect(): void;
  28322. /**
  28323. * Gets a boolean indicating if this mesh has LOD
  28324. */
  28325. get hasLODLevels(): boolean;
  28326. /**
  28327. * Gets the list of MeshLODLevel associated with the current mesh
  28328. * @returns an array of MeshLODLevel
  28329. */
  28330. getLODLevels(): MeshLODLevel[];
  28331. private _sortLODLevels;
  28332. /**
  28333. * Add a mesh as LOD level triggered at the given distance.
  28334. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28335. * @param distance The distance from the center of the object to show this level
  28336. * @param mesh The mesh to be added as LOD level (can be null)
  28337. * @return This mesh (for chaining)
  28338. */
  28339. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28340. /**
  28341. * Returns the LOD level mesh at the passed distance or null if not found.
  28342. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28343. * @param distance The distance from the center of the object to show this level
  28344. * @returns a Mesh or `null`
  28345. */
  28346. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28347. /**
  28348. * Remove a mesh from the LOD array
  28349. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28350. * @param mesh defines the mesh to be removed
  28351. * @return This mesh (for chaining)
  28352. */
  28353. removeLODLevel(mesh: Mesh): Mesh;
  28354. /**
  28355. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28356. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28357. * @param camera defines the camera to use to compute distance
  28358. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28359. * @return This mesh (for chaining)
  28360. */
  28361. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28362. /**
  28363. * Gets the mesh internal Geometry object
  28364. */
  28365. get geometry(): Nullable<Geometry>;
  28366. /**
  28367. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28368. * @returns the total number of vertices
  28369. */
  28370. getTotalVertices(): number;
  28371. /**
  28372. * Returns the content of an associated vertex buffer
  28373. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28374. * - VertexBuffer.PositionKind
  28375. * - VertexBuffer.UVKind
  28376. * - VertexBuffer.UV2Kind
  28377. * - VertexBuffer.UV3Kind
  28378. * - VertexBuffer.UV4Kind
  28379. * - VertexBuffer.UV5Kind
  28380. * - VertexBuffer.UV6Kind
  28381. * - VertexBuffer.ColorKind
  28382. * - VertexBuffer.MatricesIndicesKind
  28383. * - VertexBuffer.MatricesIndicesExtraKind
  28384. * - VertexBuffer.MatricesWeightsKind
  28385. * - VertexBuffer.MatricesWeightsExtraKind
  28386. * @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
  28387. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28388. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28389. */
  28390. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28391. /**
  28392. * Returns the mesh VertexBuffer object from the requested `kind`
  28393. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28394. * - VertexBuffer.PositionKind
  28395. * - VertexBuffer.NormalKind
  28396. * - VertexBuffer.UVKind
  28397. * - VertexBuffer.UV2Kind
  28398. * - VertexBuffer.UV3Kind
  28399. * - VertexBuffer.UV4Kind
  28400. * - VertexBuffer.UV5Kind
  28401. * - VertexBuffer.UV6Kind
  28402. * - VertexBuffer.ColorKind
  28403. * - VertexBuffer.MatricesIndicesKind
  28404. * - VertexBuffer.MatricesIndicesExtraKind
  28405. * - VertexBuffer.MatricesWeightsKind
  28406. * - VertexBuffer.MatricesWeightsExtraKind
  28407. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28408. */
  28409. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28410. /**
  28411. * Tests if a specific vertex buffer is associated with this mesh
  28412. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28413. * - VertexBuffer.PositionKind
  28414. * - VertexBuffer.NormalKind
  28415. * - VertexBuffer.UVKind
  28416. * - VertexBuffer.UV2Kind
  28417. * - VertexBuffer.UV3Kind
  28418. * - VertexBuffer.UV4Kind
  28419. * - VertexBuffer.UV5Kind
  28420. * - VertexBuffer.UV6Kind
  28421. * - VertexBuffer.ColorKind
  28422. * - VertexBuffer.MatricesIndicesKind
  28423. * - VertexBuffer.MatricesIndicesExtraKind
  28424. * - VertexBuffer.MatricesWeightsKind
  28425. * - VertexBuffer.MatricesWeightsExtraKind
  28426. * @returns a boolean
  28427. */
  28428. isVerticesDataPresent(kind: string): boolean;
  28429. /**
  28430. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28431. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28432. * - VertexBuffer.PositionKind
  28433. * - VertexBuffer.UVKind
  28434. * - VertexBuffer.UV2Kind
  28435. * - VertexBuffer.UV3Kind
  28436. * - VertexBuffer.UV4Kind
  28437. * - VertexBuffer.UV5Kind
  28438. * - VertexBuffer.UV6Kind
  28439. * - VertexBuffer.ColorKind
  28440. * - VertexBuffer.MatricesIndicesKind
  28441. * - VertexBuffer.MatricesIndicesExtraKind
  28442. * - VertexBuffer.MatricesWeightsKind
  28443. * - VertexBuffer.MatricesWeightsExtraKind
  28444. * @returns a boolean
  28445. */
  28446. isVertexBufferUpdatable(kind: string): boolean;
  28447. /**
  28448. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28449. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28450. * - VertexBuffer.PositionKind
  28451. * - VertexBuffer.NormalKind
  28452. * - VertexBuffer.UVKind
  28453. * - VertexBuffer.UV2Kind
  28454. * - VertexBuffer.UV3Kind
  28455. * - VertexBuffer.UV4Kind
  28456. * - VertexBuffer.UV5Kind
  28457. * - VertexBuffer.UV6Kind
  28458. * - VertexBuffer.ColorKind
  28459. * - VertexBuffer.MatricesIndicesKind
  28460. * - VertexBuffer.MatricesIndicesExtraKind
  28461. * - VertexBuffer.MatricesWeightsKind
  28462. * - VertexBuffer.MatricesWeightsExtraKind
  28463. * @returns an array of strings
  28464. */
  28465. getVerticesDataKinds(): string[];
  28466. /**
  28467. * Returns a positive integer : the total number of indices in this mesh geometry.
  28468. * @returns the numner of indices or zero if the mesh has no geometry.
  28469. */
  28470. getTotalIndices(): number;
  28471. /**
  28472. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28473. * @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.
  28474. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28475. * @returns the indices array or an empty array if the mesh has no geometry
  28476. */
  28477. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28478. get isBlocked(): boolean;
  28479. /**
  28480. * Determine if the current mesh is ready to be rendered
  28481. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28482. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28483. * @returns true if all associated assets are ready (material, textures, shaders)
  28484. */
  28485. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28486. /**
  28487. * 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.
  28488. */
  28489. get areNormalsFrozen(): boolean;
  28490. /**
  28491. * 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.
  28492. * @returns the current mesh
  28493. */
  28494. freezeNormals(): Mesh;
  28495. /**
  28496. * 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
  28497. * @returns the current mesh
  28498. */
  28499. unfreezeNormals(): Mesh;
  28500. /**
  28501. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28502. */
  28503. set overridenInstanceCount(count: number);
  28504. /** @hidden */
  28505. _preActivate(): Mesh;
  28506. /** @hidden */
  28507. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28508. /** @hidden */
  28509. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28510. protected _afterComputeWorldMatrix(): void;
  28511. /** @hidden */
  28512. _postActivate(): void;
  28513. /**
  28514. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28515. * This means the mesh underlying bounding box and sphere are recomputed.
  28516. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28517. * @returns the current mesh
  28518. */
  28519. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28520. /** @hidden */
  28521. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28522. /**
  28523. * This function will subdivide the mesh into multiple submeshes
  28524. * @param count defines the expected number of submeshes
  28525. */
  28526. subdivide(count: number): void;
  28527. /**
  28528. * Copy a FloatArray into a specific associated vertex buffer
  28529. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28530. * - VertexBuffer.PositionKind
  28531. * - VertexBuffer.UVKind
  28532. * - VertexBuffer.UV2Kind
  28533. * - VertexBuffer.UV3Kind
  28534. * - VertexBuffer.UV4Kind
  28535. * - VertexBuffer.UV5Kind
  28536. * - VertexBuffer.UV6Kind
  28537. * - VertexBuffer.ColorKind
  28538. * - VertexBuffer.MatricesIndicesKind
  28539. * - VertexBuffer.MatricesIndicesExtraKind
  28540. * - VertexBuffer.MatricesWeightsKind
  28541. * - VertexBuffer.MatricesWeightsExtraKind
  28542. * @param data defines the data source
  28543. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28544. * @param stride defines the data stride size (can be null)
  28545. * @returns the current mesh
  28546. */
  28547. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28548. /**
  28549. * Delete a vertex buffer associated with this mesh
  28550. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28551. * - VertexBuffer.PositionKind
  28552. * - VertexBuffer.UVKind
  28553. * - VertexBuffer.UV2Kind
  28554. * - VertexBuffer.UV3Kind
  28555. * - VertexBuffer.UV4Kind
  28556. * - VertexBuffer.UV5Kind
  28557. * - VertexBuffer.UV6Kind
  28558. * - VertexBuffer.ColorKind
  28559. * - VertexBuffer.MatricesIndicesKind
  28560. * - VertexBuffer.MatricesIndicesExtraKind
  28561. * - VertexBuffer.MatricesWeightsKind
  28562. * - VertexBuffer.MatricesWeightsExtraKind
  28563. */
  28564. removeVerticesData(kind: string): void;
  28565. /**
  28566. * Flags an associated vertex buffer as updatable
  28567. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28568. * - VertexBuffer.PositionKind
  28569. * - VertexBuffer.UVKind
  28570. * - VertexBuffer.UV2Kind
  28571. * - VertexBuffer.UV3Kind
  28572. * - VertexBuffer.UV4Kind
  28573. * - VertexBuffer.UV5Kind
  28574. * - VertexBuffer.UV6Kind
  28575. * - VertexBuffer.ColorKind
  28576. * - VertexBuffer.MatricesIndicesKind
  28577. * - VertexBuffer.MatricesIndicesExtraKind
  28578. * - VertexBuffer.MatricesWeightsKind
  28579. * - VertexBuffer.MatricesWeightsExtraKind
  28580. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28581. */
  28582. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28583. /**
  28584. * Sets the mesh global Vertex Buffer
  28585. * @param buffer defines the buffer to use
  28586. * @returns the current mesh
  28587. */
  28588. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28589. /**
  28590. * Update a specific associated vertex buffer
  28591. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28592. * - VertexBuffer.PositionKind
  28593. * - VertexBuffer.UVKind
  28594. * - VertexBuffer.UV2Kind
  28595. * - VertexBuffer.UV3Kind
  28596. * - VertexBuffer.UV4Kind
  28597. * - VertexBuffer.UV5Kind
  28598. * - VertexBuffer.UV6Kind
  28599. * - VertexBuffer.ColorKind
  28600. * - VertexBuffer.MatricesIndicesKind
  28601. * - VertexBuffer.MatricesIndicesExtraKind
  28602. * - VertexBuffer.MatricesWeightsKind
  28603. * - VertexBuffer.MatricesWeightsExtraKind
  28604. * @param data defines the data source
  28605. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28606. * @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)
  28607. * @returns the current mesh
  28608. */
  28609. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28610. /**
  28611. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28612. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28613. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28614. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28615. * @returns the current mesh
  28616. */
  28617. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28618. /**
  28619. * Creates a un-shared specific occurence of the geometry for the mesh.
  28620. * @returns the current mesh
  28621. */
  28622. makeGeometryUnique(): Mesh;
  28623. /**
  28624. * Set the index buffer of this mesh
  28625. * @param indices defines the source data
  28626. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28627. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28628. * @returns the current mesh
  28629. */
  28630. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28631. /**
  28632. * Update the current index buffer
  28633. * @param indices defines the source data
  28634. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28635. * @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)
  28636. * @returns the current mesh
  28637. */
  28638. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28639. /**
  28640. * Invert the geometry to move from a right handed system to a left handed one.
  28641. * @returns the current mesh
  28642. */
  28643. toLeftHanded(): Mesh;
  28644. /** @hidden */
  28645. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28646. /** @hidden */
  28647. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28648. /**
  28649. * Registers for this mesh a javascript function called just before the rendering process
  28650. * @param func defines the function to call before rendering this mesh
  28651. * @returns the current mesh
  28652. */
  28653. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28654. /**
  28655. * Disposes a previously registered javascript function called before the rendering
  28656. * @param func defines the function to remove
  28657. * @returns the current mesh
  28658. */
  28659. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28660. /**
  28661. * Registers for this mesh a javascript function called just after the rendering is complete
  28662. * @param func defines the function to call after rendering this mesh
  28663. * @returns the current mesh
  28664. */
  28665. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28666. /**
  28667. * Disposes a previously registered javascript function called after the rendering.
  28668. * @param func defines the function to remove
  28669. * @returns the current mesh
  28670. */
  28671. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28672. /** @hidden */
  28673. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28674. /** @hidden */
  28675. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28676. /** @hidden */
  28677. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28678. /** @hidden */
  28679. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28680. /** @hidden */
  28681. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28682. /** @hidden */
  28683. _rebuild(): void;
  28684. /** @hidden */
  28685. _freeze(): void;
  28686. /** @hidden */
  28687. _unFreeze(): void;
  28688. /**
  28689. * 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
  28690. * @param subMesh defines the subMesh to render
  28691. * @param enableAlphaMode defines if alpha mode can be changed
  28692. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28693. * @returns the current mesh
  28694. */
  28695. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28696. private _onBeforeDraw;
  28697. /**
  28698. * Renormalize the mesh and patch it up if there are no weights
  28699. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28700. * However in the case of zero weights then we set just a single influence to 1.
  28701. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28702. */
  28703. cleanMatrixWeights(): void;
  28704. private normalizeSkinFourWeights;
  28705. private normalizeSkinWeightsAndExtra;
  28706. /**
  28707. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28708. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28709. * the user know there was an issue with importing the mesh
  28710. * @returns a validation object with skinned, valid and report string
  28711. */
  28712. validateSkinning(): {
  28713. skinned: boolean;
  28714. valid: boolean;
  28715. report: string;
  28716. };
  28717. /** @hidden */
  28718. _checkDelayState(): Mesh;
  28719. private _queueLoad;
  28720. /**
  28721. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28722. * A mesh is in the frustum if its bounding box intersects the frustum
  28723. * @param frustumPlanes defines the frustum to test
  28724. * @returns true if the mesh is in the frustum planes
  28725. */
  28726. isInFrustum(frustumPlanes: Plane[]): boolean;
  28727. /**
  28728. * Sets the mesh material by the material or multiMaterial `id` property
  28729. * @param id is a string identifying the material or the multiMaterial
  28730. * @returns the current mesh
  28731. */
  28732. setMaterialByID(id: string): Mesh;
  28733. /**
  28734. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28735. * @returns an array of IAnimatable
  28736. */
  28737. getAnimatables(): IAnimatable[];
  28738. /**
  28739. * Modifies the mesh geometry according to the passed transformation matrix.
  28740. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28741. * The mesh normals are modified using the same transformation.
  28742. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28743. * @param transform defines the transform matrix to use
  28744. * @see https://doc.babylonjs.com/resources/baking_transformations
  28745. * @returns the current mesh
  28746. */
  28747. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28748. /**
  28749. * Modifies the mesh geometry according to its own current World Matrix.
  28750. * The mesh World Matrix is then reset.
  28751. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28752. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28753. * @see https://doc.babylonjs.com/resources/baking_transformations
  28754. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28755. * @returns the current mesh
  28756. */
  28757. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28758. /** @hidden */
  28759. get _positions(): Nullable<Vector3[]>;
  28760. /** @hidden */
  28761. _resetPointsArrayCache(): Mesh;
  28762. /** @hidden */
  28763. _generatePointsArray(): boolean;
  28764. /**
  28765. * Returns a new Mesh object generated from the current mesh properties.
  28766. * This method must not get confused with createInstance()
  28767. * @param name is a string, the name given to the new mesh
  28768. * @param newParent can be any Node object (default `null`)
  28769. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28770. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28771. * @returns a new mesh
  28772. */
  28773. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28774. /**
  28775. * Releases resources associated with this mesh.
  28776. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28777. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28778. */
  28779. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28780. /** @hidden */
  28781. _disposeInstanceSpecificData(): void;
  28782. /** @hidden */
  28783. _disposeThinInstanceSpecificData(): void;
  28784. /**
  28785. * Modifies the mesh geometry according to a displacement map.
  28786. * 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.
  28787. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28788. * @param url is a string, the URL from the image file is to be downloaded.
  28789. * @param minHeight is the lower limit of the displacement.
  28790. * @param maxHeight is the upper limit of the displacement.
  28791. * @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.
  28792. * @param uvOffset is an optional vector2 used to offset UV.
  28793. * @param uvScale is an optional vector2 used to scale UV.
  28794. * @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.
  28795. * @returns the Mesh.
  28796. */
  28797. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28798. /**
  28799. * Modifies the mesh geometry according to a displacementMap buffer.
  28800. * 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.
  28801. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28802. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28803. * @param heightMapWidth is the width of the buffer image.
  28804. * @param heightMapHeight is the height of the buffer image.
  28805. * @param minHeight is the lower limit of the displacement.
  28806. * @param maxHeight is the upper limit of the displacement.
  28807. * @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.
  28808. * @param uvOffset is an optional vector2 used to offset UV.
  28809. * @param uvScale is an optional vector2 used to scale UV.
  28810. * @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.
  28811. * @returns the Mesh.
  28812. */
  28813. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28814. /**
  28815. * Modify the mesh to get a flat shading rendering.
  28816. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28817. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28818. * @returns current mesh
  28819. */
  28820. convertToFlatShadedMesh(): Mesh;
  28821. /**
  28822. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28823. * In other words, more vertices, no more indices and a single bigger VBO.
  28824. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28825. * @returns current mesh
  28826. */
  28827. convertToUnIndexedMesh(): Mesh;
  28828. /**
  28829. * Inverses facet orientations.
  28830. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28831. * @param flipNormals will also inverts the normals
  28832. * @returns current mesh
  28833. */
  28834. flipFaces(flipNormals?: boolean): Mesh;
  28835. /**
  28836. * Increase the number of facets and hence vertices in a mesh
  28837. * Vertex normals are interpolated from existing vertex normals
  28838. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28839. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28840. */
  28841. increaseVertices(numberPerEdge: number): void;
  28842. /**
  28843. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28844. * This will undo any application of covertToFlatShadedMesh
  28845. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28846. */
  28847. forceSharedVertices(): void;
  28848. /** @hidden */
  28849. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28850. /** @hidden */
  28851. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28852. /**
  28853. * Creates a new InstancedMesh object from the mesh model.
  28854. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28855. * @param name defines the name of the new instance
  28856. * @returns a new InstancedMesh
  28857. */
  28858. createInstance(name: string): InstancedMesh;
  28859. /**
  28860. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28861. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28862. * @returns the current mesh
  28863. */
  28864. synchronizeInstances(): Mesh;
  28865. /**
  28866. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28867. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28868. * This should be used together with the simplification to avoid disappearing triangles.
  28869. * @param successCallback an optional success callback to be called after the optimization finished.
  28870. * @returns the current mesh
  28871. */
  28872. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28873. /**
  28874. * Serialize current mesh
  28875. * @param serializationObject defines the object which will receive the serialization data
  28876. */
  28877. serialize(serializationObject: any): void;
  28878. /** @hidden */
  28879. _syncGeometryWithMorphTargetManager(): void;
  28880. /** @hidden */
  28881. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28882. /**
  28883. * Returns a new Mesh object parsed from the source provided.
  28884. * @param parsedMesh is the source
  28885. * @param scene defines the hosting scene
  28886. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28887. * @returns a new Mesh
  28888. */
  28889. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28890. /**
  28891. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28892. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28893. * @param name defines the name of the mesh to create
  28894. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28895. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28896. * @param closePath creates a seam between the first and the last points of each path of the path array
  28897. * @param offset is taken in account only if the `pathArray` is containing a single path
  28898. * @param scene defines the hosting scene
  28899. * @param updatable defines if the mesh must be flagged as updatable
  28900. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28901. * @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)
  28902. * @returns a new Mesh
  28903. */
  28904. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28905. /**
  28906. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28907. * @param name defines the name of the mesh to create
  28908. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28909. * @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
  28910. * @param scene defines the hosting scene
  28911. * @param updatable defines if the mesh must be flagged as updatable
  28912. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28913. * @returns a new Mesh
  28914. */
  28915. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28916. /**
  28917. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28918. * @param name defines the name of the mesh to create
  28919. * @param size sets the size (float) of each box side (default 1)
  28920. * @param scene defines the hosting scene
  28921. * @param updatable defines if the mesh must be flagged as updatable
  28922. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28923. * @returns a new Mesh
  28924. */
  28925. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28926. /**
  28927. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28928. * @param name defines the name of the mesh to create
  28929. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28930. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28931. * @param scene defines the hosting scene
  28932. * @param updatable defines if the mesh must be flagged as updatable
  28933. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28934. * @returns a new Mesh
  28935. */
  28936. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28937. /**
  28938. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28939. * @param name defines the name of the mesh to create
  28940. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28941. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28942. * @param scene defines the hosting scene
  28943. * @returns a new Mesh
  28944. */
  28945. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28946. /**
  28947. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28948. * @param name defines the name of the mesh to create
  28949. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28950. * @param diameterTop set the top cap diameter (floats, default 1)
  28951. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28952. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28953. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28954. * @param scene defines the hosting scene
  28955. * @param updatable defines if the mesh must be flagged as updatable
  28956. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28957. * @returns a new Mesh
  28958. */
  28959. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28960. /**
  28961. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28962. * @param name defines the name of the mesh to create
  28963. * @param diameter sets the diameter size (float) of the torus (default 1)
  28964. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28965. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28966. * @param scene defines the hosting scene
  28967. * @param updatable defines if the mesh must be flagged as updatable
  28968. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28969. * @returns a new Mesh
  28970. */
  28971. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28972. /**
  28973. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28974. * @param name defines the name of the mesh to create
  28975. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28976. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28977. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28978. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28979. * @param p the number of windings on X axis (positive integers, default 2)
  28980. * @param q the number of windings on Y axis (positive integers, default 3)
  28981. * @param scene defines the hosting scene
  28982. * @param updatable defines if the mesh must be flagged as updatable
  28983. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28984. * @returns a new Mesh
  28985. */
  28986. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28987. /**
  28988. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28989. * @param name defines the name of the mesh to create
  28990. * @param points is an array successive Vector3
  28991. * @param scene defines the hosting scene
  28992. * @param updatable defines if the mesh must be flagged as updatable
  28993. * @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).
  28994. * @returns a new Mesh
  28995. */
  28996. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28997. /**
  28998. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28999. * @param name defines the name of the mesh to create
  29000. * @param points is an array successive Vector3
  29001. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29002. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29003. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29004. * @param scene defines the hosting scene
  29005. * @param updatable defines if the mesh must be flagged as updatable
  29006. * @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)
  29007. * @returns a new Mesh
  29008. */
  29009. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29010. /**
  29011. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29012. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29013. * 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.
  29014. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29015. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29016. * Remember you can only change the shape positions, not their number when updating a polygon.
  29017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29018. * @param name defines the name of the mesh to create
  29019. * @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
  29020. * @param scene defines the hosting scene
  29021. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29022. * @param updatable defines if the mesh must be flagged as updatable
  29023. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29024. * @param earcutInjection can be used to inject your own earcut reference
  29025. * @returns a new Mesh
  29026. */
  29027. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29028. /**
  29029. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29030. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29031. * @param name defines the name of the mesh to create
  29032. * @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
  29033. * @param depth defines the height of extrusion
  29034. * @param scene defines the hosting scene
  29035. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29036. * @param updatable defines if the mesh must be flagged as updatable
  29037. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29038. * @param earcutInjection can be used to inject your own earcut reference
  29039. * @returns a new Mesh
  29040. */
  29041. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29042. /**
  29043. * Creates an extruded shape mesh.
  29044. * 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
  29045. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29047. * @param name defines the name of the mesh to create
  29048. * @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
  29049. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29050. * @param scale is the value to scale the shape
  29051. * @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
  29052. * @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
  29053. * @param scene defines the hosting scene
  29054. * @param updatable defines if the mesh must be flagged as updatable
  29055. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29056. * @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)
  29057. * @returns a new Mesh
  29058. */
  29059. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29060. /**
  29061. * Creates an custom extruded shape mesh.
  29062. * The custom extrusion is a parametric shape.
  29063. * It has no predefined shape. Its final shape will depend on the input parameters.
  29064. * Please consider using the same method from the MeshBuilder class instead
  29065. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29066. * @param name defines the name of the mesh to create
  29067. * @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
  29068. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29069. * @param scaleFunction is a custom Javascript function called on each path point
  29070. * @param rotationFunction is a custom Javascript function called on each path point
  29071. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29072. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29073. * @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
  29074. * @param scene defines the hosting scene
  29075. * @param updatable defines if the mesh must be flagged as updatable
  29076. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29077. * @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)
  29078. * @returns a new Mesh
  29079. */
  29080. 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;
  29081. /**
  29082. * Creates lathe mesh.
  29083. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29084. * Please consider using the same method from the MeshBuilder class instead
  29085. * @param name defines the name of the mesh to create
  29086. * @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
  29087. * @param radius is the radius value of the lathe
  29088. * @param tessellation is the side number of the lathe.
  29089. * @param scene defines the hosting scene
  29090. * @param updatable defines if the mesh must be flagged as updatable
  29091. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29092. * @returns a new Mesh
  29093. */
  29094. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29095. /**
  29096. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29097. * @param name defines the name of the mesh to create
  29098. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29099. * @param scene defines the hosting scene
  29100. * @param updatable defines if the mesh must be flagged as updatable
  29101. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29102. * @returns a new Mesh
  29103. */
  29104. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29105. /**
  29106. * Creates a ground mesh.
  29107. * Please consider using the same method from the MeshBuilder class instead
  29108. * @param name defines the name of the mesh to create
  29109. * @param width set the width of the ground
  29110. * @param height set the height of the ground
  29111. * @param subdivisions sets the number of subdivisions per side
  29112. * @param scene defines the hosting scene
  29113. * @param updatable defines if the mesh must be flagged as updatable
  29114. * @returns a new Mesh
  29115. */
  29116. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29117. /**
  29118. * Creates a tiled ground mesh.
  29119. * Please consider using the same method from the MeshBuilder class instead
  29120. * @param name defines the name of the mesh to create
  29121. * @param xmin set the ground minimum X coordinate
  29122. * @param zmin set the ground minimum Y coordinate
  29123. * @param xmax set the ground maximum X coordinate
  29124. * @param zmax set the ground maximum Z coordinate
  29125. * @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
  29126. * @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
  29127. * @param scene defines the hosting scene
  29128. * @param updatable defines if the mesh must be flagged as updatable
  29129. * @returns a new Mesh
  29130. */
  29131. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29132. w: number;
  29133. h: number;
  29134. }, precision: {
  29135. w: number;
  29136. h: number;
  29137. }, scene: Scene, updatable?: boolean): Mesh;
  29138. /**
  29139. * Creates a ground mesh from a height map.
  29140. * Please consider using the same method from the MeshBuilder class instead
  29141. * @see https://doc.babylonjs.com/babylon101/height_map
  29142. * @param name defines the name of the mesh to create
  29143. * @param url sets the URL of the height map image resource
  29144. * @param width set the ground width size
  29145. * @param height set the ground height size
  29146. * @param subdivisions sets the number of subdivision per side
  29147. * @param minHeight is the minimum altitude on the ground
  29148. * @param maxHeight is the maximum altitude on the ground
  29149. * @param scene defines the hosting scene
  29150. * @param updatable defines if the mesh must be flagged as updatable
  29151. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29152. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29153. * @returns a new Mesh
  29154. */
  29155. 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;
  29156. /**
  29157. * Creates a tube mesh.
  29158. * The tube is a parametric shape.
  29159. * It has no predefined shape. Its final shape will depend on the input parameters.
  29160. * Please consider using the same method from the MeshBuilder class instead
  29161. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29162. * @param name defines the name of the mesh to create
  29163. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29164. * @param radius sets the tube radius size
  29165. * @param tessellation is the number of sides on the tubular surface
  29166. * @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
  29167. * @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
  29168. * @param scene defines the hosting scene
  29169. * @param updatable defines if the mesh must be flagged as updatable
  29170. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29171. * @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)
  29172. * @returns a new Mesh
  29173. */
  29174. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29175. (i: number, distance: number): number;
  29176. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29177. /**
  29178. * Creates a polyhedron mesh.
  29179. * Please consider using the same method from the MeshBuilder class instead.
  29180. * * 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
  29181. * * The parameter `size` (positive float, default 1) sets the polygon size
  29182. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29183. * * 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`
  29184. * * 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
  29185. * * 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)`)
  29186. * * 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
  29187. * * 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
  29188. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29189. * * 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
  29190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29191. * @param name defines the name of the mesh to create
  29192. * @param options defines the options used to create the mesh
  29193. * @param scene defines the hosting scene
  29194. * @returns a new Mesh
  29195. */
  29196. static CreatePolyhedron(name: string, options: {
  29197. type?: number;
  29198. size?: number;
  29199. sizeX?: number;
  29200. sizeY?: number;
  29201. sizeZ?: number;
  29202. custom?: any;
  29203. faceUV?: Vector4[];
  29204. faceColors?: Color4[];
  29205. updatable?: boolean;
  29206. sideOrientation?: number;
  29207. }, scene: Scene): Mesh;
  29208. /**
  29209. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29210. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29211. * * 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`)
  29212. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29213. * * 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
  29214. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29215. * * 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
  29216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29217. * @param name defines the name of the mesh
  29218. * @param options defines the options used to create the mesh
  29219. * @param scene defines the hosting scene
  29220. * @returns a new Mesh
  29221. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29222. */
  29223. static CreateIcoSphere(name: string, options: {
  29224. radius?: number;
  29225. flat?: boolean;
  29226. subdivisions?: number;
  29227. sideOrientation?: number;
  29228. updatable?: boolean;
  29229. }, scene: Scene): Mesh;
  29230. /**
  29231. * Creates a decal mesh.
  29232. * Please consider using the same method from the MeshBuilder class instead.
  29233. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29234. * @param name defines the name of the mesh
  29235. * @param sourceMesh defines the mesh receiving the decal
  29236. * @param position sets the position of the decal in world coordinates
  29237. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29238. * @param size sets the decal scaling
  29239. * @param angle sets the angle to rotate the decal
  29240. * @returns a new Mesh
  29241. */
  29242. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29243. /**
  29244. * Prepare internal position array for software CPU skinning
  29245. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29246. */
  29247. setPositionsForCPUSkinning(): Float32Array;
  29248. /**
  29249. * Prepare internal normal array for software CPU skinning
  29250. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29251. */
  29252. setNormalsForCPUSkinning(): Float32Array;
  29253. /**
  29254. * Updates the vertex buffer by applying transformation from the bones
  29255. * @param skeleton defines the skeleton to apply to current mesh
  29256. * @returns the current mesh
  29257. */
  29258. applySkeleton(skeleton: Skeleton): Mesh;
  29259. /**
  29260. * 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
  29261. * @param meshes defines the list of meshes to scan
  29262. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29263. */
  29264. static MinMax(meshes: AbstractMesh[]): {
  29265. min: Vector3;
  29266. max: Vector3;
  29267. };
  29268. /**
  29269. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29270. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29271. * @returns a vector3
  29272. */
  29273. static Center(meshesOrMinMaxVector: {
  29274. min: Vector3;
  29275. max: Vector3;
  29276. } | AbstractMesh[]): Vector3;
  29277. /**
  29278. * Merge the array of meshes into a single mesh for performance reasons.
  29279. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29280. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29281. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29282. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29283. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29284. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29285. * @returns a new mesh
  29286. */
  29287. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29288. /** @hidden */
  29289. addInstance(instance: InstancedMesh): void;
  29290. /** @hidden */
  29291. removeInstance(instance: InstancedMesh): void;
  29292. }
  29293. }
  29294. declare module BABYLON {
  29295. /**
  29296. * This is the base class of all the camera used in the application.
  29297. * @see https://doc.babylonjs.com/features/cameras
  29298. */
  29299. export class Camera extends Node {
  29300. /** @hidden */
  29301. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29302. /**
  29303. * This is the default projection mode used by the cameras.
  29304. * It helps recreating a feeling of perspective and better appreciate depth.
  29305. * This is the best way to simulate real life cameras.
  29306. */
  29307. static readonly PERSPECTIVE_CAMERA: number;
  29308. /**
  29309. * This helps creating camera with an orthographic mode.
  29310. * 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.
  29311. */
  29312. static readonly ORTHOGRAPHIC_CAMERA: number;
  29313. /**
  29314. * This is the default FOV mode for perspective cameras.
  29315. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29316. */
  29317. static readonly FOVMODE_VERTICAL_FIXED: number;
  29318. /**
  29319. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29320. */
  29321. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29322. /**
  29323. * This specifies ther is no need for a camera rig.
  29324. * Basically only one eye is rendered corresponding to the camera.
  29325. */
  29326. static readonly RIG_MODE_NONE: number;
  29327. /**
  29328. * Simulates a camera Rig with one blue eye and one red eye.
  29329. * This can be use with 3d blue and red glasses.
  29330. */
  29331. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29332. /**
  29333. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29334. */
  29335. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29336. /**
  29337. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29338. */
  29339. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29340. /**
  29341. * Defines that both eyes of the camera will be rendered over under each other.
  29342. */
  29343. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29344. /**
  29345. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29346. */
  29347. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29348. /**
  29349. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29350. */
  29351. static readonly RIG_MODE_VR: number;
  29352. /**
  29353. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29354. */
  29355. static readonly RIG_MODE_WEBVR: number;
  29356. /**
  29357. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29358. */
  29359. static readonly RIG_MODE_CUSTOM: number;
  29360. /**
  29361. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29362. */
  29363. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29364. /**
  29365. * Define the input manager associated with the camera.
  29366. */
  29367. inputs: CameraInputsManager<Camera>;
  29368. /** @hidden */
  29369. _position: Vector3;
  29370. /**
  29371. * Define the current local position of the camera in the scene
  29372. */
  29373. get position(): Vector3;
  29374. set position(newPosition: Vector3);
  29375. protected _upVector: Vector3;
  29376. /**
  29377. * The vector the camera should consider as up.
  29378. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29379. */
  29380. set upVector(vec: Vector3);
  29381. get upVector(): Vector3;
  29382. /**
  29383. * Define the current limit on the left side for an orthographic camera
  29384. * In scene unit
  29385. */
  29386. orthoLeft: Nullable<number>;
  29387. /**
  29388. * Define the current limit on the right side for an orthographic camera
  29389. * In scene unit
  29390. */
  29391. orthoRight: Nullable<number>;
  29392. /**
  29393. * Define the current limit on the bottom side for an orthographic camera
  29394. * In scene unit
  29395. */
  29396. orthoBottom: Nullable<number>;
  29397. /**
  29398. * Define the current limit on the top side for an orthographic camera
  29399. * In scene unit
  29400. */
  29401. orthoTop: Nullable<number>;
  29402. /**
  29403. * Field Of View is set in Radians. (default is 0.8)
  29404. */
  29405. fov: number;
  29406. /**
  29407. * Define the minimum distance the camera can see from.
  29408. * This is important to note that the depth buffer are not infinite and the closer it starts
  29409. * the more your scene might encounter depth fighting issue.
  29410. */
  29411. minZ: number;
  29412. /**
  29413. * Define the maximum distance the camera can see to.
  29414. * This is important to note that the depth buffer are not infinite and the further it end
  29415. * the more your scene might encounter depth fighting issue.
  29416. */
  29417. maxZ: number;
  29418. /**
  29419. * Define the default inertia of the camera.
  29420. * This helps giving a smooth feeling to the camera movement.
  29421. */
  29422. inertia: number;
  29423. /**
  29424. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29425. */
  29426. mode: number;
  29427. /**
  29428. * Define whether the camera is intermediate.
  29429. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29430. */
  29431. isIntermediate: boolean;
  29432. /**
  29433. * Define the viewport of the camera.
  29434. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29435. */
  29436. viewport: Viewport;
  29437. /**
  29438. * Restricts the camera to viewing objects with the same layerMask.
  29439. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29440. */
  29441. layerMask: number;
  29442. /**
  29443. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29444. */
  29445. fovMode: number;
  29446. /**
  29447. * Rig mode of the camera.
  29448. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29449. * This is normally controlled byt the camera themselves as internal use.
  29450. */
  29451. cameraRigMode: number;
  29452. /**
  29453. * Defines the distance between both "eyes" in case of a RIG
  29454. */
  29455. interaxialDistance: number;
  29456. /**
  29457. * Defines if stereoscopic rendering is done side by side or over under.
  29458. */
  29459. isStereoscopicSideBySide: boolean;
  29460. /**
  29461. * 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
  29462. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29463. * else in the scene. (Eg. security camera)
  29464. *
  29465. * 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)
  29466. */
  29467. customRenderTargets: RenderTargetTexture[];
  29468. /**
  29469. * When set, the camera will render to this render target instead of the default canvas
  29470. *
  29471. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29472. */
  29473. outputRenderTarget: Nullable<RenderTargetTexture>;
  29474. /**
  29475. * Observable triggered when the camera view matrix has changed.
  29476. */
  29477. onViewMatrixChangedObservable: Observable<Camera>;
  29478. /**
  29479. * Observable triggered when the camera Projection matrix has changed.
  29480. */
  29481. onProjectionMatrixChangedObservable: Observable<Camera>;
  29482. /**
  29483. * Observable triggered when the inputs have been processed.
  29484. */
  29485. onAfterCheckInputsObservable: Observable<Camera>;
  29486. /**
  29487. * Observable triggered when reset has been called and applied to the camera.
  29488. */
  29489. onRestoreStateObservable: Observable<Camera>;
  29490. /**
  29491. * Is this camera a part of a rig system?
  29492. */
  29493. isRigCamera: boolean;
  29494. /**
  29495. * If isRigCamera set to true this will be set with the parent camera.
  29496. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29497. */
  29498. rigParent?: Camera;
  29499. /** @hidden */
  29500. _cameraRigParams: any;
  29501. /** @hidden */
  29502. _rigCameras: Camera[];
  29503. /** @hidden */
  29504. _rigPostProcess: Nullable<PostProcess>;
  29505. protected _webvrViewMatrix: Matrix;
  29506. /** @hidden */
  29507. _skipRendering: boolean;
  29508. /** @hidden */
  29509. _projectionMatrix: Matrix;
  29510. /** @hidden */
  29511. _postProcesses: Nullable<PostProcess>[];
  29512. /** @hidden */
  29513. _activeMeshes: SmartArray<AbstractMesh>;
  29514. protected _globalPosition: Vector3;
  29515. /** @hidden */
  29516. _computedViewMatrix: Matrix;
  29517. private _doNotComputeProjectionMatrix;
  29518. private _transformMatrix;
  29519. private _frustumPlanes;
  29520. private _refreshFrustumPlanes;
  29521. private _storedFov;
  29522. private _stateStored;
  29523. /**
  29524. * Instantiates a new camera object.
  29525. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29526. * @see https://doc.babylonjs.com/features/cameras
  29527. * @param name Defines the name of the camera in the scene
  29528. * @param position Defines the position of the camera
  29529. * @param scene Defines the scene the camera belongs too
  29530. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29531. */
  29532. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29533. /**
  29534. * Store current camera state (fov, position, etc..)
  29535. * @returns the camera
  29536. */
  29537. storeState(): Camera;
  29538. /**
  29539. * Restores the camera state values if it has been stored. You must call storeState() first
  29540. */
  29541. protected _restoreStateValues(): boolean;
  29542. /**
  29543. * Restored camera state. You must call storeState() first.
  29544. * @returns true if restored and false otherwise
  29545. */
  29546. restoreState(): boolean;
  29547. /**
  29548. * Gets the class name of the camera.
  29549. * @returns the class name
  29550. */
  29551. getClassName(): string;
  29552. /** @hidden */
  29553. readonly _isCamera: boolean;
  29554. /**
  29555. * Gets a string representation of the camera useful for debug purpose.
  29556. * @param fullDetails Defines that a more verboe level of logging is required
  29557. * @returns the string representation
  29558. */
  29559. toString(fullDetails?: boolean): string;
  29560. /**
  29561. * Gets the current world space position of the camera.
  29562. */
  29563. get globalPosition(): Vector3;
  29564. /**
  29565. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29566. * @returns the active meshe list
  29567. */
  29568. getActiveMeshes(): SmartArray<AbstractMesh>;
  29569. /**
  29570. * Check whether a mesh is part of the current active mesh list of the camera
  29571. * @param mesh Defines the mesh to check
  29572. * @returns true if active, false otherwise
  29573. */
  29574. isActiveMesh(mesh: Mesh): boolean;
  29575. /**
  29576. * Is this camera ready to be used/rendered
  29577. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29578. * @return true if the camera is ready
  29579. */
  29580. isReady(completeCheck?: boolean): boolean;
  29581. /** @hidden */
  29582. _initCache(): void;
  29583. /** @hidden */
  29584. _updateCache(ignoreParentClass?: boolean): void;
  29585. /** @hidden */
  29586. _isSynchronized(): boolean;
  29587. /** @hidden */
  29588. _isSynchronizedViewMatrix(): boolean;
  29589. /** @hidden */
  29590. _isSynchronizedProjectionMatrix(): boolean;
  29591. /**
  29592. * Attach the input controls to a specific dom element to get the input from.
  29593. * @param element Defines the element the controls should be listened from
  29594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29595. */
  29596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29597. /**
  29598. * Detach the current controls from the specified dom element.
  29599. * @param element Defines the element to stop listening the inputs from
  29600. */
  29601. detachControl(element: HTMLElement): void;
  29602. /**
  29603. * Update the camera state according to the different inputs gathered during the frame.
  29604. */
  29605. update(): void;
  29606. /** @hidden */
  29607. _checkInputs(): void;
  29608. /** @hidden */
  29609. get rigCameras(): Camera[];
  29610. /**
  29611. * Gets the post process used by the rig cameras
  29612. */
  29613. get rigPostProcess(): Nullable<PostProcess>;
  29614. /**
  29615. * Internal, gets the first post proces.
  29616. * @returns the first post process to be run on this camera.
  29617. */
  29618. _getFirstPostProcess(): Nullable<PostProcess>;
  29619. private _cascadePostProcessesToRigCams;
  29620. /**
  29621. * Attach a post process to the camera.
  29622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29623. * @param postProcess The post process to attach to the camera
  29624. * @param insertAt The position of the post process in case several of them are in use in the scene
  29625. * @returns the position the post process has been inserted at
  29626. */
  29627. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29628. /**
  29629. * Detach a post process to the camera.
  29630. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29631. * @param postProcess The post process to detach from the camera
  29632. */
  29633. detachPostProcess(postProcess: PostProcess): void;
  29634. /**
  29635. * Gets the current world matrix of the camera
  29636. */
  29637. getWorldMatrix(): Matrix;
  29638. /** @hidden */
  29639. _getViewMatrix(): Matrix;
  29640. /**
  29641. * Gets the current view matrix of the camera.
  29642. * @param force forces the camera to recompute the matrix without looking at the cached state
  29643. * @returns the view matrix
  29644. */
  29645. getViewMatrix(force?: boolean): Matrix;
  29646. /**
  29647. * Freeze the projection matrix.
  29648. * It will prevent the cache check of the camera projection compute and can speed up perf
  29649. * if no parameter of the camera are meant to change
  29650. * @param projection Defines manually a projection if necessary
  29651. */
  29652. freezeProjectionMatrix(projection?: Matrix): void;
  29653. /**
  29654. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29655. */
  29656. unfreezeProjectionMatrix(): void;
  29657. /**
  29658. * Gets the current projection matrix of the camera.
  29659. * @param force forces the camera to recompute the matrix without looking at the cached state
  29660. * @returns the projection matrix
  29661. */
  29662. getProjectionMatrix(force?: boolean): Matrix;
  29663. /**
  29664. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29665. * @returns a Matrix
  29666. */
  29667. getTransformationMatrix(): Matrix;
  29668. private _updateFrustumPlanes;
  29669. /**
  29670. * Checks if a cullable object (mesh...) is in the camera frustum
  29671. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29672. * @param target The object to check
  29673. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29674. * @returns true if the object is in frustum otherwise false
  29675. */
  29676. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29677. /**
  29678. * Checks if a cullable object (mesh...) is in the camera frustum
  29679. * Unlike isInFrustum this cheks the full bounding box
  29680. * @param target The object to check
  29681. * @returns true if the object is in frustum otherwise false
  29682. */
  29683. isCompletelyInFrustum(target: ICullable): boolean;
  29684. /**
  29685. * Gets a ray in the forward direction from the camera.
  29686. * @param length Defines the length of the ray to create
  29687. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29688. * @param origin Defines the start point of the ray which defaults to the camera position
  29689. * @returns the forward ray
  29690. */
  29691. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29692. /**
  29693. * Gets a ray in the forward direction from the camera.
  29694. * @param refRay the ray to (re)use when setting the values
  29695. * @param length Defines the length of the ray to create
  29696. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29697. * @param origin Defines the start point of the ray which defaults to the camera position
  29698. * @returns the forward ray
  29699. */
  29700. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29701. /**
  29702. * Releases resources associated with this node.
  29703. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29704. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29705. */
  29706. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29707. /** @hidden */
  29708. _isLeftCamera: boolean;
  29709. /**
  29710. * Gets the left camera of a rig setup in case of Rigged Camera
  29711. */
  29712. get isLeftCamera(): boolean;
  29713. /** @hidden */
  29714. _isRightCamera: boolean;
  29715. /**
  29716. * Gets the right camera of a rig setup in case of Rigged Camera
  29717. */
  29718. get isRightCamera(): boolean;
  29719. /**
  29720. * Gets the left camera of a rig setup in case of Rigged Camera
  29721. */
  29722. get leftCamera(): Nullable<FreeCamera>;
  29723. /**
  29724. * Gets the right camera of a rig setup in case of Rigged Camera
  29725. */
  29726. get rightCamera(): Nullable<FreeCamera>;
  29727. /**
  29728. * Gets the left camera target of a rig setup in case of Rigged Camera
  29729. * @returns the target position
  29730. */
  29731. getLeftTarget(): Nullable<Vector3>;
  29732. /**
  29733. * Gets the right camera target of a rig setup in case of Rigged Camera
  29734. * @returns the target position
  29735. */
  29736. getRightTarget(): Nullable<Vector3>;
  29737. /**
  29738. * @hidden
  29739. */
  29740. setCameraRigMode(mode: number, rigParams: any): void;
  29741. /** @hidden */
  29742. static _setStereoscopicRigMode(camera: Camera): void;
  29743. /** @hidden */
  29744. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29745. /** @hidden */
  29746. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29747. /** @hidden */
  29748. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29749. /** @hidden */
  29750. _getVRProjectionMatrix(): Matrix;
  29751. protected _updateCameraRotationMatrix(): void;
  29752. protected _updateWebVRCameraRotationMatrix(): void;
  29753. /**
  29754. * This function MUST be overwritten by the different WebVR cameras available.
  29755. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29756. * @hidden
  29757. */
  29758. _getWebVRProjectionMatrix(): Matrix;
  29759. /**
  29760. * This function MUST be overwritten by the different WebVR cameras available.
  29761. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29762. * @hidden
  29763. */
  29764. _getWebVRViewMatrix(): Matrix;
  29765. /** @hidden */
  29766. setCameraRigParameter(name: string, value: any): void;
  29767. /**
  29768. * needs to be overridden by children so sub has required properties to be copied
  29769. * @hidden
  29770. */
  29771. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29772. /**
  29773. * May need to be overridden by children
  29774. * @hidden
  29775. */
  29776. _updateRigCameras(): void;
  29777. /** @hidden */
  29778. _setupInputs(): void;
  29779. /**
  29780. * Serialiaze the camera setup to a json represention
  29781. * @returns the JSON representation
  29782. */
  29783. serialize(): any;
  29784. /**
  29785. * Clones the current camera.
  29786. * @param name The cloned camera name
  29787. * @returns the cloned camera
  29788. */
  29789. clone(name: string): Camera;
  29790. /**
  29791. * Gets the direction of the camera relative to a given local axis.
  29792. * @param localAxis Defines the reference axis to provide a relative direction.
  29793. * @return the direction
  29794. */
  29795. getDirection(localAxis: Vector3): Vector3;
  29796. /**
  29797. * Returns the current camera absolute rotation
  29798. */
  29799. get absoluteRotation(): Quaternion;
  29800. /**
  29801. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29802. * @param localAxis Defines the reference axis to provide a relative direction.
  29803. * @param result Defines the vector to store the result in
  29804. */
  29805. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29806. /**
  29807. * Gets a camera constructor for a given camera type
  29808. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29809. * @param name The name of the camera the result will be able to instantiate
  29810. * @param scene The scene the result will construct the camera in
  29811. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29812. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29813. * @returns a factory method to construc the camera
  29814. */
  29815. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29816. /**
  29817. * Compute the world matrix of the camera.
  29818. * @returns the camera world matrix
  29819. */
  29820. computeWorldMatrix(): Matrix;
  29821. /**
  29822. * Parse a JSON and creates the camera from the parsed information
  29823. * @param parsedCamera The JSON to parse
  29824. * @param scene The scene to instantiate the camera in
  29825. * @returns the newly constructed camera
  29826. */
  29827. static Parse(parsedCamera: any, scene: Scene): Camera;
  29828. }
  29829. }
  29830. declare module BABYLON {
  29831. /**
  29832. * Class containing static functions to help procedurally build meshes
  29833. */
  29834. export class DiscBuilder {
  29835. /**
  29836. * Creates a plane polygonal mesh. By default, this is a disc
  29837. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29838. * * 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
  29839. * * 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
  29840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29841. * * 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
  29842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29843. * @param name defines the name of the mesh
  29844. * @param options defines the options used to create the mesh
  29845. * @param scene defines the hosting scene
  29846. * @returns the plane polygonal mesh
  29847. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29848. */
  29849. static CreateDisc(name: string, options: {
  29850. radius?: number;
  29851. tessellation?: number;
  29852. arc?: number;
  29853. updatable?: boolean;
  29854. sideOrientation?: number;
  29855. frontUVs?: Vector4;
  29856. backUVs?: Vector4;
  29857. }, scene?: Nullable<Scene>): Mesh;
  29858. }
  29859. }
  29860. declare module BABYLON {
  29861. /**
  29862. * Options to be used when creating a FresnelParameters.
  29863. */
  29864. export type IFresnelParametersCreationOptions = {
  29865. /**
  29866. * Define the color used on edges (grazing angle)
  29867. */
  29868. leftColor?: Color3;
  29869. /**
  29870. * Define the color used on center
  29871. */
  29872. rightColor?: Color3;
  29873. /**
  29874. * Define bias applied to computed fresnel term
  29875. */
  29876. bias?: number;
  29877. /**
  29878. * Defined the power exponent applied to fresnel term
  29879. */
  29880. power?: number;
  29881. /**
  29882. * Define if the fresnel effect is enable or not.
  29883. */
  29884. isEnabled?: boolean;
  29885. };
  29886. /**
  29887. * Serialized format for FresnelParameters.
  29888. */
  29889. export type IFresnelParametersSerialized = {
  29890. /**
  29891. * Define the color used on edges (grazing angle) [as an array]
  29892. */
  29893. leftColor: number[];
  29894. /**
  29895. * Define the color used on center [as an array]
  29896. */
  29897. rightColor: number[];
  29898. /**
  29899. * Define bias applied to computed fresnel term
  29900. */
  29901. bias: number;
  29902. /**
  29903. * Defined the power exponent applied to fresnel term
  29904. */
  29905. power?: number;
  29906. /**
  29907. * Define if the fresnel effect is enable or not.
  29908. */
  29909. isEnabled: boolean;
  29910. };
  29911. /**
  29912. * This represents all the required information to add a fresnel effect on a material:
  29913. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29914. */
  29915. export class FresnelParameters {
  29916. private _isEnabled;
  29917. /**
  29918. * Define if the fresnel effect is enable or not.
  29919. */
  29920. get isEnabled(): boolean;
  29921. set isEnabled(value: boolean);
  29922. /**
  29923. * Define the color used on edges (grazing angle)
  29924. */
  29925. leftColor: Color3;
  29926. /**
  29927. * Define the color used on center
  29928. */
  29929. rightColor: Color3;
  29930. /**
  29931. * Define bias applied to computed fresnel term
  29932. */
  29933. bias: number;
  29934. /**
  29935. * Defined the power exponent applied to fresnel term
  29936. */
  29937. power: number;
  29938. /**
  29939. * Creates a new FresnelParameters object.
  29940. *
  29941. * @param options provide your own settings to optionally to override defaults
  29942. */
  29943. constructor(options?: IFresnelParametersCreationOptions);
  29944. /**
  29945. * Clones the current fresnel and its valuues
  29946. * @returns a clone fresnel configuration
  29947. */
  29948. clone(): FresnelParameters;
  29949. /**
  29950. * Determines equality between FresnelParameters objects
  29951. * @param otherFresnelParameters defines the second operand
  29952. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29953. */
  29954. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29955. /**
  29956. * Serializes the current fresnel parameters to a JSON representation.
  29957. * @return the JSON serialization
  29958. */
  29959. serialize(): IFresnelParametersSerialized;
  29960. /**
  29961. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29962. * @param parsedFresnelParameters Define the JSON representation
  29963. * @returns the parsed parameters
  29964. */
  29965. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29966. }
  29967. }
  29968. declare module BABYLON {
  29969. /**
  29970. * This groups all the flags used to control the materials channel.
  29971. */
  29972. export class MaterialFlags {
  29973. private static _DiffuseTextureEnabled;
  29974. /**
  29975. * Are diffuse textures enabled in the application.
  29976. */
  29977. static get DiffuseTextureEnabled(): boolean;
  29978. static set DiffuseTextureEnabled(value: boolean);
  29979. private static _DetailTextureEnabled;
  29980. /**
  29981. * Are detail textures enabled in the application.
  29982. */
  29983. static get DetailTextureEnabled(): boolean;
  29984. static set DetailTextureEnabled(value: boolean);
  29985. private static _AmbientTextureEnabled;
  29986. /**
  29987. * Are ambient textures enabled in the application.
  29988. */
  29989. static get AmbientTextureEnabled(): boolean;
  29990. static set AmbientTextureEnabled(value: boolean);
  29991. private static _OpacityTextureEnabled;
  29992. /**
  29993. * Are opacity textures enabled in the application.
  29994. */
  29995. static get OpacityTextureEnabled(): boolean;
  29996. static set OpacityTextureEnabled(value: boolean);
  29997. private static _ReflectionTextureEnabled;
  29998. /**
  29999. * Are reflection textures enabled in the application.
  30000. */
  30001. static get ReflectionTextureEnabled(): boolean;
  30002. static set ReflectionTextureEnabled(value: boolean);
  30003. private static _EmissiveTextureEnabled;
  30004. /**
  30005. * Are emissive textures enabled in the application.
  30006. */
  30007. static get EmissiveTextureEnabled(): boolean;
  30008. static set EmissiveTextureEnabled(value: boolean);
  30009. private static _SpecularTextureEnabled;
  30010. /**
  30011. * Are specular textures enabled in the application.
  30012. */
  30013. static get SpecularTextureEnabled(): boolean;
  30014. static set SpecularTextureEnabled(value: boolean);
  30015. private static _BumpTextureEnabled;
  30016. /**
  30017. * Are bump textures enabled in the application.
  30018. */
  30019. static get BumpTextureEnabled(): boolean;
  30020. static set BumpTextureEnabled(value: boolean);
  30021. private static _LightmapTextureEnabled;
  30022. /**
  30023. * Are lightmap textures enabled in the application.
  30024. */
  30025. static get LightmapTextureEnabled(): boolean;
  30026. static set LightmapTextureEnabled(value: boolean);
  30027. private static _RefractionTextureEnabled;
  30028. /**
  30029. * Are refraction textures enabled in the application.
  30030. */
  30031. static get RefractionTextureEnabled(): boolean;
  30032. static set RefractionTextureEnabled(value: boolean);
  30033. private static _ColorGradingTextureEnabled;
  30034. /**
  30035. * Are color grading textures enabled in the application.
  30036. */
  30037. static get ColorGradingTextureEnabled(): boolean;
  30038. static set ColorGradingTextureEnabled(value: boolean);
  30039. private static _FresnelEnabled;
  30040. /**
  30041. * Are fresnels enabled in the application.
  30042. */
  30043. static get FresnelEnabled(): boolean;
  30044. static set FresnelEnabled(value: boolean);
  30045. private static _ClearCoatTextureEnabled;
  30046. /**
  30047. * Are clear coat textures enabled in the application.
  30048. */
  30049. static get ClearCoatTextureEnabled(): boolean;
  30050. static set ClearCoatTextureEnabled(value: boolean);
  30051. private static _ClearCoatBumpTextureEnabled;
  30052. /**
  30053. * Are clear coat bump textures enabled in the application.
  30054. */
  30055. static get ClearCoatBumpTextureEnabled(): boolean;
  30056. static set ClearCoatBumpTextureEnabled(value: boolean);
  30057. private static _ClearCoatTintTextureEnabled;
  30058. /**
  30059. * Are clear coat tint textures enabled in the application.
  30060. */
  30061. static get ClearCoatTintTextureEnabled(): boolean;
  30062. static set ClearCoatTintTextureEnabled(value: boolean);
  30063. private static _SheenTextureEnabled;
  30064. /**
  30065. * Are sheen textures enabled in the application.
  30066. */
  30067. static get SheenTextureEnabled(): boolean;
  30068. static set SheenTextureEnabled(value: boolean);
  30069. private static _AnisotropicTextureEnabled;
  30070. /**
  30071. * Are anisotropic textures enabled in the application.
  30072. */
  30073. static get AnisotropicTextureEnabled(): boolean;
  30074. static set AnisotropicTextureEnabled(value: boolean);
  30075. private static _ThicknessTextureEnabled;
  30076. /**
  30077. * Are thickness textures enabled in the application.
  30078. */
  30079. static get ThicknessTextureEnabled(): boolean;
  30080. static set ThicknessTextureEnabled(value: boolean);
  30081. }
  30082. }
  30083. declare module BABYLON {
  30084. /** @hidden */
  30085. export var defaultFragmentDeclaration: {
  30086. name: string;
  30087. shader: string;
  30088. };
  30089. }
  30090. declare module BABYLON {
  30091. /** @hidden */
  30092. export var defaultUboDeclaration: {
  30093. name: string;
  30094. shader: string;
  30095. };
  30096. }
  30097. declare module BABYLON {
  30098. /** @hidden */
  30099. export var prePassDeclaration: {
  30100. name: string;
  30101. shader: string;
  30102. };
  30103. }
  30104. declare module BABYLON {
  30105. /** @hidden */
  30106. export var lightFragmentDeclaration: {
  30107. name: string;
  30108. shader: string;
  30109. };
  30110. }
  30111. declare module BABYLON {
  30112. /** @hidden */
  30113. export var lightUboDeclaration: {
  30114. name: string;
  30115. shader: string;
  30116. };
  30117. }
  30118. declare module BABYLON {
  30119. /** @hidden */
  30120. export var lightsFragmentFunctions: {
  30121. name: string;
  30122. shader: string;
  30123. };
  30124. }
  30125. declare module BABYLON {
  30126. /** @hidden */
  30127. export var shadowsFragmentFunctions: {
  30128. name: string;
  30129. shader: string;
  30130. };
  30131. }
  30132. declare module BABYLON {
  30133. /** @hidden */
  30134. export var fresnelFunction: {
  30135. name: string;
  30136. shader: string;
  30137. };
  30138. }
  30139. declare module BABYLON {
  30140. /** @hidden */
  30141. export var bumpFragmentMainFunctions: {
  30142. name: string;
  30143. shader: string;
  30144. };
  30145. }
  30146. declare module BABYLON {
  30147. /** @hidden */
  30148. export var bumpFragmentFunctions: {
  30149. name: string;
  30150. shader: string;
  30151. };
  30152. }
  30153. declare module BABYLON {
  30154. /** @hidden */
  30155. export var logDepthDeclaration: {
  30156. name: string;
  30157. shader: string;
  30158. };
  30159. }
  30160. declare module BABYLON {
  30161. /** @hidden */
  30162. export var bumpFragment: {
  30163. name: string;
  30164. shader: string;
  30165. };
  30166. }
  30167. declare module BABYLON {
  30168. /** @hidden */
  30169. export var depthPrePass: {
  30170. name: string;
  30171. shader: string;
  30172. };
  30173. }
  30174. declare module BABYLON {
  30175. /** @hidden */
  30176. export var lightFragment: {
  30177. name: string;
  30178. shader: string;
  30179. };
  30180. }
  30181. declare module BABYLON {
  30182. /** @hidden */
  30183. export var logDepthFragment: {
  30184. name: string;
  30185. shader: string;
  30186. };
  30187. }
  30188. declare module BABYLON {
  30189. /** @hidden */
  30190. export var defaultPixelShader: {
  30191. name: string;
  30192. shader: string;
  30193. };
  30194. }
  30195. declare module BABYLON {
  30196. /** @hidden */
  30197. export var defaultVertexDeclaration: {
  30198. name: string;
  30199. shader: string;
  30200. };
  30201. }
  30202. declare module BABYLON {
  30203. /** @hidden */
  30204. export var bumpVertexDeclaration: {
  30205. name: string;
  30206. shader: string;
  30207. };
  30208. }
  30209. declare module BABYLON {
  30210. /** @hidden */
  30211. export var bumpVertex: {
  30212. name: string;
  30213. shader: string;
  30214. };
  30215. }
  30216. declare module BABYLON {
  30217. /** @hidden */
  30218. export var fogVertex: {
  30219. name: string;
  30220. shader: string;
  30221. };
  30222. }
  30223. declare module BABYLON {
  30224. /** @hidden */
  30225. export var shadowsVertex: {
  30226. name: string;
  30227. shader: string;
  30228. };
  30229. }
  30230. declare module BABYLON {
  30231. /** @hidden */
  30232. export var pointCloudVertex: {
  30233. name: string;
  30234. shader: string;
  30235. };
  30236. }
  30237. declare module BABYLON {
  30238. /** @hidden */
  30239. export var logDepthVertex: {
  30240. name: string;
  30241. shader: string;
  30242. };
  30243. }
  30244. declare module BABYLON {
  30245. /** @hidden */
  30246. export var defaultVertexShader: {
  30247. name: string;
  30248. shader: string;
  30249. };
  30250. }
  30251. declare module BABYLON {
  30252. /**
  30253. * @hidden
  30254. */
  30255. export interface IMaterialDetailMapDefines {
  30256. DETAIL: boolean;
  30257. DETAILDIRECTUV: number;
  30258. DETAIL_NORMALBLENDMETHOD: number;
  30259. /** @hidden */
  30260. _areTexturesDirty: boolean;
  30261. }
  30262. /**
  30263. * Define the code related to the detail map parameters of a material
  30264. *
  30265. * Inspired from:
  30266. * 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
  30267. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30268. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30269. */
  30270. export class DetailMapConfiguration {
  30271. private _texture;
  30272. /**
  30273. * The detail texture of the material.
  30274. */
  30275. texture: Nullable<BaseTexture>;
  30276. /**
  30277. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30278. * Bigger values mean stronger blending
  30279. */
  30280. diffuseBlendLevel: number;
  30281. /**
  30282. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30283. * Bigger values mean stronger blending. Only used with PBR materials
  30284. */
  30285. roughnessBlendLevel: number;
  30286. /**
  30287. * Defines how strong the bump effect from the detail map is
  30288. * Bigger values mean stronger effect
  30289. */
  30290. bumpLevel: number;
  30291. private _normalBlendMethod;
  30292. /**
  30293. * The method used to blend the bump and detail normals together
  30294. */
  30295. normalBlendMethod: number;
  30296. private _isEnabled;
  30297. /**
  30298. * Enable or disable the detail map on this material
  30299. */
  30300. isEnabled: boolean;
  30301. /** @hidden */
  30302. private _internalMarkAllSubMeshesAsTexturesDirty;
  30303. /** @hidden */
  30304. _markAllSubMeshesAsTexturesDirty(): void;
  30305. /**
  30306. * Instantiate a new detail map
  30307. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30308. */
  30309. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30310. /**
  30311. * Gets whether the submesh is ready to be used or not.
  30312. * @param defines the list of "defines" to update.
  30313. * @param scene defines the scene the material belongs to.
  30314. * @returns - boolean indicating that the submesh is ready or not.
  30315. */
  30316. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30317. /**
  30318. * Update the defines for detail map usage
  30319. * @param defines the list of "defines" to update.
  30320. * @param scene defines the scene the material belongs to.
  30321. */
  30322. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30323. /**
  30324. * Binds the material data.
  30325. * @param uniformBuffer defines the Uniform buffer to fill in.
  30326. * @param scene defines the scene the material belongs to.
  30327. * @param isFrozen defines whether the material is frozen or not.
  30328. */
  30329. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30330. /**
  30331. * Checks to see if a texture is used in the material.
  30332. * @param texture - Base texture to use.
  30333. * @returns - Boolean specifying if a texture is used in the material.
  30334. */
  30335. hasTexture(texture: BaseTexture): boolean;
  30336. /**
  30337. * Returns an array of the actively used textures.
  30338. * @param activeTextures Array of BaseTextures
  30339. */
  30340. getActiveTextures(activeTextures: BaseTexture[]): void;
  30341. /**
  30342. * Returns the animatable textures.
  30343. * @param animatables Array of animatable textures.
  30344. */
  30345. getAnimatables(animatables: IAnimatable[]): void;
  30346. /**
  30347. * Disposes the resources of the material.
  30348. * @param forceDisposeTextures - Forces the disposal of all textures.
  30349. */
  30350. dispose(forceDisposeTextures?: boolean): void;
  30351. /**
  30352. * Get the current class name useful for serialization or dynamic coding.
  30353. * @returns "DetailMap"
  30354. */
  30355. getClassName(): string;
  30356. /**
  30357. * Add the required uniforms to the current list.
  30358. * @param uniforms defines the current uniform list.
  30359. */
  30360. static AddUniforms(uniforms: string[]): void;
  30361. /**
  30362. * Add the required samplers to the current list.
  30363. * @param samplers defines the current sampler list.
  30364. */
  30365. static AddSamplers(samplers: string[]): void;
  30366. /**
  30367. * Add the required uniforms to the current buffer.
  30368. * @param uniformBuffer defines the current uniform buffer.
  30369. */
  30370. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30371. /**
  30372. * Makes a duplicate of the current instance into another one.
  30373. * @param detailMap define the instance where to copy the info
  30374. */
  30375. copyTo(detailMap: DetailMapConfiguration): void;
  30376. /**
  30377. * Serializes this detail map instance
  30378. * @returns - An object with the serialized instance.
  30379. */
  30380. serialize(): any;
  30381. /**
  30382. * Parses a detail map setting from a serialized object.
  30383. * @param source - Serialized object.
  30384. * @param scene Defines the scene we are parsing for
  30385. * @param rootUrl Defines the rootUrl to load from
  30386. */
  30387. parse(source: any, scene: Scene, rootUrl: string): void;
  30388. }
  30389. }
  30390. declare module BABYLON {
  30391. /** @hidden */
  30392. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30393. MAINUV1: boolean;
  30394. MAINUV2: boolean;
  30395. DIFFUSE: boolean;
  30396. DIFFUSEDIRECTUV: number;
  30397. DETAIL: boolean;
  30398. DETAILDIRECTUV: number;
  30399. DETAIL_NORMALBLENDMETHOD: number;
  30400. AMBIENT: boolean;
  30401. AMBIENTDIRECTUV: number;
  30402. OPACITY: boolean;
  30403. OPACITYDIRECTUV: number;
  30404. OPACITYRGB: boolean;
  30405. REFLECTION: boolean;
  30406. EMISSIVE: boolean;
  30407. EMISSIVEDIRECTUV: number;
  30408. SPECULAR: boolean;
  30409. SPECULARDIRECTUV: number;
  30410. BUMP: boolean;
  30411. BUMPDIRECTUV: number;
  30412. PARALLAX: boolean;
  30413. PARALLAXOCCLUSION: boolean;
  30414. SPECULAROVERALPHA: boolean;
  30415. CLIPPLANE: boolean;
  30416. CLIPPLANE2: boolean;
  30417. CLIPPLANE3: boolean;
  30418. CLIPPLANE4: boolean;
  30419. CLIPPLANE5: boolean;
  30420. CLIPPLANE6: boolean;
  30421. ALPHATEST: boolean;
  30422. DEPTHPREPASS: boolean;
  30423. ALPHAFROMDIFFUSE: boolean;
  30424. POINTSIZE: boolean;
  30425. FOG: boolean;
  30426. SPECULARTERM: boolean;
  30427. DIFFUSEFRESNEL: boolean;
  30428. OPACITYFRESNEL: boolean;
  30429. REFLECTIONFRESNEL: boolean;
  30430. REFRACTIONFRESNEL: boolean;
  30431. EMISSIVEFRESNEL: boolean;
  30432. FRESNEL: boolean;
  30433. NORMAL: boolean;
  30434. UV1: boolean;
  30435. UV2: boolean;
  30436. VERTEXCOLOR: boolean;
  30437. VERTEXALPHA: boolean;
  30438. NUM_BONE_INFLUENCERS: number;
  30439. BonesPerMesh: number;
  30440. BONETEXTURE: boolean;
  30441. INSTANCES: boolean;
  30442. THIN_INSTANCES: boolean;
  30443. GLOSSINESS: boolean;
  30444. ROUGHNESS: boolean;
  30445. EMISSIVEASILLUMINATION: boolean;
  30446. LINKEMISSIVEWITHDIFFUSE: boolean;
  30447. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30448. LIGHTMAP: boolean;
  30449. LIGHTMAPDIRECTUV: number;
  30450. OBJECTSPACE_NORMALMAP: boolean;
  30451. USELIGHTMAPASSHADOWMAP: boolean;
  30452. REFLECTIONMAP_3D: boolean;
  30453. REFLECTIONMAP_SPHERICAL: boolean;
  30454. REFLECTIONMAP_PLANAR: boolean;
  30455. REFLECTIONMAP_CUBIC: boolean;
  30456. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30457. REFLECTIONMAP_PROJECTION: boolean;
  30458. REFLECTIONMAP_SKYBOX: boolean;
  30459. REFLECTIONMAP_EXPLICIT: boolean;
  30460. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30461. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30462. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30463. INVERTCUBICMAP: boolean;
  30464. LOGARITHMICDEPTH: boolean;
  30465. REFRACTION: boolean;
  30466. REFRACTIONMAP_3D: boolean;
  30467. REFLECTIONOVERALPHA: boolean;
  30468. TWOSIDEDLIGHTING: boolean;
  30469. SHADOWFLOAT: boolean;
  30470. MORPHTARGETS: boolean;
  30471. MORPHTARGETS_NORMAL: boolean;
  30472. MORPHTARGETS_TANGENT: boolean;
  30473. MORPHTARGETS_UV: boolean;
  30474. NUM_MORPH_INFLUENCERS: number;
  30475. NONUNIFORMSCALING: boolean;
  30476. PREMULTIPLYALPHA: boolean;
  30477. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30478. ALPHABLEND: boolean;
  30479. PREPASS: boolean;
  30480. SCENE_MRT_COUNT: number;
  30481. RGBDLIGHTMAP: boolean;
  30482. RGBDREFLECTION: boolean;
  30483. RGBDREFRACTION: boolean;
  30484. IMAGEPROCESSING: boolean;
  30485. VIGNETTE: boolean;
  30486. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30487. VIGNETTEBLENDMODEOPAQUE: boolean;
  30488. TONEMAPPING: boolean;
  30489. TONEMAPPING_ACES: boolean;
  30490. CONTRAST: boolean;
  30491. COLORCURVES: boolean;
  30492. COLORGRADING: boolean;
  30493. COLORGRADING3D: boolean;
  30494. SAMPLER3DGREENDEPTH: boolean;
  30495. SAMPLER3DBGRMAP: boolean;
  30496. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30497. MULTIVIEW: boolean;
  30498. /**
  30499. * If the reflection texture on this material is in linear color space
  30500. * @hidden
  30501. */
  30502. IS_REFLECTION_LINEAR: boolean;
  30503. /**
  30504. * If the refraction texture on this material is in linear color space
  30505. * @hidden
  30506. */
  30507. IS_REFRACTION_LINEAR: boolean;
  30508. EXPOSURE: boolean;
  30509. constructor();
  30510. setReflectionMode(modeToEnable: string): void;
  30511. }
  30512. /**
  30513. * This is the default material used in Babylon. It is the best trade off between quality
  30514. * and performances.
  30515. * @see https://doc.babylonjs.com/babylon101/materials
  30516. */
  30517. export class StandardMaterial extends PushMaterial {
  30518. private _diffuseTexture;
  30519. /**
  30520. * The basic texture of the material as viewed under a light.
  30521. */
  30522. diffuseTexture: Nullable<BaseTexture>;
  30523. private _ambientTexture;
  30524. /**
  30525. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30526. */
  30527. ambientTexture: Nullable<BaseTexture>;
  30528. private _opacityTexture;
  30529. /**
  30530. * Define the transparency of the material from a texture.
  30531. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30532. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30533. */
  30534. opacityTexture: Nullable<BaseTexture>;
  30535. private _reflectionTexture;
  30536. /**
  30537. * Define the texture used to display the reflection.
  30538. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30539. */
  30540. reflectionTexture: Nullable<BaseTexture>;
  30541. private _emissiveTexture;
  30542. /**
  30543. * Define texture of the material as if self lit.
  30544. * This will be mixed in the final result even in the absence of light.
  30545. */
  30546. emissiveTexture: Nullable<BaseTexture>;
  30547. private _specularTexture;
  30548. /**
  30549. * Define how the color and intensity of the highlight given by the light in the material.
  30550. */
  30551. specularTexture: Nullable<BaseTexture>;
  30552. private _bumpTexture;
  30553. /**
  30554. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30555. * 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.
  30556. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30557. */
  30558. bumpTexture: Nullable<BaseTexture>;
  30559. private _lightmapTexture;
  30560. /**
  30561. * Complex lighting can be computationally expensive to compute at runtime.
  30562. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30563. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30564. */
  30565. lightmapTexture: Nullable<BaseTexture>;
  30566. private _refractionTexture;
  30567. /**
  30568. * Define the texture used to display the refraction.
  30569. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30570. */
  30571. refractionTexture: Nullable<BaseTexture>;
  30572. /**
  30573. * The color of the material lit by the environmental background lighting.
  30574. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30575. */
  30576. ambientColor: Color3;
  30577. /**
  30578. * The basic color of the material as viewed under a light.
  30579. */
  30580. diffuseColor: Color3;
  30581. /**
  30582. * Define how the color and intensity of the highlight given by the light in the material.
  30583. */
  30584. specularColor: Color3;
  30585. /**
  30586. * Define the color of the material as if self lit.
  30587. * This will be mixed in the final result even in the absence of light.
  30588. */
  30589. emissiveColor: Color3;
  30590. /**
  30591. * Defines how sharp are the highlights in the material.
  30592. * The bigger the value the sharper giving a more glossy feeling to the result.
  30593. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30594. */
  30595. specularPower: number;
  30596. private _useAlphaFromDiffuseTexture;
  30597. /**
  30598. * Does the transparency come from the diffuse texture alpha channel.
  30599. */
  30600. useAlphaFromDiffuseTexture: boolean;
  30601. private _useEmissiveAsIllumination;
  30602. /**
  30603. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30604. */
  30605. useEmissiveAsIllumination: boolean;
  30606. private _linkEmissiveWithDiffuse;
  30607. /**
  30608. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30609. * the emissive level when the final color is close to one.
  30610. */
  30611. linkEmissiveWithDiffuse: boolean;
  30612. private _useSpecularOverAlpha;
  30613. /**
  30614. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30615. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30616. */
  30617. useSpecularOverAlpha: boolean;
  30618. private _useReflectionOverAlpha;
  30619. /**
  30620. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30621. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30622. */
  30623. useReflectionOverAlpha: boolean;
  30624. private _disableLighting;
  30625. /**
  30626. * Does lights from the scene impacts this material.
  30627. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30628. */
  30629. disableLighting: boolean;
  30630. private _useObjectSpaceNormalMap;
  30631. /**
  30632. * Allows using an object space normal map (instead of tangent space).
  30633. */
  30634. useObjectSpaceNormalMap: boolean;
  30635. private _useParallax;
  30636. /**
  30637. * Is parallax enabled or not.
  30638. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30639. */
  30640. useParallax: boolean;
  30641. private _useParallaxOcclusion;
  30642. /**
  30643. * Is parallax occlusion enabled or not.
  30644. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30645. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30646. */
  30647. useParallaxOcclusion: boolean;
  30648. /**
  30649. * 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.
  30650. */
  30651. parallaxScaleBias: number;
  30652. private _roughness;
  30653. /**
  30654. * Helps to define how blurry the reflections should appears in the material.
  30655. */
  30656. roughness: number;
  30657. /**
  30658. * In case of refraction, define the value of the index of refraction.
  30659. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30660. */
  30661. indexOfRefraction: number;
  30662. /**
  30663. * Invert the refraction texture alongside the y axis.
  30664. * It can be useful with procedural textures or probe for instance.
  30665. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30666. */
  30667. invertRefractionY: boolean;
  30668. /**
  30669. * Defines the alpha limits in alpha test mode.
  30670. */
  30671. alphaCutOff: number;
  30672. private _useLightmapAsShadowmap;
  30673. /**
  30674. * In case of light mapping, define whether the map contains light or shadow informations.
  30675. */
  30676. useLightmapAsShadowmap: boolean;
  30677. private _diffuseFresnelParameters;
  30678. /**
  30679. * Define the diffuse fresnel parameters of the material.
  30680. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30681. */
  30682. diffuseFresnelParameters: FresnelParameters;
  30683. private _opacityFresnelParameters;
  30684. /**
  30685. * Define the opacity fresnel parameters of the material.
  30686. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30687. */
  30688. opacityFresnelParameters: FresnelParameters;
  30689. private _reflectionFresnelParameters;
  30690. /**
  30691. * Define the reflection fresnel parameters of the material.
  30692. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30693. */
  30694. reflectionFresnelParameters: FresnelParameters;
  30695. private _refractionFresnelParameters;
  30696. /**
  30697. * Define the refraction fresnel parameters of the material.
  30698. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30699. */
  30700. refractionFresnelParameters: FresnelParameters;
  30701. private _emissiveFresnelParameters;
  30702. /**
  30703. * Define the emissive fresnel parameters of the material.
  30704. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30705. */
  30706. emissiveFresnelParameters: FresnelParameters;
  30707. private _useReflectionFresnelFromSpecular;
  30708. /**
  30709. * If true automatically deducts the fresnels values from the material specularity.
  30710. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30711. */
  30712. useReflectionFresnelFromSpecular: boolean;
  30713. private _useGlossinessFromSpecularMapAlpha;
  30714. /**
  30715. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30716. */
  30717. useGlossinessFromSpecularMapAlpha: boolean;
  30718. private _maxSimultaneousLights;
  30719. /**
  30720. * Defines the maximum number of lights that can be used in the material
  30721. */
  30722. maxSimultaneousLights: number;
  30723. private _invertNormalMapX;
  30724. /**
  30725. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30726. */
  30727. invertNormalMapX: boolean;
  30728. private _invertNormalMapY;
  30729. /**
  30730. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30731. */
  30732. invertNormalMapY: boolean;
  30733. private _twoSidedLighting;
  30734. /**
  30735. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30736. */
  30737. twoSidedLighting: boolean;
  30738. /**
  30739. * Default configuration related to image processing available in the standard Material.
  30740. */
  30741. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30742. /**
  30743. * Gets the image processing configuration used either in this material.
  30744. */
  30745. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30746. /**
  30747. * Sets the Default image processing configuration used either in the this material.
  30748. *
  30749. * If sets to null, the scene one is in use.
  30750. */
  30751. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30752. /**
  30753. * Keep track of the image processing observer to allow dispose and replace.
  30754. */
  30755. private _imageProcessingObserver;
  30756. /**
  30757. * Attaches a new image processing configuration to the Standard Material.
  30758. * @param configuration
  30759. */
  30760. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30761. /**
  30762. * Gets wether the color curves effect is enabled.
  30763. */
  30764. get cameraColorCurvesEnabled(): boolean;
  30765. /**
  30766. * Sets wether the color curves effect is enabled.
  30767. */
  30768. set cameraColorCurvesEnabled(value: boolean);
  30769. /**
  30770. * Gets wether the color grading effect is enabled.
  30771. */
  30772. get cameraColorGradingEnabled(): boolean;
  30773. /**
  30774. * Gets wether the color grading effect is enabled.
  30775. */
  30776. set cameraColorGradingEnabled(value: boolean);
  30777. /**
  30778. * Gets wether tonemapping is enabled or not.
  30779. */
  30780. get cameraToneMappingEnabled(): boolean;
  30781. /**
  30782. * Sets wether tonemapping is enabled or not
  30783. */
  30784. set cameraToneMappingEnabled(value: boolean);
  30785. /**
  30786. * The camera exposure used on this material.
  30787. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30788. * This corresponds to a photographic exposure.
  30789. */
  30790. get cameraExposure(): number;
  30791. /**
  30792. * The camera exposure used on this material.
  30793. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30794. * This corresponds to a photographic exposure.
  30795. */
  30796. set cameraExposure(value: number);
  30797. /**
  30798. * Gets The camera contrast used on this material.
  30799. */
  30800. get cameraContrast(): number;
  30801. /**
  30802. * Sets The camera contrast used on this material.
  30803. */
  30804. set cameraContrast(value: number);
  30805. /**
  30806. * Gets the Color Grading 2D Lookup Texture.
  30807. */
  30808. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30809. /**
  30810. * Sets the Color Grading 2D Lookup Texture.
  30811. */
  30812. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30813. /**
  30814. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30815. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30816. * 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;
  30817. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30818. */
  30819. get cameraColorCurves(): Nullable<ColorCurves>;
  30820. /**
  30821. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30822. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30823. * 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;
  30824. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30825. */
  30826. set cameraColorCurves(value: Nullable<ColorCurves>);
  30827. /**
  30828. * Can this material render to several textures at once
  30829. */
  30830. get canRenderToMRT(): boolean;
  30831. /**
  30832. * Defines the detail map parameters for the material.
  30833. */
  30834. readonly detailMap: DetailMapConfiguration;
  30835. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30836. protected _worldViewProjectionMatrix: Matrix;
  30837. protected _globalAmbientColor: Color3;
  30838. protected _useLogarithmicDepth: boolean;
  30839. protected _rebuildInParallel: boolean;
  30840. /**
  30841. * Instantiates a new standard material.
  30842. * This is the default material used in Babylon. It is the best trade off between quality
  30843. * and performances.
  30844. * @see https://doc.babylonjs.com/babylon101/materials
  30845. * @param name Define the name of the material in the scene
  30846. * @param scene Define the scene the material belong to
  30847. */
  30848. constructor(name: string, scene: Scene);
  30849. /**
  30850. * Gets a boolean indicating that current material needs to register RTT
  30851. */
  30852. get hasRenderTargetTextures(): boolean;
  30853. /**
  30854. * Gets the current class name of the material e.g. "StandardMaterial"
  30855. * Mainly use in serialization.
  30856. * @returns the class name
  30857. */
  30858. getClassName(): string;
  30859. /**
  30860. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30861. * You can try switching to logarithmic depth.
  30862. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30863. */
  30864. get useLogarithmicDepth(): boolean;
  30865. set useLogarithmicDepth(value: boolean);
  30866. /**
  30867. * Specifies if the material will require alpha blending
  30868. * @returns a boolean specifying if alpha blending is needed
  30869. */
  30870. needAlphaBlending(): boolean;
  30871. /**
  30872. * Specifies if this material should be rendered in alpha test mode
  30873. * @returns a boolean specifying if an alpha test is needed.
  30874. */
  30875. needAlphaTesting(): boolean;
  30876. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30877. /**
  30878. * Get the texture used for alpha test purpose.
  30879. * @returns the diffuse texture in case of the standard material.
  30880. */
  30881. getAlphaTestTexture(): Nullable<BaseTexture>;
  30882. /**
  30883. * Get if the submesh is ready to be used and all its information available.
  30884. * Child classes can use it to update shaders
  30885. * @param mesh defines the mesh to check
  30886. * @param subMesh defines which submesh to check
  30887. * @param useInstances specifies that instances should be used
  30888. * @returns a boolean indicating that the submesh is ready or not
  30889. */
  30890. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30891. /**
  30892. * Builds the material UBO layouts.
  30893. * Used internally during the effect preparation.
  30894. */
  30895. buildUniformLayout(): void;
  30896. /**
  30897. * Unbinds the material from the mesh
  30898. */
  30899. unbind(): void;
  30900. /**
  30901. * Binds the submesh to this material by preparing the effect and shader to draw
  30902. * @param world defines the world transformation matrix
  30903. * @param mesh defines the mesh containing the submesh
  30904. * @param subMesh defines the submesh to bind the material to
  30905. */
  30906. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30907. /**
  30908. * Get the list of animatables in the material.
  30909. * @returns the list of animatables object used in the material
  30910. */
  30911. getAnimatables(): IAnimatable[];
  30912. /**
  30913. * Gets the active textures from the material
  30914. * @returns an array of textures
  30915. */
  30916. getActiveTextures(): BaseTexture[];
  30917. /**
  30918. * Specifies if the material uses a texture
  30919. * @param texture defines the texture to check against the material
  30920. * @returns a boolean specifying if the material uses the texture
  30921. */
  30922. hasTexture(texture: BaseTexture): boolean;
  30923. /**
  30924. * Disposes the material
  30925. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30926. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30927. */
  30928. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30929. /**
  30930. * Makes a duplicate of the material, and gives it a new name
  30931. * @param name defines the new name for the duplicated material
  30932. * @returns the cloned material
  30933. */
  30934. clone(name: string): StandardMaterial;
  30935. /**
  30936. * Serializes this material in a JSON representation
  30937. * @returns the serialized material object
  30938. */
  30939. serialize(): any;
  30940. /**
  30941. * Creates a standard material from parsed material data
  30942. * @param source defines the JSON representation of the material
  30943. * @param scene defines the hosting scene
  30944. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30945. * @returns a new standard material
  30946. */
  30947. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30948. /**
  30949. * Are diffuse textures enabled in the application.
  30950. */
  30951. static get DiffuseTextureEnabled(): boolean;
  30952. static set DiffuseTextureEnabled(value: boolean);
  30953. /**
  30954. * Are detail textures enabled in the application.
  30955. */
  30956. static get DetailTextureEnabled(): boolean;
  30957. static set DetailTextureEnabled(value: boolean);
  30958. /**
  30959. * Are ambient textures enabled in the application.
  30960. */
  30961. static get AmbientTextureEnabled(): boolean;
  30962. static set AmbientTextureEnabled(value: boolean);
  30963. /**
  30964. * Are opacity textures enabled in the application.
  30965. */
  30966. static get OpacityTextureEnabled(): boolean;
  30967. static set OpacityTextureEnabled(value: boolean);
  30968. /**
  30969. * Are reflection textures enabled in the application.
  30970. */
  30971. static get ReflectionTextureEnabled(): boolean;
  30972. static set ReflectionTextureEnabled(value: boolean);
  30973. /**
  30974. * Are emissive textures enabled in the application.
  30975. */
  30976. static get EmissiveTextureEnabled(): boolean;
  30977. static set EmissiveTextureEnabled(value: boolean);
  30978. /**
  30979. * Are specular textures enabled in the application.
  30980. */
  30981. static get SpecularTextureEnabled(): boolean;
  30982. static set SpecularTextureEnabled(value: boolean);
  30983. /**
  30984. * Are bump textures enabled in the application.
  30985. */
  30986. static get BumpTextureEnabled(): boolean;
  30987. static set BumpTextureEnabled(value: boolean);
  30988. /**
  30989. * Are lightmap textures enabled in the application.
  30990. */
  30991. static get LightmapTextureEnabled(): boolean;
  30992. static set LightmapTextureEnabled(value: boolean);
  30993. /**
  30994. * Are refraction textures enabled in the application.
  30995. */
  30996. static get RefractionTextureEnabled(): boolean;
  30997. static set RefractionTextureEnabled(value: boolean);
  30998. /**
  30999. * Are color grading textures enabled in the application.
  31000. */
  31001. static get ColorGradingTextureEnabled(): boolean;
  31002. static set ColorGradingTextureEnabled(value: boolean);
  31003. /**
  31004. * Are fresnels enabled in the application.
  31005. */
  31006. static get FresnelEnabled(): boolean;
  31007. static set FresnelEnabled(value: boolean);
  31008. }
  31009. }
  31010. declare module BABYLON {
  31011. /**
  31012. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31013. *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.
  31014. * The SPS is also a particle system. It provides some methods to manage the particles.
  31015. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31016. *
  31017. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31018. */
  31019. export class SolidParticleSystem implements IDisposable {
  31020. /**
  31021. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31022. * Example : var p = SPS.particles[i];
  31023. */
  31024. particles: SolidParticle[];
  31025. /**
  31026. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31027. */
  31028. nbParticles: number;
  31029. /**
  31030. * If the particles must ever face the camera (default false). Useful for planar particles.
  31031. */
  31032. billboard: boolean;
  31033. /**
  31034. * Recompute normals when adding a shape
  31035. */
  31036. recomputeNormals: boolean;
  31037. /**
  31038. * This a counter ofr your own usage. It's not set by any SPS functions.
  31039. */
  31040. counter: number;
  31041. /**
  31042. * The SPS name. This name is also given to the underlying mesh.
  31043. */
  31044. name: string;
  31045. /**
  31046. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31047. */
  31048. mesh: Mesh;
  31049. /**
  31050. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31051. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31052. */
  31053. vars: any;
  31054. /**
  31055. * This array is populated when the SPS is set as 'pickable'.
  31056. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31057. * Each element of this array is an object `{idx: int, faceId: int}`.
  31058. * `idx` is the picked particle index in the `SPS.particles` array
  31059. * `faceId` is the picked face index counted within this particle.
  31060. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31061. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31062. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31063. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31064. */
  31065. pickedParticles: {
  31066. idx: number;
  31067. faceId: number;
  31068. }[];
  31069. /**
  31070. * This array is populated when the SPS is set as 'pickable'
  31071. * Each key of this array is a submesh index.
  31072. * Each element of this array is a second array defined like this :
  31073. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31074. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31075. * `idx` is the picked particle index in the `SPS.particles` array
  31076. * `faceId` is the picked face index counted within this particle.
  31077. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31078. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31079. */
  31080. pickedBySubMesh: {
  31081. idx: number;
  31082. faceId: number;
  31083. }[][];
  31084. /**
  31085. * This array is populated when `enableDepthSort` is set to true.
  31086. * Each element of this array is an instance of the class DepthSortedParticle.
  31087. */
  31088. depthSortedParticles: DepthSortedParticle[];
  31089. /**
  31090. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31091. * @hidden
  31092. */
  31093. _bSphereOnly: boolean;
  31094. /**
  31095. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31096. * @hidden
  31097. */
  31098. _bSphereRadiusFactor: number;
  31099. private _scene;
  31100. private _positions;
  31101. private _indices;
  31102. private _normals;
  31103. private _colors;
  31104. private _uvs;
  31105. private _indices32;
  31106. private _positions32;
  31107. private _normals32;
  31108. private _fixedNormal32;
  31109. private _colors32;
  31110. private _uvs32;
  31111. private _index;
  31112. private _updatable;
  31113. private _pickable;
  31114. private _isVisibilityBoxLocked;
  31115. private _alwaysVisible;
  31116. private _depthSort;
  31117. private _expandable;
  31118. private _shapeCounter;
  31119. private _copy;
  31120. private _color;
  31121. private _computeParticleColor;
  31122. private _computeParticleTexture;
  31123. private _computeParticleRotation;
  31124. private _computeParticleVertex;
  31125. private _computeBoundingBox;
  31126. private _depthSortParticles;
  31127. private _camera;
  31128. private _mustUnrotateFixedNormals;
  31129. private _particlesIntersect;
  31130. private _needs32Bits;
  31131. private _isNotBuilt;
  31132. private _lastParticleId;
  31133. private _idxOfId;
  31134. private _multimaterialEnabled;
  31135. private _useModelMaterial;
  31136. private _indicesByMaterial;
  31137. private _materialIndexes;
  31138. private _depthSortFunction;
  31139. private _materialSortFunction;
  31140. private _materials;
  31141. private _multimaterial;
  31142. private _materialIndexesById;
  31143. private _defaultMaterial;
  31144. private _autoUpdateSubMeshes;
  31145. private _tmpVertex;
  31146. /**
  31147. * Creates a SPS (Solid Particle System) object.
  31148. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31149. * @param scene (Scene) is the scene in which the SPS is added.
  31150. * @param options defines the options of the sps e.g.
  31151. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31152. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31153. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31154. * * 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.
  31155. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31156. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31157. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31158. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31159. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31160. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31161. */
  31162. constructor(name: string, scene: Scene, options?: {
  31163. updatable?: boolean;
  31164. isPickable?: boolean;
  31165. enableDepthSort?: boolean;
  31166. particleIntersection?: boolean;
  31167. boundingSphereOnly?: boolean;
  31168. bSphereRadiusFactor?: number;
  31169. expandable?: boolean;
  31170. useModelMaterial?: boolean;
  31171. enableMultiMaterial?: boolean;
  31172. });
  31173. /**
  31174. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31175. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31176. * @returns the created mesh
  31177. */
  31178. buildMesh(): Mesh;
  31179. /**
  31180. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31181. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31182. * Thus the particles generated from `digest()` have their property `position` set yet.
  31183. * @param mesh ( Mesh ) is the mesh to be digested
  31184. * @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
  31185. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31186. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31187. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31188. * @returns the current SPS
  31189. */
  31190. digest(mesh: Mesh, options?: {
  31191. facetNb?: number;
  31192. number?: number;
  31193. delta?: number;
  31194. storage?: [];
  31195. }): SolidParticleSystem;
  31196. /**
  31197. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31198. * @hidden
  31199. */
  31200. private _unrotateFixedNormals;
  31201. /**
  31202. * Resets the temporary working copy particle
  31203. * @hidden
  31204. */
  31205. private _resetCopy;
  31206. /**
  31207. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31208. * @param p the current index in the positions array to be updated
  31209. * @param ind the current index in the indices array
  31210. * @param shape a Vector3 array, the shape geometry
  31211. * @param positions the positions array to be updated
  31212. * @param meshInd the shape indices array
  31213. * @param indices the indices array to be updated
  31214. * @param meshUV the shape uv array
  31215. * @param uvs the uv array to be updated
  31216. * @param meshCol the shape color array
  31217. * @param colors the color array to be updated
  31218. * @param meshNor the shape normals array
  31219. * @param normals the normals array to be updated
  31220. * @param idx the particle index
  31221. * @param idxInShape the particle index in its shape
  31222. * @param options the addShape() method passed options
  31223. * @model the particle model
  31224. * @hidden
  31225. */
  31226. private _meshBuilder;
  31227. /**
  31228. * Returns a shape Vector3 array from positions float array
  31229. * @param positions float array
  31230. * @returns a vector3 array
  31231. * @hidden
  31232. */
  31233. private _posToShape;
  31234. /**
  31235. * Returns a shapeUV array from a float uvs (array deep copy)
  31236. * @param uvs as a float array
  31237. * @returns a shapeUV array
  31238. * @hidden
  31239. */
  31240. private _uvsToShapeUV;
  31241. /**
  31242. * Adds a new particle object in the particles array
  31243. * @param idx particle index in particles array
  31244. * @param id particle id
  31245. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31246. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31247. * @param model particle ModelShape object
  31248. * @param shapeId model shape identifier
  31249. * @param idxInShape index of the particle in the current model
  31250. * @param bInfo model bounding info object
  31251. * @param storage target storage array, if any
  31252. * @hidden
  31253. */
  31254. private _addParticle;
  31255. /**
  31256. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31257. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31258. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31259. * @param nb (positive integer) the number of particles to be created from this model
  31260. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31261. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31262. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31263. * @returns the number of shapes in the system
  31264. */
  31265. addShape(mesh: Mesh, nb: number, options?: {
  31266. positionFunction?: any;
  31267. vertexFunction?: any;
  31268. storage?: [];
  31269. }): number;
  31270. /**
  31271. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31272. * @hidden
  31273. */
  31274. private _rebuildParticle;
  31275. /**
  31276. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31277. * @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.
  31278. * @returns the SPS.
  31279. */
  31280. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31281. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31282. * Returns an array with the removed particles.
  31283. * 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.
  31284. * The SPS can't be empty so at least one particle needs to remain in place.
  31285. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31286. * @param start index of the first particle to remove
  31287. * @param end index of the last particle to remove (included)
  31288. * @returns an array populated with the removed particles
  31289. */
  31290. removeParticles(start: number, end: number): SolidParticle[];
  31291. /**
  31292. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31293. * @param solidParticleArray an array populated with Solid Particles objects
  31294. * @returns the SPS
  31295. */
  31296. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31297. /**
  31298. * Creates a new particle and modifies the SPS mesh geometry :
  31299. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31300. * - calls _addParticle() to populate the particle array
  31301. * factorized code from addShape() and insertParticlesFromArray()
  31302. * @param idx particle index in the particles array
  31303. * @param i particle index in its shape
  31304. * @param modelShape particle ModelShape object
  31305. * @param shape shape vertex array
  31306. * @param meshInd shape indices array
  31307. * @param meshUV shape uv array
  31308. * @param meshCol shape color array
  31309. * @param meshNor shape normals array
  31310. * @param bbInfo shape bounding info
  31311. * @param storage target particle storage
  31312. * @options addShape() passed options
  31313. * @hidden
  31314. */
  31315. private _insertNewParticle;
  31316. /**
  31317. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31318. * This method calls `updateParticle()` for each particle of the SPS.
  31319. * For an animated SPS, it is usually called within the render loop.
  31320. * 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.
  31321. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31322. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31323. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31324. * @returns the SPS.
  31325. */
  31326. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31327. /**
  31328. * Disposes the SPS.
  31329. */
  31330. dispose(): void;
  31331. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31332. * idx is the particle index in the SPS
  31333. * faceId is the picked face index counted within this particle.
  31334. * Returns null if the pickInfo can't identify a picked particle.
  31335. * @param pickingInfo (PickingInfo object)
  31336. * @returns {idx: number, faceId: number} or null
  31337. */
  31338. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31339. idx: number;
  31340. faceId: number;
  31341. }>;
  31342. /**
  31343. * Returns a SolidParticle object from its identifier : particle.id
  31344. * @param id (integer) the particle Id
  31345. * @returns the searched particle or null if not found in the SPS.
  31346. */
  31347. getParticleById(id: number): Nullable<SolidParticle>;
  31348. /**
  31349. * Returns a new array populated with the particles having the passed shapeId.
  31350. * @param shapeId (integer) the shape identifier
  31351. * @returns a new solid particle array
  31352. */
  31353. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31354. /**
  31355. * Populates the passed array "ref" with the particles having the passed shapeId.
  31356. * @param shapeId the shape identifier
  31357. * @returns the SPS
  31358. * @param ref
  31359. */
  31360. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31361. /**
  31362. * Computes the required SubMeshes according the materials assigned to the particles.
  31363. * @returns the solid particle system.
  31364. * Does nothing if called before the SPS mesh is built.
  31365. */
  31366. computeSubMeshes(): SolidParticleSystem;
  31367. /**
  31368. * Sorts the solid particles by material when MultiMaterial is enabled.
  31369. * Updates the indices32 array.
  31370. * Updates the indicesByMaterial array.
  31371. * Updates the mesh indices array.
  31372. * @returns the SPS
  31373. * @hidden
  31374. */
  31375. private _sortParticlesByMaterial;
  31376. /**
  31377. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31378. * @hidden
  31379. */
  31380. private _setMaterialIndexesById;
  31381. /**
  31382. * Returns an array with unique values of Materials from the passed array
  31383. * @param array the material array to be checked and filtered
  31384. * @hidden
  31385. */
  31386. private _filterUniqueMaterialId;
  31387. /**
  31388. * Sets a new Standard Material as _defaultMaterial if not already set.
  31389. * @hidden
  31390. */
  31391. private _setDefaultMaterial;
  31392. /**
  31393. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31394. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31395. * @returns the SPS.
  31396. */
  31397. refreshVisibleSize(): SolidParticleSystem;
  31398. /**
  31399. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31400. * @param size the size (float) of the visibility box
  31401. * note : this doesn't lock the SPS mesh bounding box.
  31402. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31403. */
  31404. setVisibilityBox(size: number): void;
  31405. /**
  31406. * Gets whether the SPS as always visible or not
  31407. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31408. */
  31409. get isAlwaysVisible(): boolean;
  31410. /**
  31411. * Sets the SPS as always visible or not
  31412. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31413. */
  31414. set isAlwaysVisible(val: boolean);
  31415. /**
  31416. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31417. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31418. */
  31419. set isVisibilityBoxLocked(val: boolean);
  31420. /**
  31421. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31422. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31423. */
  31424. get isVisibilityBoxLocked(): boolean;
  31425. /**
  31426. * Tells to `setParticles()` to compute the particle rotations or not.
  31427. * Default value : true. The SPS is faster when it's set to false.
  31428. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31429. */
  31430. set computeParticleRotation(val: boolean);
  31431. /**
  31432. * Tells to `setParticles()` to compute the particle colors or not.
  31433. * Default value : true. The SPS is faster when it's set to false.
  31434. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31435. */
  31436. set computeParticleColor(val: boolean);
  31437. set computeParticleTexture(val: boolean);
  31438. /**
  31439. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31440. * Default value : false. The SPS is faster when it's set to false.
  31441. * Note : the particle custom vertex positions aren't stored values.
  31442. */
  31443. set computeParticleVertex(val: boolean);
  31444. /**
  31445. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31446. */
  31447. set computeBoundingBox(val: boolean);
  31448. /**
  31449. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31450. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31451. * Default : `true`
  31452. */
  31453. set depthSortParticles(val: boolean);
  31454. /**
  31455. * Gets if `setParticles()` computes the particle rotations or not.
  31456. * Default value : true. The SPS is faster when it's set to false.
  31457. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31458. */
  31459. get computeParticleRotation(): boolean;
  31460. /**
  31461. * Gets if `setParticles()` computes the particle colors or not.
  31462. * Default value : true. The SPS is faster when it's set to false.
  31463. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31464. */
  31465. get computeParticleColor(): boolean;
  31466. /**
  31467. * Gets if `setParticles()` computes the particle textures or not.
  31468. * Default value : true. The SPS is faster when it's set to false.
  31469. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31470. */
  31471. get computeParticleTexture(): boolean;
  31472. /**
  31473. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31474. * Default value : false. The SPS is faster when it's set to false.
  31475. * Note : the particle custom vertex positions aren't stored values.
  31476. */
  31477. get computeParticleVertex(): boolean;
  31478. /**
  31479. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31480. */
  31481. get computeBoundingBox(): boolean;
  31482. /**
  31483. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31484. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31485. * Default : `true`
  31486. */
  31487. get depthSortParticles(): boolean;
  31488. /**
  31489. * Gets if the SPS is created as expandable at construction time.
  31490. * Default : `false`
  31491. */
  31492. get expandable(): boolean;
  31493. /**
  31494. * Gets if the SPS supports the Multi Materials
  31495. */
  31496. get multimaterialEnabled(): boolean;
  31497. /**
  31498. * Gets if the SPS uses the model materials for its own multimaterial.
  31499. */
  31500. get useModelMaterial(): boolean;
  31501. /**
  31502. * The SPS used material array.
  31503. */
  31504. get materials(): Material[];
  31505. /**
  31506. * Sets the SPS MultiMaterial from the passed materials.
  31507. * Note : the passed array is internally copied and not used then by reference.
  31508. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31509. */
  31510. setMultiMaterial(materials: Material[]): void;
  31511. /**
  31512. * The SPS computed multimaterial object
  31513. */
  31514. get multimaterial(): MultiMaterial;
  31515. set multimaterial(mm: MultiMaterial);
  31516. /**
  31517. * If the subMeshes must be updated on the next call to setParticles()
  31518. */
  31519. get autoUpdateSubMeshes(): boolean;
  31520. set autoUpdateSubMeshes(val: boolean);
  31521. /**
  31522. * This function does nothing. It may be overwritten to set all the particle first values.
  31523. * The SPS doesn't call this function, you may have to call it by your own.
  31524. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31525. */
  31526. initParticles(): void;
  31527. /**
  31528. * This function does nothing. It may be overwritten to recycle a particle.
  31529. * The SPS doesn't call this function, you may have to call it by your own.
  31530. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31531. * @param particle The particle to recycle
  31532. * @returns the recycled particle
  31533. */
  31534. recycleParticle(particle: SolidParticle): SolidParticle;
  31535. /**
  31536. * Updates a particle : this function should be overwritten by the user.
  31537. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31538. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31539. * @example : just set a particle position or velocity and recycle conditions
  31540. * @param particle The particle to update
  31541. * @returns the updated particle
  31542. */
  31543. updateParticle(particle: SolidParticle): SolidParticle;
  31544. /**
  31545. * Updates a vertex of a particle : it can be overwritten by the user.
  31546. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31547. * @param particle the current particle
  31548. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31549. * @param pt the index of the current vertex in the particle shape
  31550. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31551. * @example : just set a vertex particle position or color
  31552. * @returns the sps
  31553. */
  31554. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31555. /**
  31556. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31557. * This does nothing and may be overwritten by the user.
  31558. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31559. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31560. * @param update the boolean update value actually passed to setParticles()
  31561. */
  31562. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31563. /**
  31564. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31565. * This will be passed three parameters.
  31566. * This does nothing and may be overwritten by the user.
  31567. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31568. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31569. * @param update the boolean update value actually passed to setParticles()
  31570. */
  31571. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31572. }
  31573. }
  31574. declare module BABYLON {
  31575. /**
  31576. * Represents one particle of a solid particle system.
  31577. */
  31578. export class SolidParticle {
  31579. /**
  31580. * particle global index
  31581. */
  31582. idx: number;
  31583. /**
  31584. * particle identifier
  31585. */
  31586. id: number;
  31587. /**
  31588. * The color of the particle
  31589. */
  31590. color: Nullable<Color4>;
  31591. /**
  31592. * The world space position of the particle.
  31593. */
  31594. position: Vector3;
  31595. /**
  31596. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31597. */
  31598. rotation: Vector3;
  31599. /**
  31600. * The world space rotation quaternion of the particle.
  31601. */
  31602. rotationQuaternion: Nullable<Quaternion>;
  31603. /**
  31604. * The scaling of the particle.
  31605. */
  31606. scaling: Vector3;
  31607. /**
  31608. * The uvs of the particle.
  31609. */
  31610. uvs: Vector4;
  31611. /**
  31612. * The current speed of the particle.
  31613. */
  31614. velocity: Vector3;
  31615. /**
  31616. * The pivot point in the particle local space.
  31617. */
  31618. pivot: Vector3;
  31619. /**
  31620. * Must the particle be translated from its pivot point in its local space ?
  31621. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31622. * Default : false
  31623. */
  31624. translateFromPivot: boolean;
  31625. /**
  31626. * Is the particle active or not ?
  31627. */
  31628. alive: boolean;
  31629. /**
  31630. * Is the particle visible or not ?
  31631. */
  31632. isVisible: boolean;
  31633. /**
  31634. * Index of this particle in the global "positions" array (Internal use)
  31635. * @hidden
  31636. */
  31637. _pos: number;
  31638. /**
  31639. * @hidden Index of this particle in the global "indices" array (Internal use)
  31640. */
  31641. _ind: number;
  31642. /**
  31643. * @hidden ModelShape of this particle (Internal use)
  31644. */
  31645. _model: ModelShape;
  31646. /**
  31647. * ModelShape id of this particle
  31648. */
  31649. shapeId: number;
  31650. /**
  31651. * Index of the particle in its shape id
  31652. */
  31653. idxInShape: number;
  31654. /**
  31655. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31656. */
  31657. _modelBoundingInfo: BoundingInfo;
  31658. /**
  31659. * @hidden Particle BoundingInfo object (Internal use)
  31660. */
  31661. _boundingInfo: BoundingInfo;
  31662. /**
  31663. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31664. */
  31665. _sps: SolidParticleSystem;
  31666. /**
  31667. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31668. */
  31669. _stillInvisible: boolean;
  31670. /**
  31671. * @hidden Last computed particle rotation matrix
  31672. */
  31673. _rotationMatrix: number[];
  31674. /**
  31675. * Parent particle Id, if any.
  31676. * Default null.
  31677. */
  31678. parentId: Nullable<number>;
  31679. /**
  31680. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31681. */
  31682. materialIndex: Nullable<number>;
  31683. /**
  31684. * Custom object or properties.
  31685. */
  31686. props: Nullable<any>;
  31687. /**
  31688. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31689. * The possible values are :
  31690. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31691. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31692. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31693. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31694. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31695. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31696. * */
  31697. cullingStrategy: number;
  31698. /**
  31699. * @hidden Internal global position in the SPS.
  31700. */
  31701. _globalPosition: Vector3;
  31702. /**
  31703. * Creates a Solid Particle object.
  31704. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31705. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31706. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31707. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31708. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31709. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31710. * @param shapeId (integer) is the model shape identifier in the SPS.
  31711. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31712. * @param sps defines the sps it is associated to
  31713. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31714. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31715. */
  31716. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31717. /**
  31718. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31719. * @param target the particle target
  31720. * @returns the current particle
  31721. */
  31722. copyToRef(target: SolidParticle): SolidParticle;
  31723. /**
  31724. * Legacy support, changed scale to scaling
  31725. */
  31726. get scale(): Vector3;
  31727. /**
  31728. * Legacy support, changed scale to scaling
  31729. */
  31730. set scale(scale: Vector3);
  31731. /**
  31732. * Legacy support, changed quaternion to rotationQuaternion
  31733. */
  31734. get quaternion(): Nullable<Quaternion>;
  31735. /**
  31736. * Legacy support, changed quaternion to rotationQuaternion
  31737. */
  31738. set quaternion(q: Nullable<Quaternion>);
  31739. /**
  31740. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31741. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31742. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31743. * @returns true if it intersects
  31744. */
  31745. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31746. /**
  31747. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31748. * A particle is in the frustum if its bounding box intersects the frustum
  31749. * @param frustumPlanes defines the frustum to test
  31750. * @returns true if the particle is in the frustum planes
  31751. */
  31752. isInFrustum(frustumPlanes: Plane[]): boolean;
  31753. /**
  31754. * get the rotation matrix of the particle
  31755. * @hidden
  31756. */
  31757. getRotationMatrix(m: Matrix): void;
  31758. }
  31759. /**
  31760. * Represents the shape of the model used by one particle of a solid particle system.
  31761. * SPS internal tool, don't use it manually.
  31762. */
  31763. export class ModelShape {
  31764. /**
  31765. * The shape id
  31766. * @hidden
  31767. */
  31768. shapeID: number;
  31769. /**
  31770. * flat array of model positions (internal use)
  31771. * @hidden
  31772. */
  31773. _shape: Vector3[];
  31774. /**
  31775. * flat array of model UVs (internal use)
  31776. * @hidden
  31777. */
  31778. _shapeUV: number[];
  31779. /**
  31780. * color array of the model
  31781. * @hidden
  31782. */
  31783. _shapeColors: number[];
  31784. /**
  31785. * indices array of the model
  31786. * @hidden
  31787. */
  31788. _indices: number[];
  31789. /**
  31790. * normals array of the model
  31791. * @hidden
  31792. */
  31793. _normals: number[];
  31794. /**
  31795. * length of the shape in the model indices array (internal use)
  31796. * @hidden
  31797. */
  31798. _indicesLength: number;
  31799. /**
  31800. * Custom position function (internal use)
  31801. * @hidden
  31802. */
  31803. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31804. /**
  31805. * Custom vertex function (internal use)
  31806. * @hidden
  31807. */
  31808. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31809. /**
  31810. * Model material (internal use)
  31811. * @hidden
  31812. */
  31813. _material: Nullable<Material>;
  31814. /**
  31815. * 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.
  31816. * SPS internal tool, don't use it manually.
  31817. * @hidden
  31818. */
  31819. 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>);
  31820. }
  31821. /**
  31822. * Represents a Depth Sorted Particle in the solid particle system.
  31823. * @hidden
  31824. */
  31825. export class DepthSortedParticle {
  31826. /**
  31827. * Particle index
  31828. */
  31829. idx: number;
  31830. /**
  31831. * Index of the particle in the "indices" array
  31832. */
  31833. ind: number;
  31834. /**
  31835. * Length of the particle shape in the "indices" array
  31836. */
  31837. indicesLength: number;
  31838. /**
  31839. * Squared distance from the particle to the camera
  31840. */
  31841. sqDistance: number;
  31842. /**
  31843. * Material index when used with MultiMaterials
  31844. */
  31845. materialIndex: number;
  31846. /**
  31847. * Creates a new sorted particle
  31848. * @param materialIndex
  31849. */
  31850. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31851. }
  31852. /**
  31853. * Represents a solid particle vertex
  31854. */
  31855. export class SolidParticleVertex {
  31856. /**
  31857. * Vertex position
  31858. */
  31859. position: Vector3;
  31860. /**
  31861. * Vertex color
  31862. */
  31863. color: Color4;
  31864. /**
  31865. * Vertex UV
  31866. */
  31867. uv: Vector2;
  31868. /**
  31869. * Creates a new solid particle vertex
  31870. */
  31871. constructor();
  31872. /** Vertex x coordinate */
  31873. get x(): number;
  31874. set x(val: number);
  31875. /** Vertex y coordinate */
  31876. get y(): number;
  31877. set y(val: number);
  31878. /** Vertex z coordinate */
  31879. get z(): number;
  31880. set z(val: number);
  31881. }
  31882. }
  31883. declare module BABYLON {
  31884. /**
  31885. * @hidden
  31886. */
  31887. export class _MeshCollisionData {
  31888. _checkCollisions: boolean;
  31889. _collisionMask: number;
  31890. _collisionGroup: number;
  31891. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31892. _collider: Nullable<Collider>;
  31893. _oldPositionForCollisions: Vector3;
  31894. _diffPositionForCollisions: Vector3;
  31895. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31896. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31897. }
  31898. }
  31899. declare module BABYLON {
  31900. /** @hidden */
  31901. class _FacetDataStorage {
  31902. facetPositions: Vector3[];
  31903. facetNormals: Vector3[];
  31904. facetPartitioning: number[][];
  31905. facetNb: number;
  31906. partitioningSubdivisions: number;
  31907. partitioningBBoxRatio: number;
  31908. facetDataEnabled: boolean;
  31909. facetParameters: any;
  31910. bbSize: Vector3;
  31911. subDiv: {
  31912. max: number;
  31913. X: number;
  31914. Y: number;
  31915. Z: number;
  31916. };
  31917. facetDepthSort: boolean;
  31918. facetDepthSortEnabled: boolean;
  31919. depthSortedIndices: IndicesArray;
  31920. depthSortedFacets: {
  31921. ind: number;
  31922. sqDistance: number;
  31923. }[];
  31924. facetDepthSortFunction: (f1: {
  31925. ind: number;
  31926. sqDistance: number;
  31927. }, f2: {
  31928. ind: number;
  31929. sqDistance: number;
  31930. }) => number;
  31931. facetDepthSortFrom: Vector3;
  31932. facetDepthSortOrigin: Vector3;
  31933. invertedMatrix: Matrix;
  31934. }
  31935. /**
  31936. * @hidden
  31937. **/
  31938. class _InternalAbstractMeshDataInfo {
  31939. _hasVertexAlpha: boolean;
  31940. _useVertexColors: boolean;
  31941. _numBoneInfluencers: number;
  31942. _applyFog: boolean;
  31943. _receiveShadows: boolean;
  31944. _facetData: _FacetDataStorage;
  31945. _visibility: number;
  31946. _skeleton: Nullable<Skeleton>;
  31947. _layerMask: number;
  31948. _computeBonesUsingShaders: boolean;
  31949. _isActive: boolean;
  31950. _onlyForInstances: boolean;
  31951. _isActiveIntermediate: boolean;
  31952. _onlyForInstancesIntermediate: boolean;
  31953. _actAsRegularMesh: boolean;
  31954. }
  31955. /**
  31956. * Class used to store all common mesh properties
  31957. */
  31958. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31959. /** No occlusion */
  31960. static OCCLUSION_TYPE_NONE: number;
  31961. /** Occlusion set to optimisitic */
  31962. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31963. /** Occlusion set to strict */
  31964. static OCCLUSION_TYPE_STRICT: number;
  31965. /** Use an accurante occlusion algorithm */
  31966. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31967. /** Use a conservative occlusion algorithm */
  31968. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31969. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31970. * Test order :
  31971. * Is the bounding sphere outside the frustum ?
  31972. * If not, are the bounding box vertices outside the frustum ?
  31973. * It not, then the cullable object is in the frustum.
  31974. */
  31975. static readonly CULLINGSTRATEGY_STANDARD: number;
  31976. /** Culling strategy : Bounding Sphere Only.
  31977. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31978. * It's also less accurate than the standard because some not visible objects can still be selected.
  31979. * Test : is the bounding sphere outside the frustum ?
  31980. * If not, then the cullable object is in the frustum.
  31981. */
  31982. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31983. /** Culling strategy : Optimistic Inclusion.
  31984. * This in an inclusion test first, then the standard exclusion test.
  31985. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31986. * 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.
  31987. * Anyway, it's as accurate as the standard strategy.
  31988. * Test :
  31989. * Is the cullable object bounding sphere center in the frustum ?
  31990. * If not, apply the default culling strategy.
  31991. */
  31992. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31993. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31994. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31995. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31996. * 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.
  31997. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31998. * Test :
  31999. * Is the cullable object bounding sphere center in the frustum ?
  32000. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32001. */
  32002. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32003. /**
  32004. * No billboard
  32005. */
  32006. static get BILLBOARDMODE_NONE(): number;
  32007. /** Billboard on X axis */
  32008. static get BILLBOARDMODE_X(): number;
  32009. /** Billboard on Y axis */
  32010. static get BILLBOARDMODE_Y(): number;
  32011. /** Billboard on Z axis */
  32012. static get BILLBOARDMODE_Z(): number;
  32013. /** Billboard on all axes */
  32014. static get BILLBOARDMODE_ALL(): number;
  32015. /** Billboard on using position instead of orientation */
  32016. static get BILLBOARDMODE_USE_POSITION(): number;
  32017. /** @hidden */
  32018. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32019. /**
  32020. * The culling strategy to use to check whether the mesh must be rendered or not.
  32021. * This value can be changed at any time and will be used on the next render mesh selection.
  32022. * The possible values are :
  32023. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32024. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32025. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32026. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32027. * Please read each static variable documentation to get details about the culling process.
  32028. * */
  32029. cullingStrategy: number;
  32030. /**
  32031. * Gets the number of facets in the mesh
  32032. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32033. */
  32034. get facetNb(): number;
  32035. /**
  32036. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32037. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32038. */
  32039. get partitioningSubdivisions(): number;
  32040. set partitioningSubdivisions(nb: number);
  32041. /**
  32042. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32043. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32044. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32045. */
  32046. get partitioningBBoxRatio(): number;
  32047. set partitioningBBoxRatio(ratio: number);
  32048. /**
  32049. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32050. * Works only for updatable meshes.
  32051. * Doesn't work with multi-materials
  32052. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32053. */
  32054. get mustDepthSortFacets(): boolean;
  32055. set mustDepthSortFacets(sort: boolean);
  32056. /**
  32057. * The location (Vector3) where the facet depth sort must be computed from.
  32058. * By default, the active camera position.
  32059. * Used only when facet depth sort is enabled
  32060. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32061. */
  32062. get facetDepthSortFrom(): Vector3;
  32063. set facetDepthSortFrom(location: Vector3);
  32064. /**
  32065. * gets a boolean indicating if facetData is enabled
  32066. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32067. */
  32068. get isFacetDataEnabled(): boolean;
  32069. /** @hidden */
  32070. _updateNonUniformScalingState(value: boolean): boolean;
  32071. /**
  32072. * An event triggered when this mesh collides with another one
  32073. */
  32074. onCollideObservable: Observable<AbstractMesh>;
  32075. /** Set a function to call when this mesh collides with another one */
  32076. set onCollide(callback: () => void);
  32077. /**
  32078. * An event triggered when the collision's position changes
  32079. */
  32080. onCollisionPositionChangeObservable: Observable<Vector3>;
  32081. /** Set a function to call when the collision's position changes */
  32082. set onCollisionPositionChange(callback: () => void);
  32083. /**
  32084. * An event triggered when material is changed
  32085. */
  32086. onMaterialChangedObservable: Observable<AbstractMesh>;
  32087. /**
  32088. * Gets or sets the orientation for POV movement & rotation
  32089. */
  32090. definedFacingForward: boolean;
  32091. /** @hidden */
  32092. _occlusionQuery: Nullable<WebGLQuery>;
  32093. /** @hidden */
  32094. _renderingGroup: Nullable<RenderingGroup>;
  32095. /**
  32096. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32097. */
  32098. get visibility(): number;
  32099. /**
  32100. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32101. */
  32102. set visibility(value: number);
  32103. /** Gets or sets the alpha index used to sort transparent meshes
  32104. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32105. */
  32106. alphaIndex: number;
  32107. /**
  32108. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32109. */
  32110. isVisible: boolean;
  32111. /**
  32112. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32113. */
  32114. isPickable: boolean;
  32115. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32116. showSubMeshesBoundingBox: boolean;
  32117. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32118. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32119. */
  32120. isBlocker: boolean;
  32121. /**
  32122. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32123. */
  32124. enablePointerMoveEvents: boolean;
  32125. private _renderingGroupId;
  32126. /**
  32127. * Specifies the rendering group id for this mesh (0 by default)
  32128. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32129. */
  32130. get renderingGroupId(): number;
  32131. set renderingGroupId(value: number);
  32132. private _material;
  32133. /** Gets or sets current material */
  32134. get material(): Nullable<Material>;
  32135. set material(value: Nullable<Material>);
  32136. /**
  32137. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32138. * @see https://doc.babylonjs.com/babylon101/shadows
  32139. */
  32140. get receiveShadows(): boolean;
  32141. set receiveShadows(value: boolean);
  32142. /** Defines color to use when rendering outline */
  32143. outlineColor: Color3;
  32144. /** Define width to use when rendering outline */
  32145. outlineWidth: number;
  32146. /** Defines color to use when rendering overlay */
  32147. overlayColor: Color3;
  32148. /** Defines alpha to use when rendering overlay */
  32149. overlayAlpha: number;
  32150. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32151. get hasVertexAlpha(): boolean;
  32152. set hasVertexAlpha(value: boolean);
  32153. /** 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) */
  32154. get useVertexColors(): boolean;
  32155. set useVertexColors(value: boolean);
  32156. /**
  32157. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32158. */
  32159. get computeBonesUsingShaders(): boolean;
  32160. set computeBonesUsingShaders(value: boolean);
  32161. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32162. get numBoneInfluencers(): number;
  32163. set numBoneInfluencers(value: number);
  32164. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32165. get applyFog(): boolean;
  32166. set applyFog(value: boolean);
  32167. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32168. useOctreeForRenderingSelection: boolean;
  32169. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32170. useOctreeForPicking: boolean;
  32171. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32172. useOctreeForCollisions: boolean;
  32173. /**
  32174. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32175. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32176. */
  32177. get layerMask(): number;
  32178. set layerMask(value: number);
  32179. /**
  32180. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32181. */
  32182. alwaysSelectAsActiveMesh: boolean;
  32183. /**
  32184. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32185. */
  32186. doNotSyncBoundingInfo: boolean;
  32187. /**
  32188. * Gets or sets the current action manager
  32189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32190. */
  32191. actionManager: Nullable<AbstractActionManager>;
  32192. private _meshCollisionData;
  32193. /**
  32194. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32195. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32196. */
  32197. ellipsoid: Vector3;
  32198. /**
  32199. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32200. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32201. */
  32202. ellipsoidOffset: Vector3;
  32203. /**
  32204. * Gets or sets a collision mask used to mask collisions (default is -1).
  32205. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32206. */
  32207. get collisionMask(): number;
  32208. set collisionMask(mask: number);
  32209. /**
  32210. * Gets or sets the current collision group mask (-1 by default).
  32211. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32212. */
  32213. get collisionGroup(): number;
  32214. set collisionGroup(mask: number);
  32215. /**
  32216. * Gets or sets current surrounding meshes (null by default).
  32217. *
  32218. * By default collision detection is tested against every mesh in the scene.
  32219. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32220. * meshes will be tested for the collision.
  32221. *
  32222. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32223. */
  32224. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32225. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32226. /**
  32227. * Defines edge width used when edgesRenderer is enabled
  32228. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32229. */
  32230. edgesWidth: number;
  32231. /**
  32232. * Defines edge color used when edgesRenderer is enabled
  32233. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32234. */
  32235. edgesColor: Color4;
  32236. /** @hidden */
  32237. _edgesRenderer: Nullable<IEdgesRenderer>;
  32238. /** @hidden */
  32239. _masterMesh: Nullable<AbstractMesh>;
  32240. /** @hidden */
  32241. _boundingInfo: Nullable<BoundingInfo>;
  32242. /** @hidden */
  32243. _renderId: number;
  32244. /**
  32245. * Gets or sets the list of subMeshes
  32246. * @see https://doc.babylonjs.com/how_to/multi_materials
  32247. */
  32248. subMeshes: SubMesh[];
  32249. /** @hidden */
  32250. _intersectionsInProgress: AbstractMesh[];
  32251. /** @hidden */
  32252. _unIndexed: boolean;
  32253. /** @hidden */
  32254. _lightSources: Light[];
  32255. /** Gets the list of lights affecting that mesh */
  32256. get lightSources(): Light[];
  32257. /** @hidden */
  32258. get _positions(): Nullable<Vector3[]>;
  32259. /** @hidden */
  32260. _waitingData: {
  32261. lods: Nullable<any>;
  32262. actions: Nullable<any>;
  32263. freezeWorldMatrix: Nullable<boolean>;
  32264. };
  32265. /** @hidden */
  32266. _bonesTransformMatrices: Nullable<Float32Array>;
  32267. /** @hidden */
  32268. _transformMatrixTexture: Nullable<RawTexture>;
  32269. /**
  32270. * Gets or sets a skeleton to apply skining transformations
  32271. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32272. */
  32273. set skeleton(value: Nullable<Skeleton>);
  32274. get skeleton(): Nullable<Skeleton>;
  32275. /**
  32276. * An event triggered when the mesh is rebuilt.
  32277. */
  32278. onRebuildObservable: Observable<AbstractMesh>;
  32279. /**
  32280. * Creates a new AbstractMesh
  32281. * @param name defines the name of the mesh
  32282. * @param scene defines the hosting scene
  32283. */
  32284. constructor(name: string, scene?: Nullable<Scene>);
  32285. /**
  32286. * Returns the string "AbstractMesh"
  32287. * @returns "AbstractMesh"
  32288. */
  32289. getClassName(): string;
  32290. /**
  32291. * Gets a string representation of the current mesh
  32292. * @param fullDetails defines a boolean indicating if full details must be included
  32293. * @returns a string representation of the current mesh
  32294. */
  32295. toString(fullDetails?: boolean): string;
  32296. /**
  32297. * @hidden
  32298. */
  32299. protected _getEffectiveParent(): Nullable<Node>;
  32300. /** @hidden */
  32301. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32302. /** @hidden */
  32303. _rebuild(): void;
  32304. /** @hidden */
  32305. _resyncLightSources(): void;
  32306. /** @hidden */
  32307. _resyncLightSource(light: Light): void;
  32308. /** @hidden */
  32309. _unBindEffect(): void;
  32310. /** @hidden */
  32311. _removeLightSource(light: Light, dispose: boolean): void;
  32312. private _markSubMeshesAsDirty;
  32313. /** @hidden */
  32314. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32315. /** @hidden */
  32316. _markSubMeshesAsAttributesDirty(): void;
  32317. /** @hidden */
  32318. _markSubMeshesAsMiscDirty(): void;
  32319. /**
  32320. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32321. */
  32322. get scaling(): Vector3;
  32323. set scaling(newScaling: Vector3);
  32324. /**
  32325. * Returns true if the mesh is blocked. Implemented by child classes
  32326. */
  32327. get isBlocked(): boolean;
  32328. /**
  32329. * Returns the mesh itself by default. Implemented by child classes
  32330. * @param camera defines the camera to use to pick the right LOD level
  32331. * @returns the currentAbstractMesh
  32332. */
  32333. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32334. /**
  32335. * Returns 0 by default. Implemented by child classes
  32336. * @returns an integer
  32337. */
  32338. getTotalVertices(): number;
  32339. /**
  32340. * Returns a positive integer : the total number of indices in this mesh geometry.
  32341. * @returns the numner of indices or zero if the mesh has no geometry.
  32342. */
  32343. getTotalIndices(): number;
  32344. /**
  32345. * Returns null by default. Implemented by child classes
  32346. * @returns null
  32347. */
  32348. getIndices(): Nullable<IndicesArray>;
  32349. /**
  32350. * Returns the array of the requested vertex data kind. Implemented by child classes
  32351. * @param kind defines the vertex data kind to use
  32352. * @returns null
  32353. */
  32354. getVerticesData(kind: string): Nullable<FloatArray>;
  32355. /**
  32356. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32357. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32358. * Note that a new underlying VertexBuffer object is created each call.
  32359. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32360. * @param kind defines vertex data kind:
  32361. * * VertexBuffer.PositionKind
  32362. * * VertexBuffer.UVKind
  32363. * * VertexBuffer.UV2Kind
  32364. * * VertexBuffer.UV3Kind
  32365. * * VertexBuffer.UV4Kind
  32366. * * VertexBuffer.UV5Kind
  32367. * * VertexBuffer.UV6Kind
  32368. * * VertexBuffer.ColorKind
  32369. * * VertexBuffer.MatricesIndicesKind
  32370. * * VertexBuffer.MatricesIndicesExtraKind
  32371. * * VertexBuffer.MatricesWeightsKind
  32372. * * VertexBuffer.MatricesWeightsExtraKind
  32373. * @param data defines the data source
  32374. * @param updatable defines if the data must be flagged as updatable (or static)
  32375. * @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
  32376. * @returns the current mesh
  32377. */
  32378. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32379. /**
  32380. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32381. * If the mesh has no geometry, it is simply returned as it is.
  32382. * @param kind defines vertex data kind:
  32383. * * VertexBuffer.PositionKind
  32384. * * VertexBuffer.UVKind
  32385. * * VertexBuffer.UV2Kind
  32386. * * VertexBuffer.UV3Kind
  32387. * * VertexBuffer.UV4Kind
  32388. * * VertexBuffer.UV5Kind
  32389. * * VertexBuffer.UV6Kind
  32390. * * VertexBuffer.ColorKind
  32391. * * VertexBuffer.MatricesIndicesKind
  32392. * * VertexBuffer.MatricesIndicesExtraKind
  32393. * * VertexBuffer.MatricesWeightsKind
  32394. * * VertexBuffer.MatricesWeightsExtraKind
  32395. * @param data defines the data source
  32396. * @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
  32397. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32398. * @returns the current mesh
  32399. */
  32400. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32401. /**
  32402. * Sets the mesh indices,
  32403. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32404. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32405. * @param totalVertices Defines the total number of vertices
  32406. * @returns the current mesh
  32407. */
  32408. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32409. /**
  32410. * Gets a boolean indicating if specific vertex data is present
  32411. * @param kind defines the vertex data kind to use
  32412. * @returns true is data kind is present
  32413. */
  32414. isVerticesDataPresent(kind: string): boolean;
  32415. /**
  32416. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32417. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32418. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32419. * @returns a BoundingInfo
  32420. */
  32421. getBoundingInfo(): BoundingInfo;
  32422. /**
  32423. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32424. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32425. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32426. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32427. * @returns the current mesh
  32428. */
  32429. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32430. /**
  32431. * Overwrite the current bounding info
  32432. * @param boundingInfo defines the new bounding info
  32433. * @returns the current mesh
  32434. */
  32435. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32436. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32437. get useBones(): boolean;
  32438. /** @hidden */
  32439. _preActivate(): void;
  32440. /** @hidden */
  32441. _preActivateForIntermediateRendering(renderId: number): void;
  32442. /** @hidden */
  32443. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32444. /** @hidden */
  32445. _postActivate(): void;
  32446. /** @hidden */
  32447. _freeze(): void;
  32448. /** @hidden */
  32449. _unFreeze(): void;
  32450. /**
  32451. * Gets the current world matrix
  32452. * @returns a Matrix
  32453. */
  32454. getWorldMatrix(): Matrix;
  32455. /** @hidden */
  32456. _getWorldMatrixDeterminant(): number;
  32457. /**
  32458. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32459. */
  32460. get isAnInstance(): boolean;
  32461. /**
  32462. * Gets a boolean indicating if this mesh has instances
  32463. */
  32464. get hasInstances(): boolean;
  32465. /**
  32466. * Gets a boolean indicating if this mesh has thin instances
  32467. */
  32468. get hasThinInstances(): boolean;
  32469. /**
  32470. * Perform relative position change from the point of view of behind the front of the mesh.
  32471. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32472. * Supports definition of mesh facing forward or backward
  32473. * @param amountRight defines the distance on the right axis
  32474. * @param amountUp defines the distance on the up axis
  32475. * @param amountForward defines the distance on the forward axis
  32476. * @returns the current mesh
  32477. */
  32478. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32479. /**
  32480. * Calculate relative position change from the point of view of behind the front of the mesh.
  32481. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32482. * Supports definition of mesh facing forward or backward
  32483. * @param amountRight defines the distance on the right axis
  32484. * @param amountUp defines the distance on the up axis
  32485. * @param amountForward defines the distance on the forward axis
  32486. * @returns the new displacement vector
  32487. */
  32488. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32489. /**
  32490. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32491. * Supports definition of mesh facing forward or backward
  32492. * @param flipBack defines the flip
  32493. * @param twirlClockwise defines the twirl
  32494. * @param tiltRight defines the tilt
  32495. * @returns the current mesh
  32496. */
  32497. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32498. /**
  32499. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32500. * Supports definition of mesh facing forward or backward.
  32501. * @param flipBack defines the flip
  32502. * @param twirlClockwise defines the twirl
  32503. * @param tiltRight defines the tilt
  32504. * @returns the new rotation vector
  32505. */
  32506. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32507. /**
  32508. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32509. * This means the mesh underlying bounding box and sphere are recomputed.
  32510. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32511. * @returns the current mesh
  32512. */
  32513. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32514. /** @hidden */
  32515. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32516. /** @hidden */
  32517. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32518. /** @hidden */
  32519. _updateBoundingInfo(): AbstractMesh;
  32520. /** @hidden */
  32521. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32522. /** @hidden */
  32523. protected _afterComputeWorldMatrix(): void;
  32524. /** @hidden */
  32525. get _effectiveMesh(): AbstractMesh;
  32526. /**
  32527. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32528. * A mesh is in the frustum if its bounding box intersects the frustum
  32529. * @param frustumPlanes defines the frustum to test
  32530. * @returns true if the mesh is in the frustum planes
  32531. */
  32532. isInFrustum(frustumPlanes: Plane[]): boolean;
  32533. /**
  32534. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32535. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32536. * @param frustumPlanes defines the frustum to test
  32537. * @returns true if the mesh is completely in the frustum planes
  32538. */
  32539. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32540. /**
  32541. * True if the mesh intersects another mesh or a SolidParticle object
  32542. * @param mesh defines a target mesh or SolidParticle to test
  32543. * @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)
  32544. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32545. * @returns true if there is an intersection
  32546. */
  32547. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32548. /**
  32549. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32550. * @param point defines the point to test
  32551. * @returns true if there is an intersection
  32552. */
  32553. intersectsPoint(point: Vector3): boolean;
  32554. /**
  32555. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32556. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32557. */
  32558. get checkCollisions(): boolean;
  32559. set checkCollisions(collisionEnabled: boolean);
  32560. /**
  32561. * Gets Collider object used to compute collisions (not physics)
  32562. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32563. */
  32564. get collider(): Nullable<Collider>;
  32565. /**
  32566. * Move the mesh using collision engine
  32567. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32568. * @param displacement defines the requested displacement vector
  32569. * @returns the current mesh
  32570. */
  32571. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32572. private _onCollisionPositionChange;
  32573. /** @hidden */
  32574. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32575. /** @hidden */
  32576. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32577. /** @hidden */
  32578. _checkCollision(collider: Collider): AbstractMesh;
  32579. /** @hidden */
  32580. _generatePointsArray(): boolean;
  32581. /**
  32582. * Checks if the passed Ray intersects with the mesh
  32583. * @param ray defines the ray to use
  32584. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32585. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32586. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32587. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32588. * @returns the picking info
  32589. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32590. */
  32591. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32592. /**
  32593. * Clones the current mesh
  32594. * @param name defines the mesh name
  32595. * @param newParent defines the new mesh parent
  32596. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32597. * @returns the new mesh
  32598. */
  32599. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32600. /**
  32601. * Disposes all the submeshes of the current meshnp
  32602. * @returns the current mesh
  32603. */
  32604. releaseSubMeshes(): AbstractMesh;
  32605. /**
  32606. * Releases resources associated with this abstract mesh.
  32607. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32608. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32609. */
  32610. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32611. /**
  32612. * Adds the passed mesh as a child to the current mesh
  32613. * @param mesh defines the child mesh
  32614. * @returns the current mesh
  32615. */
  32616. addChild(mesh: AbstractMesh): AbstractMesh;
  32617. /**
  32618. * Removes the passed mesh from the current mesh children list
  32619. * @param mesh defines the child mesh
  32620. * @returns the current mesh
  32621. */
  32622. removeChild(mesh: AbstractMesh): AbstractMesh;
  32623. /** @hidden */
  32624. private _initFacetData;
  32625. /**
  32626. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32627. * This method can be called within the render loop.
  32628. * 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
  32629. * @returns the current mesh
  32630. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32631. */
  32632. updateFacetData(): AbstractMesh;
  32633. /**
  32634. * Returns the facetLocalNormals array.
  32635. * The normals are expressed in the mesh local spac
  32636. * @returns an array of Vector3
  32637. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32638. */
  32639. getFacetLocalNormals(): Vector3[];
  32640. /**
  32641. * Returns the facetLocalPositions array.
  32642. * The facet positions are expressed in the mesh local space
  32643. * @returns an array of Vector3
  32644. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32645. */
  32646. getFacetLocalPositions(): Vector3[];
  32647. /**
  32648. * Returns the facetLocalPartioning array
  32649. * @returns an array of array of numbers
  32650. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32651. */
  32652. getFacetLocalPartitioning(): number[][];
  32653. /**
  32654. * Returns the i-th facet position in the world system.
  32655. * This method allocates a new Vector3 per call
  32656. * @param i defines the facet index
  32657. * @returns a new Vector3
  32658. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32659. */
  32660. getFacetPosition(i: number): Vector3;
  32661. /**
  32662. * Sets the reference Vector3 with the i-th facet position in the world system
  32663. * @param i defines the facet index
  32664. * @param ref defines the target vector
  32665. * @returns the current mesh
  32666. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32667. */
  32668. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32669. /**
  32670. * Returns the i-th facet normal in the world system.
  32671. * This method allocates a new Vector3 per call
  32672. * @param i defines the facet index
  32673. * @returns a new Vector3
  32674. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32675. */
  32676. getFacetNormal(i: number): Vector3;
  32677. /**
  32678. * Sets the reference Vector3 with the i-th facet normal in the world system
  32679. * @param i defines the facet index
  32680. * @param ref defines the target vector
  32681. * @returns the current mesh
  32682. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32683. */
  32684. getFacetNormalToRef(i: number, ref: Vector3): this;
  32685. /**
  32686. * 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)
  32687. * @param x defines x coordinate
  32688. * @param y defines y coordinate
  32689. * @param z defines z coordinate
  32690. * @returns the array of facet indexes
  32691. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32692. */
  32693. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32694. /**
  32695. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32696. * @param projected sets as the (x,y,z) world projection on the facet
  32697. * @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
  32698. * @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
  32699. * @param x defines x coordinate
  32700. * @param y defines y coordinate
  32701. * @param z defines z coordinate
  32702. * @returns the face index if found (or null instead)
  32703. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32704. */
  32705. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32706. /**
  32707. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32708. * @param projected sets as the (x,y,z) local projection on the facet
  32709. * @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
  32710. * @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
  32711. * @param x defines x coordinate
  32712. * @param y defines y coordinate
  32713. * @param z defines z coordinate
  32714. * @returns the face index if found (or null instead)
  32715. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32716. */
  32717. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32718. /**
  32719. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32720. * @returns the parameters
  32721. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32722. */
  32723. getFacetDataParameters(): any;
  32724. /**
  32725. * Disables the feature FacetData and frees the related memory
  32726. * @returns the current mesh
  32727. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32728. */
  32729. disableFacetData(): AbstractMesh;
  32730. /**
  32731. * Updates the AbstractMesh indices array
  32732. * @param indices defines the data source
  32733. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32734. * @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)
  32735. * @returns the current mesh
  32736. */
  32737. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32738. /**
  32739. * Creates new normals data for the mesh
  32740. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32741. * @returns the current mesh
  32742. */
  32743. createNormals(updatable: boolean): AbstractMesh;
  32744. /**
  32745. * Align the mesh with a normal
  32746. * @param normal defines the normal to use
  32747. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32748. * @returns the current mesh
  32749. */
  32750. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32751. /** @hidden */
  32752. _checkOcclusionQuery(): boolean;
  32753. /**
  32754. * Disables the mesh edge rendering mode
  32755. * @returns the currentAbstractMesh
  32756. */
  32757. disableEdgesRendering(): AbstractMesh;
  32758. /**
  32759. * Enables the edge rendering mode on the mesh.
  32760. * This mode makes the mesh edges visible
  32761. * @param epsilon defines the maximal distance between two angles to detect a face
  32762. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32763. * @returns the currentAbstractMesh
  32764. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32765. */
  32766. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32767. /**
  32768. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32769. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32770. */
  32771. getConnectedParticleSystems(): IParticleSystem[];
  32772. }
  32773. }
  32774. declare module BABYLON {
  32775. /**
  32776. * Interface used to define ActionEvent
  32777. */
  32778. export interface IActionEvent {
  32779. /** The mesh or sprite that triggered the action */
  32780. source: any;
  32781. /** The X mouse cursor position at the time of the event */
  32782. pointerX: number;
  32783. /** The Y mouse cursor position at the time of the event */
  32784. pointerY: number;
  32785. /** The mesh that is currently pointed at (can be null) */
  32786. meshUnderPointer: Nullable<AbstractMesh>;
  32787. /** the original (browser) event that triggered the ActionEvent */
  32788. sourceEvent?: any;
  32789. /** additional data for the event */
  32790. additionalData?: any;
  32791. }
  32792. /**
  32793. * ActionEvent is the event being sent when an action is triggered.
  32794. */
  32795. export class ActionEvent implements IActionEvent {
  32796. /** The mesh or sprite that triggered the action */
  32797. source: any;
  32798. /** The X mouse cursor position at the time of the event */
  32799. pointerX: number;
  32800. /** The Y mouse cursor position at the time of the event */
  32801. pointerY: number;
  32802. /** The mesh that is currently pointed at (can be null) */
  32803. meshUnderPointer: Nullable<AbstractMesh>;
  32804. /** the original (browser) event that triggered the ActionEvent */
  32805. sourceEvent?: any;
  32806. /** additional data for the event */
  32807. additionalData?: any;
  32808. /**
  32809. * Creates a new ActionEvent
  32810. * @param source The mesh or sprite that triggered the action
  32811. * @param pointerX The X mouse cursor position at the time of the event
  32812. * @param pointerY The Y mouse cursor position at the time of the event
  32813. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32814. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32815. * @param additionalData additional data for the event
  32816. */
  32817. constructor(
  32818. /** The mesh or sprite that triggered the action */
  32819. source: any,
  32820. /** The X mouse cursor position at the time of the event */
  32821. pointerX: number,
  32822. /** The Y mouse cursor position at the time of the event */
  32823. pointerY: number,
  32824. /** The mesh that is currently pointed at (can be null) */
  32825. meshUnderPointer: Nullable<AbstractMesh>,
  32826. /** the original (browser) event that triggered the ActionEvent */
  32827. sourceEvent?: any,
  32828. /** additional data for the event */
  32829. additionalData?: any);
  32830. /**
  32831. * Helper function to auto-create an ActionEvent from a source mesh.
  32832. * @param source The source mesh that triggered the event
  32833. * @param evt The original (browser) event
  32834. * @param additionalData additional data for the event
  32835. * @returns the new ActionEvent
  32836. */
  32837. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32838. /**
  32839. * Helper function to auto-create an ActionEvent from a source sprite
  32840. * @param source The source sprite that triggered the event
  32841. * @param scene Scene associated with the sprite
  32842. * @param evt The original (browser) event
  32843. * @param additionalData additional data for the event
  32844. * @returns the new ActionEvent
  32845. */
  32846. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32847. /**
  32848. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32849. * @param scene the scene where the event occurred
  32850. * @param evt The original (browser) event
  32851. * @returns the new ActionEvent
  32852. */
  32853. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32854. /**
  32855. * Helper function to auto-create an ActionEvent from a primitive
  32856. * @param prim defines the target primitive
  32857. * @param pointerPos defines the pointer position
  32858. * @param evt The original (browser) event
  32859. * @param additionalData additional data for the event
  32860. * @returns the new ActionEvent
  32861. */
  32862. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32863. }
  32864. }
  32865. declare module BABYLON {
  32866. /**
  32867. * Abstract class used to decouple action Manager from scene and meshes.
  32868. * Do not instantiate.
  32869. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32870. */
  32871. export abstract class AbstractActionManager implements IDisposable {
  32872. /** Gets the list of active triggers */
  32873. static Triggers: {
  32874. [key: string]: number;
  32875. };
  32876. /** Gets the cursor to use when hovering items */
  32877. hoverCursor: string;
  32878. /** Gets the list of actions */
  32879. actions: IAction[];
  32880. /**
  32881. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32882. */
  32883. isRecursive: boolean;
  32884. /**
  32885. * Releases all associated resources
  32886. */
  32887. abstract dispose(): void;
  32888. /**
  32889. * Does this action manager has pointer triggers
  32890. */
  32891. abstract get hasPointerTriggers(): boolean;
  32892. /**
  32893. * Does this action manager has pick triggers
  32894. */
  32895. abstract get hasPickTriggers(): boolean;
  32896. /**
  32897. * Process a specific trigger
  32898. * @param trigger defines the trigger to process
  32899. * @param evt defines the event details to be processed
  32900. */
  32901. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32902. /**
  32903. * Does this action manager handles actions of any of the given triggers
  32904. * @param triggers defines the triggers to be tested
  32905. * @return a boolean indicating whether one (or more) of the triggers is handled
  32906. */
  32907. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32908. /**
  32909. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32910. * speed.
  32911. * @param triggerA defines the trigger to be tested
  32912. * @param triggerB defines the trigger to be tested
  32913. * @return a boolean indicating whether one (or more) of the triggers is handled
  32914. */
  32915. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32916. /**
  32917. * Does this action manager handles actions of a given trigger
  32918. * @param trigger defines the trigger to be tested
  32919. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32920. * @return whether the trigger is handled
  32921. */
  32922. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32923. /**
  32924. * Serialize this manager to a JSON object
  32925. * @param name defines the property name to store this manager
  32926. * @returns a JSON representation of this manager
  32927. */
  32928. abstract serialize(name: string): any;
  32929. /**
  32930. * Registers an action to this action manager
  32931. * @param action defines the action to be registered
  32932. * @return the action amended (prepared) after registration
  32933. */
  32934. abstract registerAction(action: IAction): Nullable<IAction>;
  32935. /**
  32936. * Unregisters an action to this action manager
  32937. * @param action defines the action to be unregistered
  32938. * @return a boolean indicating whether the action has been unregistered
  32939. */
  32940. abstract unregisterAction(action: IAction): Boolean;
  32941. /**
  32942. * Does exist one action manager with at least one trigger
  32943. **/
  32944. static get HasTriggers(): boolean;
  32945. /**
  32946. * Does exist one action manager with at least one pick trigger
  32947. **/
  32948. static get HasPickTriggers(): boolean;
  32949. /**
  32950. * Does exist one action manager that handles actions of a given trigger
  32951. * @param trigger defines the trigger to be tested
  32952. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32953. **/
  32954. static HasSpecificTrigger(trigger: number): boolean;
  32955. }
  32956. }
  32957. declare module BABYLON {
  32958. /**
  32959. * Defines how a node can be built from a string name.
  32960. */
  32961. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32962. /**
  32963. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32964. */
  32965. export class Node implements IBehaviorAware<Node> {
  32966. /** @hidden */
  32967. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32968. private static _NodeConstructors;
  32969. /**
  32970. * Add a new node constructor
  32971. * @param type defines the type name of the node to construct
  32972. * @param constructorFunc defines the constructor function
  32973. */
  32974. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32975. /**
  32976. * Returns a node constructor based on type name
  32977. * @param type defines the type name
  32978. * @param name defines the new node name
  32979. * @param scene defines the hosting scene
  32980. * @param options defines optional options to transmit to constructors
  32981. * @returns the new constructor or null
  32982. */
  32983. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32984. /**
  32985. * Gets or sets the name of the node
  32986. */
  32987. name: string;
  32988. /**
  32989. * Gets or sets the id of the node
  32990. */
  32991. id: string;
  32992. /**
  32993. * Gets or sets the unique id of the node
  32994. */
  32995. uniqueId: number;
  32996. /**
  32997. * Gets or sets a string used to store user defined state for the node
  32998. */
  32999. state: string;
  33000. /**
  33001. * Gets or sets an object used to store user defined information for the node
  33002. */
  33003. metadata: any;
  33004. /**
  33005. * For internal use only. Please do not use.
  33006. */
  33007. reservedDataStore: any;
  33008. /**
  33009. * List of inspectable custom properties (used by the Inspector)
  33010. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33011. */
  33012. inspectableCustomProperties: IInspectable[];
  33013. private _doNotSerialize;
  33014. /**
  33015. * Gets or sets a boolean used to define if the node must be serialized
  33016. */
  33017. get doNotSerialize(): boolean;
  33018. set doNotSerialize(value: boolean);
  33019. /** @hidden */
  33020. _isDisposed: boolean;
  33021. /**
  33022. * Gets a list of Animations associated with the node
  33023. */
  33024. animations: Animation[];
  33025. protected _ranges: {
  33026. [name: string]: Nullable<AnimationRange>;
  33027. };
  33028. /**
  33029. * Callback raised when the node is ready to be used
  33030. */
  33031. onReady: Nullable<(node: Node) => void>;
  33032. private _isEnabled;
  33033. private _isParentEnabled;
  33034. private _isReady;
  33035. /** @hidden */
  33036. _currentRenderId: number;
  33037. private _parentUpdateId;
  33038. /** @hidden */
  33039. _childUpdateId: number;
  33040. /** @hidden */
  33041. _waitingParentId: Nullable<string>;
  33042. /** @hidden */
  33043. _scene: Scene;
  33044. /** @hidden */
  33045. _cache: any;
  33046. private _parentNode;
  33047. private _children;
  33048. /** @hidden */
  33049. _worldMatrix: Matrix;
  33050. /** @hidden */
  33051. _worldMatrixDeterminant: number;
  33052. /** @hidden */
  33053. _worldMatrixDeterminantIsDirty: boolean;
  33054. /** @hidden */
  33055. private _sceneRootNodesIndex;
  33056. /**
  33057. * Gets a boolean indicating if the node has been disposed
  33058. * @returns true if the node was disposed
  33059. */
  33060. isDisposed(): boolean;
  33061. /**
  33062. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33063. * @see https://doc.babylonjs.com/how_to/parenting
  33064. */
  33065. set parent(parent: Nullable<Node>);
  33066. get parent(): Nullable<Node>;
  33067. /** @hidden */
  33068. _addToSceneRootNodes(): void;
  33069. /** @hidden */
  33070. _removeFromSceneRootNodes(): void;
  33071. private _animationPropertiesOverride;
  33072. /**
  33073. * Gets or sets the animation properties override
  33074. */
  33075. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33076. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33077. /**
  33078. * Gets a string identifying the name of the class
  33079. * @returns "Node" string
  33080. */
  33081. getClassName(): string;
  33082. /** @hidden */
  33083. readonly _isNode: boolean;
  33084. /**
  33085. * An event triggered when the mesh is disposed
  33086. */
  33087. onDisposeObservable: Observable<Node>;
  33088. private _onDisposeObserver;
  33089. /**
  33090. * Sets a callback that will be raised when the node will be disposed
  33091. */
  33092. set onDispose(callback: () => void);
  33093. /**
  33094. * Creates a new Node
  33095. * @param name the name and id to be given to this node
  33096. * @param scene the scene this node will be added to
  33097. */
  33098. constructor(name: string, scene?: Nullable<Scene>);
  33099. /**
  33100. * Gets the scene of the node
  33101. * @returns a scene
  33102. */
  33103. getScene(): Scene;
  33104. /**
  33105. * Gets the engine of the node
  33106. * @returns a Engine
  33107. */
  33108. getEngine(): Engine;
  33109. private _behaviors;
  33110. /**
  33111. * Attach a behavior to the node
  33112. * @see https://doc.babylonjs.com/features/behaviour
  33113. * @param behavior defines the behavior to attach
  33114. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33115. * @returns the current Node
  33116. */
  33117. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33118. /**
  33119. * Remove an attached behavior
  33120. * @see https://doc.babylonjs.com/features/behaviour
  33121. * @param behavior defines the behavior to attach
  33122. * @returns the current Node
  33123. */
  33124. removeBehavior(behavior: Behavior<Node>): Node;
  33125. /**
  33126. * Gets the list of attached behaviors
  33127. * @see https://doc.babylonjs.com/features/behaviour
  33128. */
  33129. get behaviors(): Behavior<Node>[];
  33130. /**
  33131. * Gets an attached behavior by name
  33132. * @param name defines the name of the behavior to look for
  33133. * @see https://doc.babylonjs.com/features/behaviour
  33134. * @returns null if behavior was not found else the requested behavior
  33135. */
  33136. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33137. /**
  33138. * Returns the latest update of the World matrix
  33139. * @returns a Matrix
  33140. */
  33141. getWorldMatrix(): Matrix;
  33142. /** @hidden */
  33143. _getWorldMatrixDeterminant(): number;
  33144. /**
  33145. * Returns directly the latest state of the mesh World matrix.
  33146. * A Matrix is returned.
  33147. */
  33148. get worldMatrixFromCache(): Matrix;
  33149. /** @hidden */
  33150. _initCache(): void;
  33151. /** @hidden */
  33152. updateCache(force?: boolean): void;
  33153. /** @hidden */
  33154. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33155. /** @hidden */
  33156. _updateCache(ignoreParentClass?: boolean): void;
  33157. /** @hidden */
  33158. _isSynchronized(): boolean;
  33159. /** @hidden */
  33160. _markSyncedWithParent(): void;
  33161. /** @hidden */
  33162. isSynchronizedWithParent(): boolean;
  33163. /** @hidden */
  33164. isSynchronized(): boolean;
  33165. /**
  33166. * Is this node ready to be used/rendered
  33167. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33168. * @return true if the node is ready
  33169. */
  33170. isReady(completeCheck?: boolean): boolean;
  33171. /**
  33172. * Is this node enabled?
  33173. * 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
  33174. * @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
  33175. * @return whether this node (and its parent) is enabled
  33176. */
  33177. isEnabled(checkAncestors?: boolean): boolean;
  33178. /** @hidden */
  33179. protected _syncParentEnabledState(): void;
  33180. /**
  33181. * Set the enabled state of this node
  33182. * @param value defines the new enabled state
  33183. */
  33184. setEnabled(value: boolean): void;
  33185. /**
  33186. * Is this node a descendant of the given node?
  33187. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33188. * @param ancestor defines the parent node to inspect
  33189. * @returns a boolean indicating if this node is a descendant of the given node
  33190. */
  33191. isDescendantOf(ancestor: Node): boolean;
  33192. /** @hidden */
  33193. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33194. /**
  33195. * Will return all nodes that have this node as ascendant
  33196. * @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
  33197. * @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
  33198. * @return all children nodes of all types
  33199. */
  33200. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33201. /**
  33202. * Get all child-meshes of this node
  33203. * @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)
  33204. * @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
  33205. * @returns an array of AbstractMesh
  33206. */
  33207. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33208. /**
  33209. * Get all direct children of this node
  33210. * @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
  33211. * @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)
  33212. * @returns an array of Node
  33213. */
  33214. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33215. /** @hidden */
  33216. _setReady(state: boolean): void;
  33217. /**
  33218. * Get an animation by name
  33219. * @param name defines the name of the animation to look for
  33220. * @returns null if not found else the requested animation
  33221. */
  33222. getAnimationByName(name: string): Nullable<Animation>;
  33223. /**
  33224. * Creates an animation range for this node
  33225. * @param name defines the name of the range
  33226. * @param from defines the starting key
  33227. * @param to defines the end key
  33228. */
  33229. createAnimationRange(name: string, from: number, to: number): void;
  33230. /**
  33231. * Delete a specific animation range
  33232. * @param name defines the name of the range to delete
  33233. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33234. */
  33235. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33236. /**
  33237. * Get an animation range by name
  33238. * @param name defines the name of the animation range to look for
  33239. * @returns null if not found else the requested animation range
  33240. */
  33241. getAnimationRange(name: string): Nullable<AnimationRange>;
  33242. /**
  33243. * Gets the list of all animation ranges defined on this node
  33244. * @returns an array
  33245. */
  33246. getAnimationRanges(): Nullable<AnimationRange>[];
  33247. /**
  33248. * Will start the animation sequence
  33249. * @param name defines the range frames for animation sequence
  33250. * @param loop defines if the animation should loop (false by default)
  33251. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33252. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33253. * @returns the object created for this animation. If range does not exist, it will return null
  33254. */
  33255. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33256. /**
  33257. * Serialize animation ranges into a JSON compatible object
  33258. * @returns serialization object
  33259. */
  33260. serializeAnimationRanges(): any;
  33261. /**
  33262. * Computes the world matrix of the node
  33263. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33264. * @returns the world matrix
  33265. */
  33266. computeWorldMatrix(force?: boolean): Matrix;
  33267. /**
  33268. * Releases resources associated with this node.
  33269. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33270. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33271. */
  33272. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33273. /**
  33274. * Parse animation range data from a serialization object and store them into a given node
  33275. * @param node defines where to store the animation ranges
  33276. * @param parsedNode defines the serialization object to read data from
  33277. * @param scene defines the hosting scene
  33278. */
  33279. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33280. /**
  33281. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33282. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33283. * @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
  33284. * @returns the new bounding vectors
  33285. */
  33286. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33287. min: Vector3;
  33288. max: Vector3;
  33289. };
  33290. }
  33291. }
  33292. declare module BABYLON {
  33293. /**
  33294. * @hidden
  33295. */
  33296. export class _IAnimationState {
  33297. key: number;
  33298. repeatCount: number;
  33299. workValue?: any;
  33300. loopMode?: number;
  33301. offsetValue?: any;
  33302. highLimitValue?: any;
  33303. }
  33304. /**
  33305. * Class used to store any kind of animation
  33306. */
  33307. export class Animation {
  33308. /**Name of the animation */
  33309. name: string;
  33310. /**Property to animate */
  33311. targetProperty: string;
  33312. /**The frames per second of the animation */
  33313. framePerSecond: number;
  33314. /**The data type of the animation */
  33315. dataType: number;
  33316. /**The loop mode of the animation */
  33317. loopMode?: number | undefined;
  33318. /**Specifies if blending should be enabled */
  33319. enableBlending?: boolean | undefined;
  33320. /**
  33321. * Use matrix interpolation instead of using direct key value when animating matrices
  33322. */
  33323. static AllowMatricesInterpolation: boolean;
  33324. /**
  33325. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33326. */
  33327. static AllowMatrixDecomposeForInterpolation: boolean;
  33328. /** Define the Url to load snippets */
  33329. static SnippetUrl: string;
  33330. /** Snippet ID if the animation was created from the snippet server */
  33331. snippetId: string;
  33332. /**
  33333. * Stores the key frames of the animation
  33334. */
  33335. private _keys;
  33336. /**
  33337. * Stores the easing function of the animation
  33338. */
  33339. private _easingFunction;
  33340. /**
  33341. * @hidden Internal use only
  33342. */
  33343. _runtimeAnimations: RuntimeAnimation[];
  33344. /**
  33345. * The set of event that will be linked to this animation
  33346. */
  33347. private _events;
  33348. /**
  33349. * Stores an array of target property paths
  33350. */
  33351. targetPropertyPath: string[];
  33352. /**
  33353. * Stores the blending speed of the animation
  33354. */
  33355. blendingSpeed: number;
  33356. /**
  33357. * Stores the animation ranges for the animation
  33358. */
  33359. private _ranges;
  33360. /**
  33361. * @hidden Internal use
  33362. */
  33363. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33364. /**
  33365. * Sets up an animation
  33366. * @param property The property to animate
  33367. * @param animationType The animation type to apply
  33368. * @param framePerSecond The frames per second of the animation
  33369. * @param easingFunction The easing function used in the animation
  33370. * @returns The created animation
  33371. */
  33372. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33373. /**
  33374. * Create and start an animation on a node
  33375. * @param name defines the name of the global animation that will be run on all nodes
  33376. * @param node defines the root node where the animation will take place
  33377. * @param targetProperty defines property to animate
  33378. * @param framePerSecond defines the number of frame per second yo use
  33379. * @param totalFrame defines the number of frames in total
  33380. * @param from defines the initial value
  33381. * @param to defines the final value
  33382. * @param loopMode defines which loop mode you want to use (off by default)
  33383. * @param easingFunction defines the easing function to use (linear by default)
  33384. * @param onAnimationEnd defines the callback to call when animation end
  33385. * @returns the animatable created for this animation
  33386. */
  33387. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33388. /**
  33389. * Create and start an animation on a node and its descendants
  33390. * @param name defines the name of the global animation that will be run on all nodes
  33391. * @param node defines the root node where the animation will take place
  33392. * @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
  33393. * @param targetProperty defines property to animate
  33394. * @param framePerSecond defines the number of frame per second to use
  33395. * @param totalFrame defines the number of frames in total
  33396. * @param from defines the initial value
  33397. * @param to defines the final value
  33398. * @param loopMode defines which loop mode you want to use (off by default)
  33399. * @param easingFunction defines the easing function to use (linear by default)
  33400. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33401. * @returns the list of animatables created for all nodes
  33402. * @example https://www.babylonjs-playground.com/#MH0VLI
  33403. */
  33404. 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[]>;
  33405. /**
  33406. * Creates a new animation, merges it with the existing animations and starts it
  33407. * @param name Name of the animation
  33408. * @param node Node which contains the scene that begins the animations
  33409. * @param targetProperty Specifies which property to animate
  33410. * @param framePerSecond The frames per second of the animation
  33411. * @param totalFrame The total number of frames
  33412. * @param from The frame at the beginning of the animation
  33413. * @param to The frame at the end of the animation
  33414. * @param loopMode Specifies the loop mode of the animation
  33415. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33416. * @param onAnimationEnd Callback to run once the animation is complete
  33417. * @returns Nullable animation
  33418. */
  33419. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33420. /**
  33421. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33422. * @param sourceAnimation defines the Animation containing keyframes to convert
  33423. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33424. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33425. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33426. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33427. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33428. */
  33429. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33430. /**
  33431. * Transition property of an host to the target Value
  33432. * @param property The property to transition
  33433. * @param targetValue The target Value of the property
  33434. * @param host The object where the property to animate belongs
  33435. * @param scene Scene used to run the animation
  33436. * @param frameRate Framerate (in frame/s) to use
  33437. * @param transition The transition type we want to use
  33438. * @param duration The duration of the animation, in milliseconds
  33439. * @param onAnimationEnd Callback trigger at the end of the animation
  33440. * @returns Nullable animation
  33441. */
  33442. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33443. /**
  33444. * Return the array of runtime animations currently using this animation
  33445. */
  33446. get runtimeAnimations(): RuntimeAnimation[];
  33447. /**
  33448. * Specifies if any of the runtime animations are currently running
  33449. */
  33450. get hasRunningRuntimeAnimations(): boolean;
  33451. /**
  33452. * Initializes the animation
  33453. * @param name Name of the animation
  33454. * @param targetProperty Property to animate
  33455. * @param framePerSecond The frames per second of the animation
  33456. * @param dataType The data type of the animation
  33457. * @param loopMode The loop mode of the animation
  33458. * @param enableBlending Specifies if blending should be enabled
  33459. */
  33460. constructor(
  33461. /**Name of the animation */
  33462. name: string,
  33463. /**Property to animate */
  33464. targetProperty: string,
  33465. /**The frames per second of the animation */
  33466. framePerSecond: number,
  33467. /**The data type of the animation */
  33468. dataType: number,
  33469. /**The loop mode of the animation */
  33470. loopMode?: number | undefined,
  33471. /**Specifies if blending should be enabled */
  33472. enableBlending?: boolean | undefined);
  33473. /**
  33474. * Converts the animation to a string
  33475. * @param fullDetails support for multiple levels of logging within scene loading
  33476. * @returns String form of the animation
  33477. */
  33478. toString(fullDetails?: boolean): string;
  33479. /**
  33480. * Add an event to this animation
  33481. * @param event Event to add
  33482. */
  33483. addEvent(event: AnimationEvent): void;
  33484. /**
  33485. * Remove all events found at the given frame
  33486. * @param frame The frame to remove events from
  33487. */
  33488. removeEvents(frame: number): void;
  33489. /**
  33490. * Retrieves all the events from the animation
  33491. * @returns Events from the animation
  33492. */
  33493. getEvents(): AnimationEvent[];
  33494. /**
  33495. * Creates an animation range
  33496. * @param name Name of the animation range
  33497. * @param from Starting frame of the animation range
  33498. * @param to Ending frame of the animation
  33499. */
  33500. createRange(name: string, from: number, to: number): void;
  33501. /**
  33502. * Deletes an animation range by name
  33503. * @param name Name of the animation range to delete
  33504. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33505. */
  33506. deleteRange(name: string, deleteFrames?: boolean): void;
  33507. /**
  33508. * Gets the animation range by name, or null if not defined
  33509. * @param name Name of the animation range
  33510. * @returns Nullable animation range
  33511. */
  33512. getRange(name: string): Nullable<AnimationRange>;
  33513. /**
  33514. * Gets the key frames from the animation
  33515. * @returns The key frames of the animation
  33516. */
  33517. getKeys(): Array<IAnimationKey>;
  33518. /**
  33519. * Gets the highest frame rate of the animation
  33520. * @returns Highest frame rate of the animation
  33521. */
  33522. getHighestFrame(): number;
  33523. /**
  33524. * Gets the easing function of the animation
  33525. * @returns Easing function of the animation
  33526. */
  33527. getEasingFunction(): IEasingFunction;
  33528. /**
  33529. * Sets the easing function of the animation
  33530. * @param easingFunction A custom mathematical formula for animation
  33531. */
  33532. setEasingFunction(easingFunction: EasingFunction): void;
  33533. /**
  33534. * Interpolates a scalar linearly
  33535. * @param startValue Start value of the animation curve
  33536. * @param endValue End value of the animation curve
  33537. * @param gradient Scalar amount to interpolate
  33538. * @returns Interpolated scalar value
  33539. */
  33540. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33541. /**
  33542. * Interpolates a scalar cubically
  33543. * @param startValue Start value of the animation curve
  33544. * @param outTangent End tangent of the animation
  33545. * @param endValue End value of the animation curve
  33546. * @param inTangent Start tangent of the animation curve
  33547. * @param gradient Scalar amount to interpolate
  33548. * @returns Interpolated scalar value
  33549. */
  33550. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33551. /**
  33552. * Interpolates a quaternion using a spherical linear interpolation
  33553. * @param startValue Start value of the animation curve
  33554. * @param endValue End value of the animation curve
  33555. * @param gradient Scalar amount to interpolate
  33556. * @returns Interpolated quaternion value
  33557. */
  33558. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33559. /**
  33560. * Interpolates a quaternion cubically
  33561. * @param startValue Start value of the animation curve
  33562. * @param outTangent End tangent of the animation curve
  33563. * @param endValue End value of the animation curve
  33564. * @param inTangent Start tangent of the animation curve
  33565. * @param gradient Scalar amount to interpolate
  33566. * @returns Interpolated quaternion value
  33567. */
  33568. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33569. /**
  33570. * Interpolates a Vector3 linearl
  33571. * @param startValue Start value of the animation curve
  33572. * @param endValue End value of the animation curve
  33573. * @param gradient Scalar amount to interpolate
  33574. * @returns Interpolated scalar value
  33575. */
  33576. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33577. /**
  33578. * Interpolates a Vector3 cubically
  33579. * @param startValue Start value of the animation curve
  33580. * @param outTangent End tangent of the animation
  33581. * @param endValue End value of the animation curve
  33582. * @param inTangent Start tangent of the animation curve
  33583. * @param gradient Scalar amount to interpolate
  33584. * @returns InterpolatedVector3 value
  33585. */
  33586. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33587. /**
  33588. * Interpolates a Vector2 linearly
  33589. * @param startValue Start value of the animation curve
  33590. * @param endValue End value of the animation curve
  33591. * @param gradient Scalar amount to interpolate
  33592. * @returns Interpolated Vector2 value
  33593. */
  33594. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33595. /**
  33596. * Interpolates a Vector2 cubically
  33597. * @param startValue Start value of the animation curve
  33598. * @param outTangent End tangent of the animation
  33599. * @param endValue End value of the animation curve
  33600. * @param inTangent Start tangent of the animation curve
  33601. * @param gradient Scalar amount to interpolate
  33602. * @returns Interpolated Vector2 value
  33603. */
  33604. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33605. /**
  33606. * Interpolates a size linearly
  33607. * @param startValue Start value of the animation curve
  33608. * @param endValue End value of the animation curve
  33609. * @param gradient Scalar amount to interpolate
  33610. * @returns Interpolated Size value
  33611. */
  33612. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33613. /**
  33614. * Interpolates a Color3 linearly
  33615. * @param startValue Start value of the animation curve
  33616. * @param endValue End value of the animation curve
  33617. * @param gradient Scalar amount to interpolate
  33618. * @returns Interpolated Color3 value
  33619. */
  33620. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33621. /**
  33622. * Interpolates a Color4 linearly
  33623. * @param startValue Start value of the animation curve
  33624. * @param endValue End value of the animation curve
  33625. * @param gradient Scalar amount to interpolate
  33626. * @returns Interpolated Color3 value
  33627. */
  33628. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33629. /**
  33630. * @hidden Internal use only
  33631. */
  33632. _getKeyValue(value: any): any;
  33633. /**
  33634. * @hidden Internal use only
  33635. */
  33636. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33637. /**
  33638. * Defines the function to use to interpolate matrices
  33639. * @param startValue defines the start matrix
  33640. * @param endValue defines the end matrix
  33641. * @param gradient defines the gradient between both matrices
  33642. * @param result defines an optional target matrix where to store the interpolation
  33643. * @returns the interpolated matrix
  33644. */
  33645. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33646. /**
  33647. * Makes a copy of the animation
  33648. * @returns Cloned animation
  33649. */
  33650. clone(): Animation;
  33651. /**
  33652. * Sets the key frames of the animation
  33653. * @param values The animation key frames to set
  33654. */
  33655. setKeys(values: Array<IAnimationKey>): void;
  33656. /**
  33657. * Serializes the animation to an object
  33658. * @returns Serialized object
  33659. */
  33660. serialize(): any;
  33661. /**
  33662. * Float animation type
  33663. */
  33664. static readonly ANIMATIONTYPE_FLOAT: number;
  33665. /**
  33666. * Vector3 animation type
  33667. */
  33668. static readonly ANIMATIONTYPE_VECTOR3: number;
  33669. /**
  33670. * Quaternion animation type
  33671. */
  33672. static readonly ANIMATIONTYPE_QUATERNION: number;
  33673. /**
  33674. * Matrix animation type
  33675. */
  33676. static readonly ANIMATIONTYPE_MATRIX: number;
  33677. /**
  33678. * Color3 animation type
  33679. */
  33680. static readonly ANIMATIONTYPE_COLOR3: number;
  33681. /**
  33682. * Color3 animation type
  33683. */
  33684. static readonly ANIMATIONTYPE_COLOR4: number;
  33685. /**
  33686. * Vector2 animation type
  33687. */
  33688. static readonly ANIMATIONTYPE_VECTOR2: number;
  33689. /**
  33690. * Size animation type
  33691. */
  33692. static readonly ANIMATIONTYPE_SIZE: number;
  33693. /**
  33694. * Relative Loop Mode
  33695. */
  33696. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33697. /**
  33698. * Cycle Loop Mode
  33699. */
  33700. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33701. /**
  33702. * Constant Loop Mode
  33703. */
  33704. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33705. /** @hidden */
  33706. static _UniversalLerp(left: any, right: any, amount: number): any;
  33707. /**
  33708. * Parses an animation object and creates an animation
  33709. * @param parsedAnimation Parsed animation object
  33710. * @returns Animation object
  33711. */
  33712. static Parse(parsedAnimation: any): Animation;
  33713. /**
  33714. * Appends the serialized animations from the source animations
  33715. * @param source Source containing the animations
  33716. * @param destination Target to store the animations
  33717. */
  33718. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33719. /**
  33720. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33721. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33722. * @param url defines the url to load from
  33723. * @returns a promise that will resolve to the new animation or an array of animations
  33724. */
  33725. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33726. /**
  33727. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33728. * @param snippetId defines the snippet to load
  33729. * @returns a promise that will resolve to the new animation or a new array of animations
  33730. */
  33731. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33732. }
  33733. }
  33734. declare module BABYLON {
  33735. /**
  33736. * Interface containing an array of animations
  33737. */
  33738. export interface IAnimatable {
  33739. /**
  33740. * Array of animations
  33741. */
  33742. animations: Nullable<Array<Animation>>;
  33743. }
  33744. }
  33745. declare module BABYLON {
  33746. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33747. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33748. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33749. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33750. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33751. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33752. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33753. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33754. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33755. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33756. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33757. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33758. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33759. /**
  33760. * Decorator used to define property that can be serialized as reference to a camera
  33761. * @param sourceName defines the name of the property to decorate
  33762. */
  33763. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33764. /**
  33765. * Class used to help serialization objects
  33766. */
  33767. export class SerializationHelper {
  33768. /** @hidden */
  33769. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33770. /** @hidden */
  33771. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33772. /** @hidden */
  33773. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33774. /** @hidden */
  33775. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33776. /**
  33777. * Appends the serialized animations from the source animations
  33778. * @param source Source containing the animations
  33779. * @param destination Target to store the animations
  33780. */
  33781. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33782. /**
  33783. * Static function used to serialized a specific entity
  33784. * @param entity defines the entity to serialize
  33785. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33786. * @returns a JSON compatible object representing the serialization of the entity
  33787. */
  33788. static Serialize<T>(entity: T, serializationObject?: any): any;
  33789. /**
  33790. * Creates a new entity from a serialization data object
  33791. * @param creationFunction defines a function used to instanciated the new entity
  33792. * @param source defines the source serialization data
  33793. * @param scene defines the hosting scene
  33794. * @param rootUrl defines the root url for resources
  33795. * @returns a new entity
  33796. */
  33797. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33798. /**
  33799. * Clones an object
  33800. * @param creationFunction defines the function used to instanciate the new object
  33801. * @param source defines the source object
  33802. * @returns the cloned object
  33803. */
  33804. static Clone<T>(creationFunction: () => T, source: T): T;
  33805. /**
  33806. * Instanciates a new object based on a source one (some data will be shared between both object)
  33807. * @param creationFunction defines the function used to instanciate the new object
  33808. * @param source defines the source object
  33809. * @returns the new object
  33810. */
  33811. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33812. }
  33813. }
  33814. declare module BABYLON {
  33815. /**
  33816. * Base class of all the textures in babylon.
  33817. * It groups all the common properties the materials, post process, lights... might need
  33818. * in order to make a correct use of the texture.
  33819. */
  33820. export class BaseTexture implements IAnimatable {
  33821. /**
  33822. * Default anisotropic filtering level for the application.
  33823. * It is set to 4 as a good tradeoff between perf and quality.
  33824. */
  33825. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33826. /**
  33827. * Gets or sets the unique id of the texture
  33828. */
  33829. uniqueId: number;
  33830. /**
  33831. * Define the name of the texture.
  33832. */
  33833. name: string;
  33834. /**
  33835. * Gets or sets an object used to store user defined information.
  33836. */
  33837. metadata: any;
  33838. /**
  33839. * For internal use only. Please do not use.
  33840. */
  33841. reservedDataStore: any;
  33842. private _hasAlpha;
  33843. /**
  33844. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33845. */
  33846. set hasAlpha(value: boolean);
  33847. get hasAlpha(): boolean;
  33848. /**
  33849. * Defines if the alpha value should be determined via the rgb values.
  33850. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33851. */
  33852. getAlphaFromRGB: boolean;
  33853. /**
  33854. * Intensity or strength of the texture.
  33855. * It is commonly used by materials to fine tune the intensity of the texture
  33856. */
  33857. level: number;
  33858. /**
  33859. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33860. * This is part of the texture as textures usually maps to one uv set.
  33861. */
  33862. coordinatesIndex: number;
  33863. protected _coordinatesMode: number;
  33864. /**
  33865. * How a texture is mapped.
  33866. *
  33867. * | Value | Type | Description |
  33868. * | ----- | ----------------------------------- | ----------- |
  33869. * | 0 | EXPLICIT_MODE | |
  33870. * | 1 | SPHERICAL_MODE | |
  33871. * | 2 | PLANAR_MODE | |
  33872. * | 3 | CUBIC_MODE | |
  33873. * | 4 | PROJECTION_MODE | |
  33874. * | 5 | SKYBOX_MODE | |
  33875. * | 6 | INVCUBIC_MODE | |
  33876. * | 7 | EQUIRECTANGULAR_MODE | |
  33877. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33878. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33879. */
  33880. set coordinatesMode(value: number);
  33881. get coordinatesMode(): number;
  33882. private _wrapU;
  33883. /**
  33884. * | Value | Type | Description |
  33885. * | ----- | ------------------ | ----------- |
  33886. * | 0 | CLAMP_ADDRESSMODE | |
  33887. * | 1 | WRAP_ADDRESSMODE | |
  33888. * | 2 | MIRROR_ADDRESSMODE | |
  33889. */
  33890. get wrapU(): number;
  33891. set wrapU(value: number);
  33892. private _wrapV;
  33893. /**
  33894. * | Value | Type | Description |
  33895. * | ----- | ------------------ | ----------- |
  33896. * | 0 | CLAMP_ADDRESSMODE | |
  33897. * | 1 | WRAP_ADDRESSMODE | |
  33898. * | 2 | MIRROR_ADDRESSMODE | |
  33899. */
  33900. get wrapV(): number;
  33901. set wrapV(value: number);
  33902. /**
  33903. * | Value | Type | Description |
  33904. * | ----- | ------------------ | ----------- |
  33905. * | 0 | CLAMP_ADDRESSMODE | |
  33906. * | 1 | WRAP_ADDRESSMODE | |
  33907. * | 2 | MIRROR_ADDRESSMODE | |
  33908. */
  33909. wrapR: number;
  33910. /**
  33911. * With compliant hardware and browser (supporting anisotropic filtering)
  33912. * this defines the level of anisotropic filtering in the texture.
  33913. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33914. */
  33915. anisotropicFilteringLevel: number;
  33916. /**
  33917. * Define if the texture is a cube texture or if false a 2d texture.
  33918. */
  33919. get isCube(): boolean;
  33920. set isCube(value: boolean);
  33921. /**
  33922. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33923. */
  33924. get is3D(): boolean;
  33925. set is3D(value: boolean);
  33926. /**
  33927. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33928. */
  33929. get is2DArray(): boolean;
  33930. set is2DArray(value: boolean);
  33931. /**
  33932. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33933. * HDR texture are usually stored in linear space.
  33934. * This only impacts the PBR and Background materials
  33935. */
  33936. gammaSpace: boolean;
  33937. /**
  33938. * Gets or sets whether or not the texture contains RGBD data.
  33939. */
  33940. get isRGBD(): boolean;
  33941. set isRGBD(value: boolean);
  33942. /**
  33943. * Is Z inverted in the texture (useful in a cube texture).
  33944. */
  33945. invertZ: boolean;
  33946. /**
  33947. * Are mip maps generated for this texture or not.
  33948. */
  33949. get noMipmap(): boolean;
  33950. /**
  33951. * @hidden
  33952. */
  33953. lodLevelInAlpha: boolean;
  33954. /**
  33955. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33956. */
  33957. get lodGenerationOffset(): number;
  33958. set lodGenerationOffset(value: number);
  33959. /**
  33960. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33961. */
  33962. get lodGenerationScale(): number;
  33963. set lodGenerationScale(value: number);
  33964. /**
  33965. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33966. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33967. * average roughness values.
  33968. */
  33969. get linearSpecularLOD(): boolean;
  33970. set linearSpecularLOD(value: boolean);
  33971. /**
  33972. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33973. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33974. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33975. */
  33976. get irradianceTexture(): Nullable<BaseTexture>;
  33977. set irradianceTexture(value: Nullable<BaseTexture>);
  33978. /**
  33979. * Define if the texture is a render target.
  33980. */
  33981. isRenderTarget: boolean;
  33982. /**
  33983. * Define the unique id of the texture in the scene.
  33984. */
  33985. get uid(): string;
  33986. /** @hidden */
  33987. _prefiltered: boolean;
  33988. /**
  33989. * Return a string representation of the texture.
  33990. * @returns the texture as a string
  33991. */
  33992. toString(): string;
  33993. /**
  33994. * Get the class name of the texture.
  33995. * @returns "BaseTexture"
  33996. */
  33997. getClassName(): string;
  33998. /**
  33999. * Define the list of animation attached to the texture.
  34000. */
  34001. animations: Animation[];
  34002. /**
  34003. * An event triggered when the texture is disposed.
  34004. */
  34005. onDisposeObservable: Observable<BaseTexture>;
  34006. private _onDisposeObserver;
  34007. /**
  34008. * Callback triggered when the texture has been disposed.
  34009. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34010. */
  34011. set onDispose(callback: () => void);
  34012. /**
  34013. * Define the current state of the loading sequence when in delayed load mode.
  34014. */
  34015. delayLoadState: number;
  34016. protected _scene: Nullable<Scene>;
  34017. protected _engine: Nullable<ThinEngine>;
  34018. /** @hidden */
  34019. _texture: Nullable<InternalTexture>;
  34020. private _uid;
  34021. /**
  34022. * Define if the texture is preventinga material to render or not.
  34023. * If not and the texture is not ready, the engine will use a default black texture instead.
  34024. */
  34025. get isBlocking(): boolean;
  34026. /**
  34027. * Instantiates a new BaseTexture.
  34028. * Base class of all the textures in babylon.
  34029. * It groups all the common properties the materials, post process, lights... might need
  34030. * in order to make a correct use of the texture.
  34031. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34032. */
  34033. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34034. /**
  34035. * Get the scene the texture belongs to.
  34036. * @returns the scene or null if undefined
  34037. */
  34038. getScene(): Nullable<Scene>;
  34039. /** @hidden */
  34040. protected _getEngine(): Nullable<ThinEngine>;
  34041. /**
  34042. * Get the texture transform matrix used to offset tile the texture for istance.
  34043. * @returns the transformation matrix
  34044. */
  34045. getTextureMatrix(): Matrix;
  34046. /**
  34047. * Get the texture reflection matrix used to rotate/transform the reflection.
  34048. * @returns the reflection matrix
  34049. */
  34050. getReflectionTextureMatrix(): Matrix;
  34051. /**
  34052. * Get the underlying lower level texture from Babylon.
  34053. * @returns the insternal texture
  34054. */
  34055. getInternalTexture(): Nullable<InternalTexture>;
  34056. /**
  34057. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34058. * @returns true if ready or not blocking
  34059. */
  34060. isReadyOrNotBlocking(): boolean;
  34061. /**
  34062. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34063. * @returns true if fully ready
  34064. */
  34065. isReady(): boolean;
  34066. private _cachedSize;
  34067. /**
  34068. * Get the size of the texture.
  34069. * @returns the texture size.
  34070. */
  34071. getSize(): ISize;
  34072. /**
  34073. * Get the base size of the texture.
  34074. * It can be different from the size if the texture has been resized for POT for instance
  34075. * @returns the base size
  34076. */
  34077. getBaseSize(): ISize;
  34078. /**
  34079. * Update the sampling mode of the texture.
  34080. * Default is Trilinear mode.
  34081. *
  34082. * | Value | Type | Description |
  34083. * | ----- | ------------------ | ----------- |
  34084. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34085. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34086. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34087. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34088. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34089. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34090. * | 7 | NEAREST_LINEAR | |
  34091. * | 8 | NEAREST_NEAREST | |
  34092. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34093. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34094. * | 11 | LINEAR_LINEAR | |
  34095. * | 12 | LINEAR_NEAREST | |
  34096. *
  34097. * > _mag_: magnification filter (close to the viewer)
  34098. * > _min_: minification filter (far from the viewer)
  34099. * > _mip_: filter used between mip map levels
  34100. *@param samplingMode Define the new sampling mode of the texture
  34101. */
  34102. updateSamplingMode(samplingMode: number): void;
  34103. /**
  34104. * Scales the texture if is `canRescale()`
  34105. * @param ratio the resize factor we want to use to rescale
  34106. */
  34107. scale(ratio: number): void;
  34108. /**
  34109. * Get if the texture can rescale.
  34110. */
  34111. get canRescale(): boolean;
  34112. /** @hidden */
  34113. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34114. /** @hidden */
  34115. _rebuild(): void;
  34116. /**
  34117. * Triggers the load sequence in delayed load mode.
  34118. */
  34119. delayLoad(): void;
  34120. /**
  34121. * Clones the texture.
  34122. * @returns the cloned texture
  34123. */
  34124. clone(): Nullable<BaseTexture>;
  34125. /**
  34126. * Get the texture underlying type (INT, FLOAT...)
  34127. */
  34128. get textureType(): number;
  34129. /**
  34130. * Get the texture underlying format (RGB, RGBA...)
  34131. */
  34132. get textureFormat(): number;
  34133. /**
  34134. * Indicates that textures need to be re-calculated for all materials
  34135. */
  34136. protected _markAllSubMeshesAsTexturesDirty(): void;
  34137. /**
  34138. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34139. * This will returns an RGBA array buffer containing either in values (0-255) or
  34140. * float values (0-1) depending of the underlying buffer type.
  34141. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34142. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34143. * @param buffer defines a user defined buffer to fill with data (can be null)
  34144. * @returns The Array buffer containing the pixels data.
  34145. */
  34146. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34147. /**
  34148. * Release and destroy the underlying lower level texture aka internalTexture.
  34149. */
  34150. releaseInternalTexture(): void;
  34151. /** @hidden */
  34152. get _lodTextureHigh(): Nullable<BaseTexture>;
  34153. /** @hidden */
  34154. get _lodTextureMid(): Nullable<BaseTexture>;
  34155. /** @hidden */
  34156. get _lodTextureLow(): Nullable<BaseTexture>;
  34157. /**
  34158. * Dispose the texture and release its associated resources.
  34159. */
  34160. dispose(): void;
  34161. /**
  34162. * Serialize the texture into a JSON representation that can be parsed later on.
  34163. * @returns the JSON representation of the texture
  34164. */
  34165. serialize(): any;
  34166. /**
  34167. * Helper function to be called back once a list of texture contains only ready textures.
  34168. * @param textures Define the list of textures to wait for
  34169. * @param callback Define the callback triggered once the entire list will be ready
  34170. */
  34171. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34172. private static _isScene;
  34173. }
  34174. }
  34175. declare module BABYLON {
  34176. /**
  34177. * Options to be used when creating an effect.
  34178. */
  34179. export interface IEffectCreationOptions {
  34180. /**
  34181. * Atrributes that will be used in the shader.
  34182. */
  34183. attributes: string[];
  34184. /**
  34185. * Uniform varible names that will be set in the shader.
  34186. */
  34187. uniformsNames: string[];
  34188. /**
  34189. * Uniform buffer variable names that will be set in the shader.
  34190. */
  34191. uniformBuffersNames: string[];
  34192. /**
  34193. * Sampler texture variable names that will be set in the shader.
  34194. */
  34195. samplers: string[];
  34196. /**
  34197. * Define statements that will be set in the shader.
  34198. */
  34199. defines: any;
  34200. /**
  34201. * Possible fallbacks for this effect to improve performance when needed.
  34202. */
  34203. fallbacks: Nullable<IEffectFallbacks>;
  34204. /**
  34205. * Callback that will be called when the shader is compiled.
  34206. */
  34207. onCompiled: Nullable<(effect: Effect) => void>;
  34208. /**
  34209. * Callback that will be called if an error occurs during shader compilation.
  34210. */
  34211. onError: Nullable<(effect: Effect, errors: string) => void>;
  34212. /**
  34213. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34214. */
  34215. indexParameters?: any;
  34216. /**
  34217. * Max number of lights that can be used in the shader.
  34218. */
  34219. maxSimultaneousLights?: number;
  34220. /**
  34221. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34222. */
  34223. transformFeedbackVaryings?: Nullable<string[]>;
  34224. /**
  34225. * 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
  34226. */
  34227. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34228. /**
  34229. * Is this effect rendering to several color attachments ?
  34230. */
  34231. multiTarget?: boolean;
  34232. }
  34233. /**
  34234. * Effect containing vertex and fragment shader that can be executed on an object.
  34235. */
  34236. export class Effect implements IDisposable {
  34237. /**
  34238. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34239. */
  34240. static ShadersRepository: string;
  34241. /**
  34242. * Enable logging of the shader code when a compilation error occurs
  34243. */
  34244. static LogShaderCodeOnCompilationError: boolean;
  34245. /**
  34246. * Name of the effect.
  34247. */
  34248. name: any;
  34249. /**
  34250. * String container all the define statements that should be set on the shader.
  34251. */
  34252. defines: string;
  34253. /**
  34254. * Callback that will be called when the shader is compiled.
  34255. */
  34256. onCompiled: Nullable<(effect: Effect) => void>;
  34257. /**
  34258. * Callback that will be called if an error occurs during shader compilation.
  34259. */
  34260. onError: Nullable<(effect: Effect, errors: string) => void>;
  34261. /**
  34262. * Callback that will be called when effect is bound.
  34263. */
  34264. onBind: Nullable<(effect: Effect) => void>;
  34265. /**
  34266. * Unique ID of the effect.
  34267. */
  34268. uniqueId: number;
  34269. /**
  34270. * Observable that will be called when the shader is compiled.
  34271. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34272. */
  34273. onCompileObservable: Observable<Effect>;
  34274. /**
  34275. * Observable that will be called if an error occurs during shader compilation.
  34276. */
  34277. onErrorObservable: Observable<Effect>;
  34278. /** @hidden */
  34279. _onBindObservable: Nullable<Observable<Effect>>;
  34280. /**
  34281. * @hidden
  34282. * Specifies if the effect was previously ready
  34283. */
  34284. _wasPreviouslyReady: boolean;
  34285. /**
  34286. * Observable that will be called when effect is bound.
  34287. */
  34288. get onBindObservable(): Observable<Effect>;
  34289. /** @hidden */
  34290. _bonesComputationForcedToCPU: boolean;
  34291. /** @hidden */
  34292. _multiTarget: boolean;
  34293. private static _uniqueIdSeed;
  34294. private _engine;
  34295. private _uniformBuffersNames;
  34296. private _uniformBuffersNamesList;
  34297. private _uniformsNames;
  34298. private _samplerList;
  34299. private _samplers;
  34300. private _isReady;
  34301. private _compilationError;
  34302. private _allFallbacksProcessed;
  34303. private _attributesNames;
  34304. private _attributes;
  34305. private _attributeLocationByName;
  34306. private _uniforms;
  34307. /**
  34308. * Key for the effect.
  34309. * @hidden
  34310. */
  34311. _key: string;
  34312. private _indexParameters;
  34313. private _fallbacks;
  34314. private _vertexSourceCode;
  34315. private _fragmentSourceCode;
  34316. private _vertexSourceCodeOverride;
  34317. private _fragmentSourceCodeOverride;
  34318. private _transformFeedbackVaryings;
  34319. /**
  34320. * Compiled shader to webGL program.
  34321. * @hidden
  34322. */
  34323. _pipelineContext: Nullable<IPipelineContext>;
  34324. private _valueCache;
  34325. private static _baseCache;
  34326. /**
  34327. * Instantiates an effect.
  34328. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34329. * @param baseName Name of the effect.
  34330. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34331. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34332. * @param samplers List of sampler variables that will be passed to the shader.
  34333. * @param engine Engine to be used to render the effect
  34334. * @param defines Define statements to be added to the shader.
  34335. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34336. * @param onCompiled Callback that will be called when the shader is compiled.
  34337. * @param onError Callback that will be called if an error occurs during shader compilation.
  34338. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34339. */
  34340. 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);
  34341. private _useFinalCode;
  34342. /**
  34343. * Unique key for this effect
  34344. */
  34345. get key(): string;
  34346. /**
  34347. * If the effect has been compiled and prepared.
  34348. * @returns if the effect is compiled and prepared.
  34349. */
  34350. isReady(): boolean;
  34351. private _isReadyInternal;
  34352. /**
  34353. * The engine the effect was initialized with.
  34354. * @returns the engine.
  34355. */
  34356. getEngine(): Engine;
  34357. /**
  34358. * The pipeline context for this effect
  34359. * @returns the associated pipeline context
  34360. */
  34361. getPipelineContext(): Nullable<IPipelineContext>;
  34362. /**
  34363. * The set of names of attribute variables for the shader.
  34364. * @returns An array of attribute names.
  34365. */
  34366. getAttributesNames(): string[];
  34367. /**
  34368. * Returns the attribute at the given index.
  34369. * @param index The index of the attribute.
  34370. * @returns The location of the attribute.
  34371. */
  34372. getAttributeLocation(index: number): number;
  34373. /**
  34374. * Returns the attribute based on the name of the variable.
  34375. * @param name of the attribute to look up.
  34376. * @returns the attribute location.
  34377. */
  34378. getAttributeLocationByName(name: string): number;
  34379. /**
  34380. * The number of attributes.
  34381. * @returns the numnber of attributes.
  34382. */
  34383. getAttributesCount(): number;
  34384. /**
  34385. * Gets the index of a uniform variable.
  34386. * @param uniformName of the uniform to look up.
  34387. * @returns the index.
  34388. */
  34389. getUniformIndex(uniformName: string): number;
  34390. /**
  34391. * Returns the attribute based on the name of the variable.
  34392. * @param uniformName of the uniform to look up.
  34393. * @returns the location of the uniform.
  34394. */
  34395. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34396. /**
  34397. * Returns an array of sampler variable names
  34398. * @returns The array of sampler variable names.
  34399. */
  34400. getSamplers(): string[];
  34401. /**
  34402. * Returns an array of uniform variable names
  34403. * @returns The array of uniform variable names.
  34404. */
  34405. getUniformNames(): string[];
  34406. /**
  34407. * Returns an array of uniform buffer variable names
  34408. * @returns The array of uniform buffer variable names.
  34409. */
  34410. getUniformBuffersNames(): string[];
  34411. /**
  34412. * Returns the index parameters used to create the effect
  34413. * @returns The index parameters object
  34414. */
  34415. getIndexParameters(): any;
  34416. /**
  34417. * The error from the last compilation.
  34418. * @returns the error string.
  34419. */
  34420. getCompilationError(): string;
  34421. /**
  34422. * Gets a boolean indicating that all fallbacks were used during compilation
  34423. * @returns true if all fallbacks were used
  34424. */
  34425. allFallbacksProcessed(): boolean;
  34426. /**
  34427. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34428. * @param func The callback to be used.
  34429. */
  34430. executeWhenCompiled(func: (effect: Effect) => void): void;
  34431. private _checkIsReady;
  34432. private _loadShader;
  34433. /**
  34434. * Gets the vertex shader source code of this effect
  34435. */
  34436. get vertexSourceCode(): string;
  34437. /**
  34438. * Gets the fragment shader source code of this effect
  34439. */
  34440. get fragmentSourceCode(): string;
  34441. /**
  34442. * Recompiles the webGL program
  34443. * @param vertexSourceCode The source code for the vertex shader.
  34444. * @param fragmentSourceCode The source code for the fragment shader.
  34445. * @param onCompiled Callback called when completed.
  34446. * @param onError Callback called on error.
  34447. * @hidden
  34448. */
  34449. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34450. /**
  34451. * Prepares the effect
  34452. * @hidden
  34453. */
  34454. _prepareEffect(): void;
  34455. private _getShaderCodeAndErrorLine;
  34456. private _processCompilationErrors;
  34457. /**
  34458. * Checks if the effect is supported. (Must be called after compilation)
  34459. */
  34460. get isSupported(): boolean;
  34461. /**
  34462. * Binds a texture to the engine to be used as output of the shader.
  34463. * @param channel Name of the output variable.
  34464. * @param texture Texture to bind.
  34465. * @hidden
  34466. */
  34467. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34468. /**
  34469. * Sets a texture on the engine to be used in the shader.
  34470. * @param channel Name of the sampler variable.
  34471. * @param texture Texture to set.
  34472. */
  34473. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34474. /**
  34475. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34476. * @param channel Name of the sampler variable.
  34477. * @param texture Texture to set.
  34478. */
  34479. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34480. /**
  34481. * Sets an array of textures on the engine to be used in the shader.
  34482. * @param channel Name of the variable.
  34483. * @param textures Textures to set.
  34484. */
  34485. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34486. /**
  34487. * 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)
  34488. * @param channel Name of the sampler variable.
  34489. * @param postProcess Post process to get the input texture from.
  34490. */
  34491. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34492. /**
  34493. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34494. * 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)
  34495. * @param channel Name of the sampler variable.
  34496. * @param postProcess Post process to get the output texture from.
  34497. */
  34498. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34499. /** @hidden */
  34500. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34501. /** @hidden */
  34502. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34503. /** @hidden */
  34504. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34505. /** @hidden */
  34506. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34507. /**
  34508. * Binds a buffer to a uniform.
  34509. * @param buffer Buffer to bind.
  34510. * @param name Name of the uniform variable to bind to.
  34511. */
  34512. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34513. /**
  34514. * Binds block to a uniform.
  34515. * @param blockName Name of the block to bind.
  34516. * @param index Index to bind.
  34517. */
  34518. bindUniformBlock(blockName: string, index: number): void;
  34519. /**
  34520. * Sets an interger value on a uniform variable.
  34521. * @param uniformName Name of the variable.
  34522. * @param value Value to be set.
  34523. * @returns this effect.
  34524. */
  34525. setInt(uniformName: string, value: number): Effect;
  34526. /**
  34527. * Sets an int array on a uniform variable.
  34528. * @param uniformName Name of the variable.
  34529. * @param array array to be set.
  34530. * @returns this effect.
  34531. */
  34532. setIntArray(uniformName: string, array: Int32Array): Effect;
  34533. /**
  34534. * 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)
  34535. * @param uniformName Name of the variable.
  34536. * @param array array to be set.
  34537. * @returns this effect.
  34538. */
  34539. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34540. /**
  34541. * 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)
  34542. * @param uniformName Name of the variable.
  34543. * @param array array to be set.
  34544. * @returns this effect.
  34545. */
  34546. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34547. /**
  34548. * 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)
  34549. * @param uniformName Name of the variable.
  34550. * @param array array to be set.
  34551. * @returns this effect.
  34552. */
  34553. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34554. /**
  34555. * Sets an float array on a uniform variable.
  34556. * @param uniformName Name of the variable.
  34557. * @param array array to be set.
  34558. * @returns this effect.
  34559. */
  34560. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34561. /**
  34562. * 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)
  34563. * @param uniformName Name of the variable.
  34564. * @param array array to be set.
  34565. * @returns this effect.
  34566. */
  34567. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34568. /**
  34569. * 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)
  34570. * @param uniformName Name of the variable.
  34571. * @param array array to be set.
  34572. * @returns this effect.
  34573. */
  34574. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34575. /**
  34576. * 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)
  34577. * @param uniformName Name of the variable.
  34578. * @param array array to be set.
  34579. * @returns this effect.
  34580. */
  34581. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34582. /**
  34583. * Sets an array on a uniform variable.
  34584. * @param uniformName Name of the variable.
  34585. * @param array array to be set.
  34586. * @returns this effect.
  34587. */
  34588. setArray(uniformName: string, array: number[]): Effect;
  34589. /**
  34590. * 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)
  34591. * @param uniformName Name of the variable.
  34592. * @param array array to be set.
  34593. * @returns this effect.
  34594. */
  34595. setArray2(uniformName: string, array: number[]): Effect;
  34596. /**
  34597. * 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)
  34598. * @param uniformName Name of the variable.
  34599. * @param array array to be set.
  34600. * @returns this effect.
  34601. */
  34602. setArray3(uniformName: string, array: number[]): Effect;
  34603. /**
  34604. * 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)
  34605. * @param uniformName Name of the variable.
  34606. * @param array array to be set.
  34607. * @returns this effect.
  34608. */
  34609. setArray4(uniformName: string, array: number[]): Effect;
  34610. /**
  34611. * Sets matrices on a uniform variable.
  34612. * @param uniformName Name of the variable.
  34613. * @param matrices matrices to be set.
  34614. * @returns this effect.
  34615. */
  34616. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34617. /**
  34618. * Sets matrix on a uniform variable.
  34619. * @param uniformName Name of the variable.
  34620. * @param matrix matrix to be set.
  34621. * @returns this effect.
  34622. */
  34623. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34624. /**
  34625. * 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)
  34626. * @param uniformName Name of the variable.
  34627. * @param matrix matrix to be set.
  34628. * @returns this effect.
  34629. */
  34630. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34631. /**
  34632. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34633. * @param uniformName Name of the variable.
  34634. * @param matrix matrix to be set.
  34635. * @returns this effect.
  34636. */
  34637. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34638. /**
  34639. * Sets a float on a uniform variable.
  34640. * @param uniformName Name of the variable.
  34641. * @param value value to be set.
  34642. * @returns this effect.
  34643. */
  34644. setFloat(uniformName: string, value: number): Effect;
  34645. /**
  34646. * Sets a boolean on a uniform variable.
  34647. * @param uniformName Name of the variable.
  34648. * @param bool value to be set.
  34649. * @returns this effect.
  34650. */
  34651. setBool(uniformName: string, bool: boolean): Effect;
  34652. /**
  34653. * Sets a Vector2 on a uniform variable.
  34654. * @param uniformName Name of the variable.
  34655. * @param vector2 vector2 to be set.
  34656. * @returns this effect.
  34657. */
  34658. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34659. /**
  34660. * Sets a float2 on a uniform variable.
  34661. * @param uniformName Name of the variable.
  34662. * @param x First float in float2.
  34663. * @param y Second float in float2.
  34664. * @returns this effect.
  34665. */
  34666. setFloat2(uniformName: string, x: number, y: number): Effect;
  34667. /**
  34668. * Sets a Vector3 on a uniform variable.
  34669. * @param uniformName Name of the variable.
  34670. * @param vector3 Value to be set.
  34671. * @returns this effect.
  34672. */
  34673. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34674. /**
  34675. * Sets a float3 on a uniform variable.
  34676. * @param uniformName Name of the variable.
  34677. * @param x First float in float3.
  34678. * @param y Second float in float3.
  34679. * @param z Third float in float3.
  34680. * @returns this effect.
  34681. */
  34682. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34683. /**
  34684. * Sets a Vector4 on a uniform variable.
  34685. * @param uniformName Name of the variable.
  34686. * @param vector4 Value to be set.
  34687. * @returns this effect.
  34688. */
  34689. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34690. /**
  34691. * Sets a float4 on a uniform variable.
  34692. * @param uniformName Name of the variable.
  34693. * @param x First float in float4.
  34694. * @param y Second float in float4.
  34695. * @param z Third float in float4.
  34696. * @param w Fourth float in float4.
  34697. * @returns this effect.
  34698. */
  34699. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34700. /**
  34701. * Sets a Color3 on a uniform variable.
  34702. * @param uniformName Name of the variable.
  34703. * @param color3 Value to be set.
  34704. * @returns this effect.
  34705. */
  34706. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34707. /**
  34708. * Sets a Color4 on a uniform variable.
  34709. * @param uniformName Name of the variable.
  34710. * @param color3 Value to be set.
  34711. * @param alpha Alpha value to be set.
  34712. * @returns this effect.
  34713. */
  34714. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34715. /**
  34716. * Sets a Color4 on a uniform variable
  34717. * @param uniformName defines the name of the variable
  34718. * @param color4 defines the value to be set
  34719. * @returns this effect.
  34720. */
  34721. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34722. /** Release all associated resources */
  34723. dispose(): void;
  34724. /**
  34725. * This function will add a new shader to the shader store
  34726. * @param name the name of the shader
  34727. * @param pixelShader optional pixel shader content
  34728. * @param vertexShader optional vertex shader content
  34729. */
  34730. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34731. /**
  34732. * Store of each shader (The can be looked up using effect.key)
  34733. */
  34734. static ShadersStore: {
  34735. [key: string]: string;
  34736. };
  34737. /**
  34738. * Store of each included file for a shader (The can be looked up using effect.key)
  34739. */
  34740. static IncludesShadersStore: {
  34741. [key: string]: string;
  34742. };
  34743. /**
  34744. * Resets the cache of effects.
  34745. */
  34746. static ResetCache(): void;
  34747. }
  34748. }
  34749. declare module BABYLON {
  34750. /**
  34751. * Interface used to describe the capabilities of the engine relatively to the current browser
  34752. */
  34753. export interface EngineCapabilities {
  34754. /** Maximum textures units per fragment shader */
  34755. maxTexturesImageUnits: number;
  34756. /** Maximum texture units per vertex shader */
  34757. maxVertexTextureImageUnits: number;
  34758. /** Maximum textures units in the entire pipeline */
  34759. maxCombinedTexturesImageUnits: number;
  34760. /** Maximum texture size */
  34761. maxTextureSize: number;
  34762. /** Maximum texture samples */
  34763. maxSamples?: number;
  34764. /** Maximum cube texture size */
  34765. maxCubemapTextureSize: number;
  34766. /** Maximum render texture size */
  34767. maxRenderTextureSize: number;
  34768. /** Maximum number of vertex attributes */
  34769. maxVertexAttribs: number;
  34770. /** Maximum number of varyings */
  34771. maxVaryingVectors: number;
  34772. /** Maximum number of uniforms per vertex shader */
  34773. maxVertexUniformVectors: number;
  34774. /** Maximum number of uniforms per fragment shader */
  34775. maxFragmentUniformVectors: number;
  34776. /** Defines if standard derivates (dx/dy) are supported */
  34777. standardDerivatives: boolean;
  34778. /** Defines if s3tc texture compression is supported */
  34779. s3tc?: WEBGL_compressed_texture_s3tc;
  34780. /** Defines if pvrtc texture compression is supported */
  34781. pvrtc: any;
  34782. /** Defines if etc1 texture compression is supported */
  34783. etc1: any;
  34784. /** Defines if etc2 texture compression is supported */
  34785. etc2: any;
  34786. /** Defines if astc texture compression is supported */
  34787. astc: any;
  34788. /** Defines if float textures are supported */
  34789. textureFloat: boolean;
  34790. /** Defines if vertex array objects are supported */
  34791. vertexArrayObject: boolean;
  34792. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34793. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34794. /** Gets the maximum level of anisotropy supported */
  34795. maxAnisotropy: number;
  34796. /** Defines if instancing is supported */
  34797. instancedArrays: boolean;
  34798. /** Defines if 32 bits indices are supported */
  34799. uintIndices: boolean;
  34800. /** Defines if high precision shaders are supported */
  34801. highPrecisionShaderSupported: boolean;
  34802. /** Defines if depth reading in the fragment shader is supported */
  34803. fragmentDepthSupported: boolean;
  34804. /** Defines if float texture linear filtering is supported*/
  34805. textureFloatLinearFiltering: boolean;
  34806. /** Defines if rendering to float textures is supported */
  34807. textureFloatRender: boolean;
  34808. /** Defines if half float textures are supported*/
  34809. textureHalfFloat: boolean;
  34810. /** Defines if half float texture linear filtering is supported*/
  34811. textureHalfFloatLinearFiltering: boolean;
  34812. /** Defines if rendering to half float textures is supported */
  34813. textureHalfFloatRender: boolean;
  34814. /** Defines if textureLOD shader command is supported */
  34815. textureLOD: boolean;
  34816. /** Defines if draw buffers extension is supported */
  34817. drawBuffersExtension: boolean;
  34818. /** Defines if depth textures are supported */
  34819. depthTextureExtension: boolean;
  34820. /** Defines if float color buffer are supported */
  34821. colorBufferFloat: boolean;
  34822. /** Gets disjoint timer query extension (null if not supported) */
  34823. timerQuery?: EXT_disjoint_timer_query;
  34824. /** Defines if timestamp can be used with timer query */
  34825. canUseTimestampForTimerQuery: boolean;
  34826. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34827. multiview?: any;
  34828. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34829. oculusMultiview?: any;
  34830. /** Function used to let the system compiles shaders in background */
  34831. parallelShaderCompile?: {
  34832. COMPLETION_STATUS_KHR: number;
  34833. };
  34834. /** Max number of texture samples for MSAA */
  34835. maxMSAASamples: number;
  34836. /** Defines if the blend min max extension is supported */
  34837. blendMinMax: boolean;
  34838. }
  34839. }
  34840. declare module BABYLON {
  34841. /**
  34842. * @hidden
  34843. **/
  34844. export class DepthCullingState {
  34845. private _isDepthTestDirty;
  34846. private _isDepthMaskDirty;
  34847. private _isDepthFuncDirty;
  34848. private _isCullFaceDirty;
  34849. private _isCullDirty;
  34850. private _isZOffsetDirty;
  34851. private _isFrontFaceDirty;
  34852. private _depthTest;
  34853. private _depthMask;
  34854. private _depthFunc;
  34855. private _cull;
  34856. private _cullFace;
  34857. private _zOffset;
  34858. private _frontFace;
  34859. /**
  34860. * Initializes the state.
  34861. */
  34862. constructor();
  34863. get isDirty(): boolean;
  34864. get zOffset(): number;
  34865. set zOffset(value: number);
  34866. get cullFace(): Nullable<number>;
  34867. set cullFace(value: Nullable<number>);
  34868. get cull(): Nullable<boolean>;
  34869. set cull(value: Nullable<boolean>);
  34870. get depthFunc(): Nullable<number>;
  34871. set depthFunc(value: Nullable<number>);
  34872. get depthMask(): boolean;
  34873. set depthMask(value: boolean);
  34874. get depthTest(): boolean;
  34875. set depthTest(value: boolean);
  34876. get frontFace(): Nullable<number>;
  34877. set frontFace(value: Nullable<number>);
  34878. reset(): void;
  34879. apply(gl: WebGLRenderingContext): void;
  34880. }
  34881. }
  34882. declare module BABYLON {
  34883. /**
  34884. * @hidden
  34885. **/
  34886. export class StencilState {
  34887. /** 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 */
  34888. static readonly ALWAYS: number;
  34889. /** Passed to stencilOperation to specify that stencil value must be kept */
  34890. static readonly KEEP: number;
  34891. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34892. static readonly REPLACE: number;
  34893. private _isStencilTestDirty;
  34894. private _isStencilMaskDirty;
  34895. private _isStencilFuncDirty;
  34896. private _isStencilOpDirty;
  34897. private _stencilTest;
  34898. private _stencilMask;
  34899. private _stencilFunc;
  34900. private _stencilFuncRef;
  34901. private _stencilFuncMask;
  34902. private _stencilOpStencilFail;
  34903. private _stencilOpDepthFail;
  34904. private _stencilOpStencilDepthPass;
  34905. get isDirty(): boolean;
  34906. get stencilFunc(): number;
  34907. set stencilFunc(value: number);
  34908. get stencilFuncRef(): number;
  34909. set stencilFuncRef(value: number);
  34910. get stencilFuncMask(): number;
  34911. set stencilFuncMask(value: number);
  34912. get stencilOpStencilFail(): number;
  34913. set stencilOpStencilFail(value: number);
  34914. get stencilOpDepthFail(): number;
  34915. set stencilOpDepthFail(value: number);
  34916. get stencilOpStencilDepthPass(): number;
  34917. set stencilOpStencilDepthPass(value: number);
  34918. get stencilMask(): number;
  34919. set stencilMask(value: number);
  34920. get stencilTest(): boolean;
  34921. set stencilTest(value: boolean);
  34922. constructor();
  34923. reset(): void;
  34924. apply(gl: WebGLRenderingContext): void;
  34925. }
  34926. }
  34927. declare module BABYLON {
  34928. /**
  34929. * @hidden
  34930. **/
  34931. export class AlphaState {
  34932. private _isAlphaBlendDirty;
  34933. private _isBlendFunctionParametersDirty;
  34934. private _isBlendEquationParametersDirty;
  34935. private _isBlendConstantsDirty;
  34936. private _alphaBlend;
  34937. private _blendFunctionParameters;
  34938. private _blendEquationParameters;
  34939. private _blendConstants;
  34940. /**
  34941. * Initializes the state.
  34942. */
  34943. constructor();
  34944. get isDirty(): boolean;
  34945. get alphaBlend(): boolean;
  34946. set alphaBlend(value: boolean);
  34947. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34948. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34949. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34950. reset(): void;
  34951. apply(gl: WebGLRenderingContext): void;
  34952. }
  34953. }
  34954. declare module BABYLON {
  34955. /** @hidden */
  34956. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34957. attributeProcessor(attribute: string): string;
  34958. varyingProcessor(varying: string, isFragment: boolean): string;
  34959. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34960. }
  34961. }
  34962. declare module BABYLON {
  34963. /**
  34964. * Interface for attribute information associated with buffer instanciation
  34965. */
  34966. export interface InstancingAttributeInfo {
  34967. /**
  34968. * Name of the GLSL attribute
  34969. * if attribute index is not specified, this is used to retrieve the index from the effect
  34970. */
  34971. attributeName: string;
  34972. /**
  34973. * Index/offset of the attribute in the vertex shader
  34974. * if not specified, this will be computes from the name.
  34975. */
  34976. index?: number;
  34977. /**
  34978. * size of the attribute, 1, 2, 3 or 4
  34979. */
  34980. attributeSize: number;
  34981. /**
  34982. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34983. */
  34984. offset: number;
  34985. /**
  34986. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34987. * default to 1
  34988. */
  34989. divisor?: number;
  34990. /**
  34991. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34992. * default is FLOAT
  34993. */
  34994. attributeType?: number;
  34995. /**
  34996. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34997. */
  34998. normalized?: boolean;
  34999. }
  35000. }
  35001. declare module BABYLON {
  35002. interface ThinEngine {
  35003. /**
  35004. * Update a video texture
  35005. * @param texture defines the texture to update
  35006. * @param video defines the video element to use
  35007. * @param invertY defines if data must be stored with Y axis inverted
  35008. */
  35009. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35010. }
  35011. }
  35012. declare module BABYLON {
  35013. interface ThinEngine {
  35014. /**
  35015. * Creates a dynamic texture
  35016. * @param width defines the width of the texture
  35017. * @param height defines the height of the texture
  35018. * @param generateMipMaps defines if the engine should generate the mip levels
  35019. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35020. * @returns the dynamic texture inside an InternalTexture
  35021. */
  35022. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35023. /**
  35024. * Update the content of a dynamic texture
  35025. * @param texture defines the texture to update
  35026. * @param canvas defines the canvas containing the source
  35027. * @param invertY defines if data must be stored with Y axis inverted
  35028. * @param premulAlpha defines if alpha is stored as premultiplied
  35029. * @param format defines the format of the data
  35030. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35031. */
  35032. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35033. }
  35034. }
  35035. declare module BABYLON {
  35036. /**
  35037. * Settings for finer control over video usage
  35038. */
  35039. export interface VideoTextureSettings {
  35040. /**
  35041. * Applies `autoplay` to video, if specified
  35042. */
  35043. autoPlay?: boolean;
  35044. /**
  35045. * Applies `loop` to video, if specified
  35046. */
  35047. loop?: boolean;
  35048. /**
  35049. * Automatically updates internal texture from video at every frame in the render loop
  35050. */
  35051. autoUpdateTexture: boolean;
  35052. /**
  35053. * Image src displayed during the video loading or until the user interacts with the video.
  35054. */
  35055. poster?: string;
  35056. }
  35057. /**
  35058. * If you want to display a video in your scene, this is the special texture for that.
  35059. * This special texture works similar to other textures, with the exception of a few parameters.
  35060. * @see https://doc.babylonjs.com/how_to/video_texture
  35061. */
  35062. export class VideoTexture extends Texture {
  35063. /**
  35064. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35065. */
  35066. readonly autoUpdateTexture: boolean;
  35067. /**
  35068. * The video instance used by the texture internally
  35069. */
  35070. readonly video: HTMLVideoElement;
  35071. private _onUserActionRequestedObservable;
  35072. /**
  35073. * Event triggerd when a dom action is required by the user to play the video.
  35074. * This happens due to recent changes in browser policies preventing video to auto start.
  35075. */
  35076. get onUserActionRequestedObservable(): Observable<Texture>;
  35077. private _generateMipMaps;
  35078. private _stillImageCaptured;
  35079. private _displayingPosterTexture;
  35080. private _settings;
  35081. private _createInternalTextureOnEvent;
  35082. private _frameId;
  35083. private _currentSrc;
  35084. /**
  35085. * Creates a video texture.
  35086. * If you want to display a video in your scene, this is the special texture for that.
  35087. * This special texture works similar to other textures, with the exception of a few parameters.
  35088. * @see https://doc.babylonjs.com/how_to/video_texture
  35089. * @param name optional name, will detect from video source, if not defined
  35090. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35091. * @param scene is obviously the current scene.
  35092. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35093. * @param invertY is false by default but can be used to invert video on Y axis
  35094. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35095. * @param settings allows finer control over video usage
  35096. */
  35097. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35098. private _getName;
  35099. private _getVideo;
  35100. private _createInternalTexture;
  35101. private reset;
  35102. /**
  35103. * @hidden Internal method to initiate `update`.
  35104. */
  35105. _rebuild(): void;
  35106. /**
  35107. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35108. */
  35109. update(): void;
  35110. /**
  35111. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35112. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35113. */
  35114. updateTexture(isVisible: boolean): void;
  35115. protected _updateInternalTexture: () => void;
  35116. /**
  35117. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35118. * @param url New url.
  35119. */
  35120. updateURL(url: string): void;
  35121. /**
  35122. * Clones the texture.
  35123. * @returns the cloned texture
  35124. */
  35125. clone(): VideoTexture;
  35126. /**
  35127. * Dispose the texture and release its associated resources.
  35128. */
  35129. dispose(): void;
  35130. /**
  35131. * Creates a video texture straight from a stream.
  35132. * @param scene Define the scene the texture should be created in
  35133. * @param stream Define the stream the texture should be created from
  35134. * @returns The created video texture as a promise
  35135. */
  35136. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35137. /**
  35138. * Creates a video texture straight from your WebCam video feed.
  35139. * @param scene Define the scene the texture should be created in
  35140. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35141. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35142. * @returns The created video texture as a promise
  35143. */
  35144. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35145. minWidth: number;
  35146. maxWidth: number;
  35147. minHeight: number;
  35148. maxHeight: number;
  35149. deviceId: string;
  35150. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35151. /**
  35152. * Creates a video texture straight from your WebCam video feed.
  35153. * @param scene Define the scene the texture should be created in
  35154. * @param onReady Define a callback to triggered once the texture will be ready
  35155. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35156. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35157. */
  35158. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35159. minWidth: number;
  35160. maxWidth: number;
  35161. minHeight: number;
  35162. maxHeight: number;
  35163. deviceId: string;
  35164. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35165. }
  35166. }
  35167. declare module BABYLON {
  35168. /**
  35169. * Defines the interface used by objects working like Scene
  35170. * @hidden
  35171. */
  35172. export interface ISceneLike {
  35173. _addPendingData(data: any): void;
  35174. _removePendingData(data: any): void;
  35175. offlineProvider: IOfflineProvider;
  35176. }
  35177. /**
  35178. * Information about the current host
  35179. */
  35180. export interface HostInformation {
  35181. /**
  35182. * Defines if the current host is a mobile
  35183. */
  35184. isMobile: boolean;
  35185. }
  35186. /** Interface defining initialization parameters for Engine class */
  35187. export interface EngineOptions extends WebGLContextAttributes {
  35188. /**
  35189. * Defines if the engine should no exceed a specified device ratio
  35190. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35191. */
  35192. limitDeviceRatio?: number;
  35193. /**
  35194. * Defines if webvr should be enabled automatically
  35195. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35196. */
  35197. autoEnableWebVR?: boolean;
  35198. /**
  35199. * Defines if webgl2 should be turned off even if supported
  35200. * @see https://doc.babylonjs.com/features/webgl2
  35201. */
  35202. disableWebGL2Support?: boolean;
  35203. /**
  35204. * Defines if webaudio should be initialized as well
  35205. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35206. */
  35207. audioEngine?: boolean;
  35208. /**
  35209. * Defines if animations should run using a deterministic lock step
  35210. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35211. */
  35212. deterministicLockstep?: boolean;
  35213. /** Defines the maximum steps to use with deterministic lock step mode */
  35214. lockstepMaxSteps?: number;
  35215. /** Defines the seconds between each deterministic lock step */
  35216. timeStep?: number;
  35217. /**
  35218. * Defines that engine should ignore context lost events
  35219. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35220. */
  35221. doNotHandleContextLost?: boolean;
  35222. /**
  35223. * Defines that engine should ignore modifying touch action attribute and style
  35224. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35225. */
  35226. doNotHandleTouchAction?: boolean;
  35227. /**
  35228. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35229. */
  35230. useHighPrecisionFloats?: boolean;
  35231. /**
  35232. * Make the canvas XR Compatible for XR sessions
  35233. */
  35234. xrCompatible?: boolean;
  35235. /**
  35236. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35237. */
  35238. useHighPrecisionMatrix?: boolean;
  35239. }
  35240. /**
  35241. * The base engine class (root of all engines)
  35242. */
  35243. export class ThinEngine {
  35244. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35245. static ExceptionList: ({
  35246. key: string;
  35247. capture: string;
  35248. captureConstraint: number;
  35249. targets: string[];
  35250. } | {
  35251. key: string;
  35252. capture: null;
  35253. captureConstraint: null;
  35254. targets: string[];
  35255. })[];
  35256. /** @hidden */
  35257. static _TextureLoaders: IInternalTextureLoader[];
  35258. /**
  35259. * Returns the current npm package of the sdk
  35260. */
  35261. static get NpmPackage(): string;
  35262. /**
  35263. * Returns the current version of the framework
  35264. */
  35265. static get Version(): string;
  35266. /**
  35267. * Returns a string describing the current engine
  35268. */
  35269. get description(): string;
  35270. /**
  35271. * Gets or sets the epsilon value used by collision engine
  35272. */
  35273. static CollisionsEpsilon: number;
  35274. /**
  35275. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35276. */
  35277. static get ShadersRepository(): string;
  35278. static set ShadersRepository(value: string);
  35279. /** @hidden */
  35280. _shaderProcessor: IShaderProcessor;
  35281. /**
  35282. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35283. */
  35284. forcePOTTextures: boolean;
  35285. /**
  35286. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35287. */
  35288. isFullscreen: boolean;
  35289. /**
  35290. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35291. */
  35292. cullBackFaces: boolean;
  35293. /**
  35294. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35295. */
  35296. renderEvenInBackground: boolean;
  35297. /**
  35298. * Gets or sets a boolean indicating that cache can be kept between frames
  35299. */
  35300. preventCacheWipeBetweenFrames: boolean;
  35301. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35302. validateShaderPrograms: boolean;
  35303. /**
  35304. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35305. * This can provide greater z depth for distant objects.
  35306. */
  35307. useReverseDepthBuffer: boolean;
  35308. /**
  35309. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35310. */
  35311. disableUniformBuffers: boolean;
  35312. /** @hidden */
  35313. _uniformBuffers: UniformBuffer[];
  35314. /**
  35315. * Gets a boolean indicating that the engine supports uniform buffers
  35316. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35317. */
  35318. get supportsUniformBuffers(): boolean;
  35319. /** @hidden */
  35320. _gl: WebGLRenderingContext;
  35321. /** @hidden */
  35322. _webGLVersion: number;
  35323. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35324. protected _windowIsBackground: boolean;
  35325. protected _creationOptions: EngineOptions;
  35326. protected _highPrecisionShadersAllowed: boolean;
  35327. /** @hidden */
  35328. get _shouldUseHighPrecisionShader(): boolean;
  35329. /**
  35330. * Gets a boolean indicating that only power of 2 textures are supported
  35331. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35332. */
  35333. get needPOTTextures(): boolean;
  35334. /** @hidden */
  35335. _badOS: boolean;
  35336. /** @hidden */
  35337. _badDesktopOS: boolean;
  35338. private _hardwareScalingLevel;
  35339. /** @hidden */
  35340. _caps: EngineCapabilities;
  35341. private _isStencilEnable;
  35342. private _glVersion;
  35343. private _glRenderer;
  35344. private _glVendor;
  35345. /** @hidden */
  35346. _videoTextureSupported: boolean;
  35347. protected _renderingQueueLaunched: boolean;
  35348. protected _activeRenderLoops: (() => void)[];
  35349. /**
  35350. * Observable signaled when a context lost event is raised
  35351. */
  35352. onContextLostObservable: Observable<ThinEngine>;
  35353. /**
  35354. * Observable signaled when a context restored event is raised
  35355. */
  35356. onContextRestoredObservable: Observable<ThinEngine>;
  35357. private _onContextLost;
  35358. private _onContextRestored;
  35359. protected _contextWasLost: boolean;
  35360. /** @hidden */
  35361. _doNotHandleContextLost: boolean;
  35362. /**
  35363. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35364. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35365. */
  35366. get doNotHandleContextLost(): boolean;
  35367. set doNotHandleContextLost(value: boolean);
  35368. /**
  35369. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35370. */
  35371. disableVertexArrayObjects: boolean;
  35372. /** @hidden */
  35373. protected _colorWrite: boolean;
  35374. /** @hidden */
  35375. protected _colorWriteChanged: boolean;
  35376. /** @hidden */
  35377. protected _depthCullingState: DepthCullingState;
  35378. /** @hidden */
  35379. protected _stencilState: StencilState;
  35380. /** @hidden */
  35381. _alphaState: AlphaState;
  35382. /** @hidden */
  35383. _alphaMode: number;
  35384. /** @hidden */
  35385. _alphaEquation: number;
  35386. /** @hidden */
  35387. _internalTexturesCache: InternalTexture[];
  35388. /** @hidden */
  35389. protected _activeChannel: number;
  35390. private _currentTextureChannel;
  35391. /** @hidden */
  35392. protected _boundTexturesCache: {
  35393. [key: string]: Nullable<InternalTexture>;
  35394. };
  35395. /** @hidden */
  35396. protected _currentEffect: Nullable<Effect>;
  35397. /** @hidden */
  35398. protected _currentProgram: Nullable<WebGLProgram>;
  35399. private _compiledEffects;
  35400. private _vertexAttribArraysEnabled;
  35401. /** @hidden */
  35402. protected _cachedViewport: Nullable<IViewportLike>;
  35403. private _cachedVertexArrayObject;
  35404. /** @hidden */
  35405. protected _cachedVertexBuffers: any;
  35406. /** @hidden */
  35407. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35408. /** @hidden */
  35409. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35410. /** @hidden */
  35411. _currentRenderTarget: Nullable<InternalTexture>;
  35412. private _uintIndicesCurrentlySet;
  35413. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35414. /** @hidden */
  35415. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35416. /** @hidden */
  35417. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35418. private _currentBufferPointers;
  35419. private _currentInstanceLocations;
  35420. private _currentInstanceBuffers;
  35421. private _textureUnits;
  35422. /** @hidden */
  35423. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35424. /** @hidden */
  35425. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35426. /** @hidden */
  35427. _boundRenderFunction: any;
  35428. private _vaoRecordInProgress;
  35429. private _mustWipeVertexAttributes;
  35430. private _emptyTexture;
  35431. private _emptyCubeTexture;
  35432. private _emptyTexture3D;
  35433. private _emptyTexture2DArray;
  35434. /** @hidden */
  35435. _frameHandler: number;
  35436. private _nextFreeTextureSlots;
  35437. private _maxSimultaneousTextures;
  35438. private _activeRequests;
  35439. /** @hidden */
  35440. _transformTextureUrl: Nullable<(url: string) => string>;
  35441. /**
  35442. * Gets information about the current host
  35443. */
  35444. hostInformation: HostInformation;
  35445. protected get _supportsHardwareTextureRescaling(): boolean;
  35446. private _framebufferDimensionsObject;
  35447. /**
  35448. * sets the object from which width and height will be taken from when getting render width and height
  35449. * Will fallback to the gl object
  35450. * @param dimensions the framebuffer width and height that will be used.
  35451. */
  35452. set framebufferDimensionsObject(dimensions: Nullable<{
  35453. framebufferWidth: number;
  35454. framebufferHeight: number;
  35455. }>);
  35456. /**
  35457. * Gets the current viewport
  35458. */
  35459. get currentViewport(): Nullable<IViewportLike>;
  35460. /**
  35461. * Gets the default empty texture
  35462. */
  35463. get emptyTexture(): InternalTexture;
  35464. /**
  35465. * Gets the default empty 3D texture
  35466. */
  35467. get emptyTexture3D(): InternalTexture;
  35468. /**
  35469. * Gets the default empty 2D array texture
  35470. */
  35471. get emptyTexture2DArray(): InternalTexture;
  35472. /**
  35473. * Gets the default empty cube texture
  35474. */
  35475. get emptyCubeTexture(): InternalTexture;
  35476. /**
  35477. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35478. */
  35479. readonly premultipliedAlpha: boolean;
  35480. /**
  35481. * Observable event triggered before each texture is initialized
  35482. */
  35483. onBeforeTextureInitObservable: Observable<Texture>;
  35484. /**
  35485. * Creates a new engine
  35486. * @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
  35487. * @param antialias defines enable antialiasing (default: false)
  35488. * @param options defines further options to be sent to the getContext() function
  35489. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35490. */
  35491. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35492. private _rebuildInternalTextures;
  35493. private _rebuildEffects;
  35494. /**
  35495. * Gets a boolean indicating if all created effects are ready
  35496. * @returns true if all effects are ready
  35497. */
  35498. areAllEffectsReady(): boolean;
  35499. protected _rebuildBuffers(): void;
  35500. protected _initGLContext(): void;
  35501. /**
  35502. * Gets version of the current webGL context
  35503. */
  35504. get webGLVersion(): number;
  35505. /**
  35506. * Gets a string identifying the name of the class
  35507. * @returns "Engine" string
  35508. */
  35509. getClassName(): string;
  35510. /**
  35511. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35512. */
  35513. get isStencilEnable(): boolean;
  35514. /** @hidden */
  35515. _prepareWorkingCanvas(): void;
  35516. /**
  35517. * Reset the texture cache to empty state
  35518. */
  35519. resetTextureCache(): void;
  35520. /**
  35521. * Gets an object containing information about the current webGL context
  35522. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35523. */
  35524. getGlInfo(): {
  35525. vendor: string;
  35526. renderer: string;
  35527. version: string;
  35528. };
  35529. /**
  35530. * Defines the hardware scaling level.
  35531. * By default the hardware scaling level is computed from the window device ratio.
  35532. * 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.
  35533. * @param level defines the level to use
  35534. */
  35535. setHardwareScalingLevel(level: number): void;
  35536. /**
  35537. * Gets the current hardware scaling level.
  35538. * By default the hardware scaling level is computed from the window device ratio.
  35539. * 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.
  35540. * @returns a number indicating the current hardware scaling level
  35541. */
  35542. getHardwareScalingLevel(): number;
  35543. /**
  35544. * Gets the list of loaded textures
  35545. * @returns an array containing all loaded textures
  35546. */
  35547. getLoadedTexturesCache(): InternalTexture[];
  35548. /**
  35549. * Gets the object containing all engine capabilities
  35550. * @returns the EngineCapabilities object
  35551. */
  35552. getCaps(): EngineCapabilities;
  35553. /**
  35554. * stop executing a render loop function and remove it from the execution array
  35555. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35556. */
  35557. stopRenderLoop(renderFunction?: () => void): void;
  35558. /** @hidden */
  35559. _renderLoop(): void;
  35560. /**
  35561. * Gets the HTML canvas attached with the current webGL context
  35562. * @returns a HTML canvas
  35563. */
  35564. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35565. /**
  35566. * Gets host window
  35567. * @returns the host window object
  35568. */
  35569. getHostWindow(): Nullable<Window>;
  35570. /**
  35571. * Gets the current render width
  35572. * @param useScreen defines if screen size must be used (or the current render target if any)
  35573. * @returns a number defining the current render width
  35574. */
  35575. getRenderWidth(useScreen?: boolean): number;
  35576. /**
  35577. * Gets the current render height
  35578. * @param useScreen defines if screen size must be used (or the current render target if any)
  35579. * @returns a number defining the current render height
  35580. */
  35581. getRenderHeight(useScreen?: boolean): number;
  35582. /**
  35583. * Can be used to override the current requestAnimationFrame requester.
  35584. * @hidden
  35585. */
  35586. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35587. /**
  35588. * Register and execute a render loop. The engine can have more than one render function
  35589. * @param renderFunction defines the function to continuously execute
  35590. */
  35591. runRenderLoop(renderFunction: () => void): void;
  35592. /**
  35593. * Clear the current render buffer or the current render target (if any is set up)
  35594. * @param color defines the color to use
  35595. * @param backBuffer defines if the back buffer must be cleared
  35596. * @param depth defines if the depth buffer must be cleared
  35597. * @param stencil defines if the stencil buffer must be cleared
  35598. */
  35599. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35600. private _viewportCached;
  35601. /** @hidden */
  35602. _viewport(x: number, y: number, width: number, height: number): void;
  35603. /**
  35604. * Set the WebGL's viewport
  35605. * @param viewport defines the viewport element to be used
  35606. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35607. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35608. */
  35609. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35610. /**
  35611. * Begin a new frame
  35612. */
  35613. beginFrame(): void;
  35614. /**
  35615. * Enf the current frame
  35616. */
  35617. endFrame(): void;
  35618. /**
  35619. * Resize the view according to the canvas' size
  35620. */
  35621. resize(): void;
  35622. /**
  35623. * Force a specific size of the canvas
  35624. * @param width defines the new canvas' width
  35625. * @param height defines the new canvas' height
  35626. * @returns true if the size was changed
  35627. */
  35628. setSize(width: number, height: number): boolean;
  35629. /**
  35630. * Binds the frame buffer to the specified texture.
  35631. * @param texture The texture to render to or null for the default canvas
  35632. * @param faceIndex The face of the texture to render to in case of cube texture
  35633. * @param requiredWidth The width of the target to render to
  35634. * @param requiredHeight The height of the target to render to
  35635. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35636. * @param lodLevel defines the lod level to bind to the frame buffer
  35637. * @param layer defines the 2d array index to bind to frame buffer to
  35638. */
  35639. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35640. /** @hidden */
  35641. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35642. /**
  35643. * Unbind the current render target texture from the webGL context
  35644. * @param texture defines the render target texture to unbind
  35645. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35646. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35647. */
  35648. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35649. /**
  35650. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35651. */
  35652. flushFramebuffer(): void;
  35653. /**
  35654. * Unbind the current render target and bind the default framebuffer
  35655. */
  35656. restoreDefaultFramebuffer(): void;
  35657. /** @hidden */
  35658. protected _resetVertexBufferBinding(): void;
  35659. /**
  35660. * Creates a vertex buffer
  35661. * @param data the data for the vertex buffer
  35662. * @returns the new WebGL static buffer
  35663. */
  35664. createVertexBuffer(data: DataArray): DataBuffer;
  35665. private _createVertexBuffer;
  35666. /**
  35667. * Creates a dynamic vertex buffer
  35668. * @param data the data for the dynamic vertex buffer
  35669. * @returns the new WebGL dynamic buffer
  35670. */
  35671. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35672. protected _resetIndexBufferBinding(): void;
  35673. /**
  35674. * Creates a new index buffer
  35675. * @param indices defines the content of the index buffer
  35676. * @param updatable defines if the index buffer must be updatable
  35677. * @returns a new webGL buffer
  35678. */
  35679. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35680. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35681. /**
  35682. * Bind a webGL buffer to the webGL context
  35683. * @param buffer defines the buffer to bind
  35684. */
  35685. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35686. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35687. private bindBuffer;
  35688. /**
  35689. * update the bound buffer with the given data
  35690. * @param data defines the data to update
  35691. */
  35692. updateArrayBuffer(data: Float32Array): void;
  35693. private _vertexAttribPointer;
  35694. /** @hidden */
  35695. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35696. private _bindVertexBuffersAttributes;
  35697. /**
  35698. * Records a vertex array object
  35699. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35700. * @param vertexBuffers defines the list of vertex buffers to store
  35701. * @param indexBuffer defines the index buffer to store
  35702. * @param effect defines the effect to store
  35703. * @returns the new vertex array object
  35704. */
  35705. recordVertexArrayObject(vertexBuffers: {
  35706. [key: string]: VertexBuffer;
  35707. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35708. /**
  35709. * Bind a specific vertex array object
  35710. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35711. * @param vertexArrayObject defines the vertex array object to bind
  35712. * @param indexBuffer defines the index buffer to bind
  35713. */
  35714. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35715. /**
  35716. * Bind webGl buffers directly to the webGL context
  35717. * @param vertexBuffer defines the vertex buffer to bind
  35718. * @param indexBuffer defines the index buffer to bind
  35719. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35720. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35721. * @param effect defines the effect associated with the vertex buffer
  35722. */
  35723. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35724. private _unbindVertexArrayObject;
  35725. /**
  35726. * Bind a list of vertex buffers to the webGL context
  35727. * @param vertexBuffers defines the list of vertex buffers to bind
  35728. * @param indexBuffer defines the index buffer to bind
  35729. * @param effect defines the effect associated with the vertex buffers
  35730. */
  35731. bindBuffers(vertexBuffers: {
  35732. [key: string]: Nullable<VertexBuffer>;
  35733. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35734. /**
  35735. * Unbind all instance attributes
  35736. */
  35737. unbindInstanceAttributes(): void;
  35738. /**
  35739. * Release and free the memory of a vertex array object
  35740. * @param vao defines the vertex array object to delete
  35741. */
  35742. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35743. /** @hidden */
  35744. _releaseBuffer(buffer: DataBuffer): boolean;
  35745. protected _deleteBuffer(buffer: DataBuffer): void;
  35746. /**
  35747. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35748. * @param instancesBuffer defines the webGL buffer to update and bind
  35749. * @param data defines the data to store in the buffer
  35750. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35751. */
  35752. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35753. /**
  35754. * Bind the content of a webGL buffer used with instantiation
  35755. * @param instancesBuffer defines the webGL buffer to bind
  35756. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35757. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35758. */
  35759. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35760. /**
  35761. * Disable the instance attribute corresponding to the name in parameter
  35762. * @param name defines the name of the attribute to disable
  35763. */
  35764. disableInstanceAttributeByName(name: string): void;
  35765. /**
  35766. * Disable the instance attribute corresponding to the location in parameter
  35767. * @param attributeLocation defines the attribute location of the attribute to disable
  35768. */
  35769. disableInstanceAttribute(attributeLocation: number): void;
  35770. /**
  35771. * Disable the attribute corresponding to the location in parameter
  35772. * @param attributeLocation defines the attribute location of the attribute to disable
  35773. */
  35774. disableAttributeByIndex(attributeLocation: number): void;
  35775. /**
  35776. * Send a draw order
  35777. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35778. * @param indexStart defines the starting index
  35779. * @param indexCount defines the number of index to draw
  35780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35781. */
  35782. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35783. /**
  35784. * Draw a list of points
  35785. * @param verticesStart defines the index of first vertex to draw
  35786. * @param verticesCount defines the count of vertices to draw
  35787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35788. */
  35789. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35790. /**
  35791. * Draw a list of unindexed primitives
  35792. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35793. * @param verticesStart defines the index of first vertex to draw
  35794. * @param verticesCount defines the count of vertices to draw
  35795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35796. */
  35797. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35798. /**
  35799. * Draw a list of indexed primitives
  35800. * @param fillMode defines the primitive to use
  35801. * @param indexStart defines the starting index
  35802. * @param indexCount defines the number of index to draw
  35803. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35804. */
  35805. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35806. /**
  35807. * Draw a list of unindexed primitives
  35808. * @param fillMode defines the primitive to use
  35809. * @param verticesStart defines the index of first vertex to draw
  35810. * @param verticesCount defines the count of vertices to draw
  35811. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35812. */
  35813. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35814. private _drawMode;
  35815. /** @hidden */
  35816. protected _reportDrawCall(): void;
  35817. /** @hidden */
  35818. _releaseEffect(effect: Effect): void;
  35819. /** @hidden */
  35820. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35821. /**
  35822. * Create a new effect (used to store vertex/fragment shaders)
  35823. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35824. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35825. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35826. * @param samplers defines an array of string used to represent textures
  35827. * @param defines defines the string containing the defines to use to compile the shaders
  35828. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35829. * @param onCompiled defines a function to call when the effect creation is successful
  35830. * @param onError defines a function to call when the effect creation has failed
  35831. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35832. * @returns the new Effect
  35833. */
  35834. 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;
  35835. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35836. private _compileShader;
  35837. private _compileRawShader;
  35838. /** @hidden */
  35839. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35840. /**
  35841. * Directly creates a webGL program
  35842. * @param pipelineContext defines the pipeline context to attach to
  35843. * @param vertexCode defines the vertex shader code to use
  35844. * @param fragmentCode defines the fragment shader code to use
  35845. * @param context defines the webGL context to use (if not set, the current one will be used)
  35846. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35847. * @returns the new webGL program
  35848. */
  35849. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35850. /**
  35851. * Creates a webGL program
  35852. * @param pipelineContext defines the pipeline context to attach to
  35853. * @param vertexCode defines the vertex shader code to use
  35854. * @param fragmentCode defines the fragment shader code to use
  35855. * @param defines defines the string containing the defines to use to compile the shaders
  35856. * @param context defines the webGL context to use (if not set, the current one will be used)
  35857. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35858. * @returns the new webGL program
  35859. */
  35860. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35861. /**
  35862. * Creates a new pipeline context
  35863. * @returns the new pipeline
  35864. */
  35865. createPipelineContext(): IPipelineContext;
  35866. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35867. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35868. /** @hidden */
  35869. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35870. /** @hidden */
  35871. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35872. /** @hidden */
  35873. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35874. /**
  35875. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35876. * @param pipelineContext defines the pipeline context to use
  35877. * @param uniformsNames defines the list of uniform names
  35878. * @returns an array of webGL uniform locations
  35879. */
  35880. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35881. /**
  35882. * Gets the lsit of active attributes for a given webGL program
  35883. * @param pipelineContext defines the pipeline context to use
  35884. * @param attributesNames defines the list of attribute names to get
  35885. * @returns an array of indices indicating the offset of each attribute
  35886. */
  35887. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35888. /**
  35889. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35890. * @param effect defines the effect to activate
  35891. */
  35892. enableEffect(effect: Nullable<Effect>): void;
  35893. /**
  35894. * Set the value of an uniform to a number (int)
  35895. * @param uniform defines the webGL uniform location where to store the value
  35896. * @param value defines the int number to store
  35897. */
  35898. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35899. /**
  35900. * Set the value of an uniform to an array of int32
  35901. * @param uniform defines the webGL uniform location where to store the value
  35902. * @param array defines the array of int32 to store
  35903. */
  35904. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35905. /**
  35906. * Set the value of an uniform to an array of int32 (stored as vec2)
  35907. * @param uniform defines the webGL uniform location where to store the value
  35908. * @param array defines the array of int32 to store
  35909. */
  35910. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35911. /**
  35912. * Set the value of an uniform to an array of int32 (stored as vec3)
  35913. * @param uniform defines the webGL uniform location where to store the value
  35914. * @param array defines the array of int32 to store
  35915. */
  35916. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35917. /**
  35918. * Set the value of an uniform to an array of int32 (stored as vec4)
  35919. * @param uniform defines the webGL uniform location where to store the value
  35920. * @param array defines the array of int32 to store
  35921. */
  35922. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35923. /**
  35924. * Set the value of an uniform to an array of number
  35925. * @param uniform defines the webGL uniform location where to store the value
  35926. * @param array defines the array of number to store
  35927. */
  35928. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35929. /**
  35930. * Set the value of an uniform to an array of number (stored as vec2)
  35931. * @param uniform defines the webGL uniform location where to store the value
  35932. * @param array defines the array of number to store
  35933. */
  35934. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35935. /**
  35936. * Set the value of an uniform to an array of number (stored as vec3)
  35937. * @param uniform defines the webGL uniform location where to store the value
  35938. * @param array defines the array of number to store
  35939. */
  35940. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35941. /**
  35942. * Set the value of an uniform to an array of number (stored as vec4)
  35943. * @param uniform defines the webGL uniform location where to store the value
  35944. * @param array defines the array of number to store
  35945. */
  35946. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35947. /**
  35948. * Set the value of an uniform to an array of float32 (stored as matrices)
  35949. * @param uniform defines the webGL uniform location where to store the value
  35950. * @param matrices defines the array of float32 to store
  35951. */
  35952. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35953. /**
  35954. * Set the value of an uniform to a matrix (3x3)
  35955. * @param uniform defines the webGL uniform location where to store the value
  35956. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35957. */
  35958. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35959. /**
  35960. * Set the value of an uniform to a matrix (2x2)
  35961. * @param uniform defines the webGL uniform location where to store the value
  35962. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35963. */
  35964. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35965. /**
  35966. * Set the value of an uniform to a number (float)
  35967. * @param uniform defines the webGL uniform location where to store the value
  35968. * @param value defines the float number to store
  35969. */
  35970. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35971. /**
  35972. * Set the value of an uniform to a vec2
  35973. * @param uniform defines the webGL uniform location where to store the value
  35974. * @param x defines the 1st component of the value
  35975. * @param y defines the 2nd component of the value
  35976. */
  35977. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35978. /**
  35979. * Set the value of an uniform to a vec3
  35980. * @param uniform defines the webGL uniform location where to store the value
  35981. * @param x defines the 1st component of the value
  35982. * @param y defines the 2nd component of the value
  35983. * @param z defines the 3rd component of the value
  35984. */
  35985. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35986. /**
  35987. * Set the value of an uniform to a vec4
  35988. * @param uniform defines the webGL uniform location where to store the value
  35989. * @param x defines the 1st component of the value
  35990. * @param y defines the 2nd component of the value
  35991. * @param z defines the 3rd component of the value
  35992. * @param w defines the 4th component of the value
  35993. */
  35994. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35995. /**
  35996. * Apply all cached states (depth, culling, stencil and alpha)
  35997. */
  35998. applyStates(): void;
  35999. /**
  36000. * Enable or disable color writing
  36001. * @param enable defines the state to set
  36002. */
  36003. setColorWrite(enable: boolean): void;
  36004. /**
  36005. * Gets a boolean indicating if color writing is enabled
  36006. * @returns the current color writing state
  36007. */
  36008. getColorWrite(): boolean;
  36009. /**
  36010. * Gets the depth culling state manager
  36011. */
  36012. get depthCullingState(): DepthCullingState;
  36013. /**
  36014. * Gets the alpha state manager
  36015. */
  36016. get alphaState(): AlphaState;
  36017. /**
  36018. * Gets the stencil state manager
  36019. */
  36020. get stencilState(): StencilState;
  36021. /**
  36022. * Clears the list of texture accessible through engine.
  36023. * This can help preventing texture load conflict due to name collision.
  36024. */
  36025. clearInternalTexturesCache(): void;
  36026. /**
  36027. * Force the entire cache to be cleared
  36028. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36029. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36030. */
  36031. wipeCaches(bruteForce?: boolean): void;
  36032. /** @hidden */
  36033. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36034. min: number;
  36035. mag: number;
  36036. };
  36037. /** @hidden */
  36038. _createTexture(): WebGLTexture;
  36039. /**
  36040. * Usually called from Texture.ts.
  36041. * Passed information to create a WebGLTexture
  36042. * @param url defines a value which contains one of the following:
  36043. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36044. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36045. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36046. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36047. * @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)
  36048. * @param scene needed for loading to the correct scene
  36049. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36050. * @param onLoad optional callback to be called upon successful completion
  36051. * @param onError optional callback to be called upon failure
  36052. * @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
  36053. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36054. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36055. * @param forcedExtension defines the extension to use to pick the right loader
  36056. * @param mimeType defines an optional mime type
  36057. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36058. */
  36059. 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;
  36060. /**
  36061. * Loads an image as an HTMLImageElement.
  36062. * @param input url string, ArrayBuffer, or Blob to load
  36063. * @param onLoad callback called when the image successfully loads
  36064. * @param onError callback called when the image fails to load
  36065. * @param offlineProvider offline provider for caching
  36066. * @param mimeType optional mime type
  36067. * @returns the HTMLImageElement of the loaded image
  36068. * @hidden
  36069. */
  36070. 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>;
  36071. /**
  36072. * @hidden
  36073. */
  36074. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36075. private _unpackFlipYCached;
  36076. /**
  36077. * In case you are sharing the context with other applications, it might
  36078. * be interested to not cache the unpack flip y state to ensure a consistent
  36079. * value would be set.
  36080. */
  36081. enableUnpackFlipYCached: boolean;
  36082. /** @hidden */
  36083. _unpackFlipY(value: boolean): void;
  36084. /** @hidden */
  36085. _getUnpackAlignement(): number;
  36086. private _getTextureTarget;
  36087. /**
  36088. * Update the sampling mode of a given texture
  36089. * @param samplingMode defines the required sampling mode
  36090. * @param texture defines the texture to update
  36091. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36092. */
  36093. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36094. /**
  36095. * Update the sampling mode of a given texture
  36096. * @param texture defines the texture to update
  36097. * @param wrapU defines the texture wrap mode of the u coordinates
  36098. * @param wrapV defines the texture wrap mode of the v coordinates
  36099. * @param wrapR defines the texture wrap mode of the r coordinates
  36100. */
  36101. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36102. /** @hidden */
  36103. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36104. width: number;
  36105. height: number;
  36106. layers?: number;
  36107. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36108. /** @hidden */
  36109. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36110. /** @hidden */
  36111. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36112. /**
  36113. * Update a portion of an internal texture
  36114. * @param texture defines the texture to update
  36115. * @param imageData defines the data to store into the texture
  36116. * @param xOffset defines the x coordinates of the update rectangle
  36117. * @param yOffset defines the y coordinates of the update rectangle
  36118. * @param width defines the width of the update rectangle
  36119. * @param height defines the height of the update rectangle
  36120. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36121. * @param lod defines the lod level to update (0 by default)
  36122. */
  36123. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36124. /** @hidden */
  36125. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36126. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36127. private _prepareWebGLTexture;
  36128. /** @hidden */
  36129. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36130. private _getDepthStencilBuffer;
  36131. /** @hidden */
  36132. _releaseFramebufferObjects(texture: InternalTexture): void;
  36133. /** @hidden */
  36134. _releaseTexture(texture: InternalTexture): void;
  36135. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36136. protected _setProgram(program: WebGLProgram): void;
  36137. protected _boundUniforms: {
  36138. [key: number]: WebGLUniformLocation;
  36139. };
  36140. /**
  36141. * Binds an effect to the webGL context
  36142. * @param effect defines the effect to bind
  36143. */
  36144. bindSamplers(effect: Effect): void;
  36145. private _activateCurrentTexture;
  36146. /** @hidden */
  36147. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36148. /** @hidden */
  36149. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36150. /**
  36151. * Unbind all textures from the webGL context
  36152. */
  36153. unbindAllTextures(): void;
  36154. /**
  36155. * Sets a texture to the according uniform.
  36156. * @param channel The texture channel
  36157. * @param uniform The uniform to set
  36158. * @param texture The texture to apply
  36159. */
  36160. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36161. private _bindSamplerUniformToChannel;
  36162. private _getTextureWrapMode;
  36163. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36164. /**
  36165. * Sets an array of texture to the webGL context
  36166. * @param channel defines the channel where the texture array must be set
  36167. * @param uniform defines the associated uniform location
  36168. * @param textures defines the array of textures to bind
  36169. */
  36170. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36171. /** @hidden */
  36172. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36173. private _setTextureParameterFloat;
  36174. private _setTextureParameterInteger;
  36175. /**
  36176. * Unbind all vertex attributes from the webGL context
  36177. */
  36178. unbindAllAttributes(): void;
  36179. /**
  36180. * 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
  36181. */
  36182. releaseEffects(): void;
  36183. /**
  36184. * Dispose and release all associated resources
  36185. */
  36186. dispose(): void;
  36187. /**
  36188. * Attach a new callback raised when context lost event is fired
  36189. * @param callback defines the callback to call
  36190. */
  36191. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36192. /**
  36193. * Attach a new callback raised when context restored event is fired
  36194. * @param callback defines the callback to call
  36195. */
  36196. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36197. /**
  36198. * Get the current error code of the webGL context
  36199. * @returns the error code
  36200. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36201. */
  36202. getError(): number;
  36203. private _canRenderToFloatFramebuffer;
  36204. private _canRenderToHalfFloatFramebuffer;
  36205. private _canRenderToFramebuffer;
  36206. /** @hidden */
  36207. _getWebGLTextureType(type: number): number;
  36208. /** @hidden */
  36209. _getInternalFormat(format: number): number;
  36210. /** @hidden */
  36211. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36212. /** @hidden */
  36213. _getRGBAMultiSampleBufferFormat(type: number): number;
  36214. /** @hidden */
  36215. _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;
  36216. /**
  36217. * Loads a file from a url
  36218. * @param url url to load
  36219. * @param onSuccess callback called when the file successfully loads
  36220. * @param onProgress callback called while file is loading (if the server supports this mode)
  36221. * @param offlineProvider defines the offline provider for caching
  36222. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36223. * @param onError callback called when the file fails to load
  36224. * @returns a file request object
  36225. * @hidden
  36226. */
  36227. 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;
  36228. /**
  36229. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36230. * @param x defines the x coordinate of the rectangle where pixels must be read
  36231. * @param y defines the y coordinate of the rectangle where pixels must be read
  36232. * @param width defines the width of the rectangle where pixels must be read
  36233. * @param height defines the height of the rectangle where pixels must be read
  36234. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36235. * @returns a Uint8Array containing RGBA colors
  36236. */
  36237. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36238. private static _isSupported;
  36239. /**
  36240. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36241. * @returns true if the engine can be created
  36242. * @ignorenaming
  36243. */
  36244. static isSupported(): boolean;
  36245. /**
  36246. * Find the next highest power of two.
  36247. * @param x Number to start search from.
  36248. * @return Next highest power of two.
  36249. */
  36250. static CeilingPOT(x: number): number;
  36251. /**
  36252. * Find the next lowest power of two.
  36253. * @param x Number to start search from.
  36254. * @return Next lowest power of two.
  36255. */
  36256. static FloorPOT(x: number): number;
  36257. /**
  36258. * Find the nearest power of two.
  36259. * @param x Number to start search from.
  36260. * @return Next nearest power of two.
  36261. */
  36262. static NearestPOT(x: number): number;
  36263. /**
  36264. * Get the closest exponent of two
  36265. * @param value defines the value to approximate
  36266. * @param max defines the maximum value to return
  36267. * @param mode defines how to define the closest value
  36268. * @returns closest exponent of two of the given value
  36269. */
  36270. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36271. /**
  36272. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36273. * @param func - the function to be called
  36274. * @param requester - the object that will request the next frame. Falls back to window.
  36275. * @returns frame number
  36276. */
  36277. static QueueNewFrame(func: () => void, requester?: any): number;
  36278. /**
  36279. * Gets host document
  36280. * @returns the host document object
  36281. */
  36282. getHostDocument(): Nullable<Document>;
  36283. }
  36284. }
  36285. declare module BABYLON {
  36286. /**
  36287. * Class representing spherical harmonics coefficients to the 3rd degree
  36288. */
  36289. export class SphericalHarmonics {
  36290. /**
  36291. * Defines whether or not the harmonics have been prescaled for rendering.
  36292. */
  36293. preScaled: boolean;
  36294. /**
  36295. * The l0,0 coefficients of the spherical harmonics
  36296. */
  36297. l00: Vector3;
  36298. /**
  36299. * The l1,-1 coefficients of the spherical harmonics
  36300. */
  36301. l1_1: Vector3;
  36302. /**
  36303. * The l1,0 coefficients of the spherical harmonics
  36304. */
  36305. l10: Vector3;
  36306. /**
  36307. * The l1,1 coefficients of the spherical harmonics
  36308. */
  36309. l11: Vector3;
  36310. /**
  36311. * The l2,-2 coefficients of the spherical harmonics
  36312. */
  36313. l2_2: Vector3;
  36314. /**
  36315. * The l2,-1 coefficients of the spherical harmonics
  36316. */
  36317. l2_1: Vector3;
  36318. /**
  36319. * The l2,0 coefficients of the spherical harmonics
  36320. */
  36321. l20: Vector3;
  36322. /**
  36323. * The l2,1 coefficients of the spherical harmonics
  36324. */
  36325. l21: Vector3;
  36326. /**
  36327. * The l2,2 coefficients of the spherical harmonics
  36328. */
  36329. l22: Vector3;
  36330. /**
  36331. * Adds a light to the spherical harmonics
  36332. * @param direction the direction of the light
  36333. * @param color the color of the light
  36334. * @param deltaSolidAngle the delta solid angle of the light
  36335. */
  36336. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36337. /**
  36338. * Scales the spherical harmonics by the given amount
  36339. * @param scale the amount to scale
  36340. */
  36341. scaleInPlace(scale: number): void;
  36342. /**
  36343. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36344. *
  36345. * ```
  36346. * E_lm = A_l * L_lm
  36347. * ```
  36348. *
  36349. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36350. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36351. * the scaling factors are given in equation 9.
  36352. */
  36353. convertIncidentRadianceToIrradiance(): void;
  36354. /**
  36355. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36356. *
  36357. * ```
  36358. * L = (1/pi) * E * rho
  36359. * ```
  36360. *
  36361. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36362. */
  36363. convertIrradianceToLambertianRadiance(): void;
  36364. /**
  36365. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36366. * required operations at run time.
  36367. *
  36368. * This is simply done by scaling back the SH with Ylm constants parameter.
  36369. * The trigonometric part being applied by the shader at run time.
  36370. */
  36371. preScaleForRendering(): void;
  36372. /**
  36373. * Constructs a spherical harmonics from an array.
  36374. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36375. * @returns the spherical harmonics
  36376. */
  36377. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36378. /**
  36379. * Gets the spherical harmonics from polynomial
  36380. * @param polynomial the spherical polynomial
  36381. * @returns the spherical harmonics
  36382. */
  36383. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36384. }
  36385. /**
  36386. * Class representing spherical polynomial coefficients to the 3rd degree
  36387. */
  36388. export class SphericalPolynomial {
  36389. private _harmonics;
  36390. /**
  36391. * The spherical harmonics used to create the polynomials.
  36392. */
  36393. get preScaledHarmonics(): SphericalHarmonics;
  36394. /**
  36395. * The x coefficients of the spherical polynomial
  36396. */
  36397. x: Vector3;
  36398. /**
  36399. * The y coefficients of the spherical polynomial
  36400. */
  36401. y: Vector3;
  36402. /**
  36403. * The z coefficients of the spherical polynomial
  36404. */
  36405. z: Vector3;
  36406. /**
  36407. * The xx coefficients of the spherical polynomial
  36408. */
  36409. xx: Vector3;
  36410. /**
  36411. * The yy coefficients of the spherical polynomial
  36412. */
  36413. yy: Vector3;
  36414. /**
  36415. * The zz coefficients of the spherical polynomial
  36416. */
  36417. zz: Vector3;
  36418. /**
  36419. * The xy coefficients of the spherical polynomial
  36420. */
  36421. xy: Vector3;
  36422. /**
  36423. * The yz coefficients of the spherical polynomial
  36424. */
  36425. yz: Vector3;
  36426. /**
  36427. * The zx coefficients of the spherical polynomial
  36428. */
  36429. zx: Vector3;
  36430. /**
  36431. * Adds an ambient color to the spherical polynomial
  36432. * @param color the color to add
  36433. */
  36434. addAmbient(color: Color3): void;
  36435. /**
  36436. * Scales the spherical polynomial by the given amount
  36437. * @param scale the amount to scale
  36438. */
  36439. scaleInPlace(scale: number): void;
  36440. /**
  36441. * Gets the spherical polynomial from harmonics
  36442. * @param harmonics the spherical harmonics
  36443. * @returns the spherical polynomial
  36444. */
  36445. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36446. /**
  36447. * Constructs a spherical polynomial from an array.
  36448. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36449. * @returns the spherical polynomial
  36450. */
  36451. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36452. }
  36453. }
  36454. declare module BABYLON {
  36455. /**
  36456. * Defines the source of the internal texture
  36457. */
  36458. export enum InternalTextureSource {
  36459. /**
  36460. * The source of the texture data is unknown
  36461. */
  36462. Unknown = 0,
  36463. /**
  36464. * Texture data comes from an URL
  36465. */
  36466. Url = 1,
  36467. /**
  36468. * Texture data is only used for temporary storage
  36469. */
  36470. Temp = 2,
  36471. /**
  36472. * Texture data comes from raw data (ArrayBuffer)
  36473. */
  36474. Raw = 3,
  36475. /**
  36476. * Texture content is dynamic (video or dynamic texture)
  36477. */
  36478. Dynamic = 4,
  36479. /**
  36480. * Texture content is generated by rendering to it
  36481. */
  36482. RenderTarget = 5,
  36483. /**
  36484. * Texture content is part of a multi render target process
  36485. */
  36486. MultiRenderTarget = 6,
  36487. /**
  36488. * Texture data comes from a cube data file
  36489. */
  36490. Cube = 7,
  36491. /**
  36492. * Texture data comes from a raw cube data
  36493. */
  36494. CubeRaw = 8,
  36495. /**
  36496. * Texture data come from a prefiltered cube data file
  36497. */
  36498. CubePrefiltered = 9,
  36499. /**
  36500. * Texture content is raw 3D data
  36501. */
  36502. Raw3D = 10,
  36503. /**
  36504. * Texture content is raw 2D array data
  36505. */
  36506. Raw2DArray = 11,
  36507. /**
  36508. * Texture content is a depth texture
  36509. */
  36510. Depth = 12,
  36511. /**
  36512. * Texture data comes from a raw cube data encoded with RGBD
  36513. */
  36514. CubeRawRGBD = 13
  36515. }
  36516. /**
  36517. * Class used to store data associated with WebGL texture data for the engine
  36518. * This class should not be used directly
  36519. */
  36520. export class InternalTexture {
  36521. /** @hidden */
  36522. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36523. /**
  36524. * Defines if the texture is ready
  36525. */
  36526. isReady: boolean;
  36527. /**
  36528. * Defines if the texture is a cube texture
  36529. */
  36530. isCube: boolean;
  36531. /**
  36532. * Defines if the texture contains 3D data
  36533. */
  36534. is3D: boolean;
  36535. /**
  36536. * Defines if the texture contains 2D array data
  36537. */
  36538. is2DArray: boolean;
  36539. /**
  36540. * Defines if the texture contains multiview data
  36541. */
  36542. isMultiview: boolean;
  36543. /**
  36544. * Gets the URL used to load this texture
  36545. */
  36546. url: string;
  36547. /**
  36548. * Gets the sampling mode of the texture
  36549. */
  36550. samplingMode: number;
  36551. /**
  36552. * Gets a boolean indicating if the texture needs mipmaps generation
  36553. */
  36554. generateMipMaps: boolean;
  36555. /**
  36556. * Gets the number of samples used by the texture (WebGL2+ only)
  36557. */
  36558. samples: number;
  36559. /**
  36560. * Gets the type of the texture (int, float...)
  36561. */
  36562. type: number;
  36563. /**
  36564. * Gets the format of the texture (RGB, RGBA...)
  36565. */
  36566. format: number;
  36567. /**
  36568. * Observable called when the texture is loaded
  36569. */
  36570. onLoadedObservable: Observable<InternalTexture>;
  36571. /**
  36572. * Gets the width of the texture
  36573. */
  36574. width: number;
  36575. /**
  36576. * Gets the height of the texture
  36577. */
  36578. height: number;
  36579. /**
  36580. * Gets the depth of the texture
  36581. */
  36582. depth: number;
  36583. /**
  36584. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36585. */
  36586. baseWidth: number;
  36587. /**
  36588. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36589. */
  36590. baseHeight: number;
  36591. /**
  36592. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36593. */
  36594. baseDepth: number;
  36595. /**
  36596. * Gets a boolean indicating if the texture is inverted on Y axis
  36597. */
  36598. invertY: boolean;
  36599. /** @hidden */
  36600. _invertVScale: boolean;
  36601. /** @hidden */
  36602. _associatedChannel: number;
  36603. /** @hidden */
  36604. _source: InternalTextureSource;
  36605. /** @hidden */
  36606. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36607. /** @hidden */
  36608. _bufferView: Nullable<ArrayBufferView>;
  36609. /** @hidden */
  36610. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36611. /** @hidden */
  36612. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36613. /** @hidden */
  36614. _size: number;
  36615. /** @hidden */
  36616. _extension: string;
  36617. /** @hidden */
  36618. _files: Nullable<string[]>;
  36619. /** @hidden */
  36620. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36621. /** @hidden */
  36622. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36623. /** @hidden */
  36624. _framebuffer: Nullable<WebGLFramebuffer>;
  36625. /** @hidden */
  36626. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36627. /** @hidden */
  36628. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36629. /** @hidden */
  36630. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36631. /** @hidden */
  36632. _attachments: Nullable<number[]>;
  36633. /** @hidden */
  36634. _textureArray: Nullable<InternalTexture[]>;
  36635. /** @hidden */
  36636. _cachedCoordinatesMode: Nullable<number>;
  36637. /** @hidden */
  36638. _cachedWrapU: Nullable<number>;
  36639. /** @hidden */
  36640. _cachedWrapV: Nullable<number>;
  36641. /** @hidden */
  36642. _cachedWrapR: Nullable<number>;
  36643. /** @hidden */
  36644. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36645. /** @hidden */
  36646. _isDisabled: boolean;
  36647. /** @hidden */
  36648. _compression: Nullable<string>;
  36649. /** @hidden */
  36650. _generateStencilBuffer: boolean;
  36651. /** @hidden */
  36652. _generateDepthBuffer: boolean;
  36653. /** @hidden */
  36654. _comparisonFunction: number;
  36655. /** @hidden */
  36656. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36657. /** @hidden */
  36658. _lodGenerationScale: number;
  36659. /** @hidden */
  36660. _lodGenerationOffset: number;
  36661. /** @hidden */
  36662. _depthStencilTexture: Nullable<InternalTexture>;
  36663. /** @hidden */
  36664. _colorTextureArray: Nullable<WebGLTexture>;
  36665. /** @hidden */
  36666. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36667. /** @hidden */
  36668. _lodTextureHigh: Nullable<BaseTexture>;
  36669. /** @hidden */
  36670. _lodTextureMid: Nullable<BaseTexture>;
  36671. /** @hidden */
  36672. _lodTextureLow: Nullable<BaseTexture>;
  36673. /** @hidden */
  36674. _isRGBD: boolean;
  36675. /** @hidden */
  36676. _linearSpecularLOD: boolean;
  36677. /** @hidden */
  36678. _irradianceTexture: Nullable<BaseTexture>;
  36679. /** @hidden */
  36680. _webGLTexture: Nullable<WebGLTexture>;
  36681. /** @hidden */
  36682. _references: number;
  36683. private _engine;
  36684. /**
  36685. * Gets the Engine the texture belongs to.
  36686. * @returns The babylon engine
  36687. */
  36688. getEngine(): ThinEngine;
  36689. /**
  36690. * Gets the data source type of the texture
  36691. */
  36692. get source(): InternalTextureSource;
  36693. /**
  36694. * Creates a new InternalTexture
  36695. * @param engine defines the engine to use
  36696. * @param source defines the type of data that will be used
  36697. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36698. */
  36699. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36700. /**
  36701. * Increments the number of references (ie. the number of Texture that point to it)
  36702. */
  36703. incrementReferences(): void;
  36704. /**
  36705. * Change the size of the texture (not the size of the content)
  36706. * @param width defines the new width
  36707. * @param height defines the new height
  36708. * @param depth defines the new depth (1 by default)
  36709. */
  36710. updateSize(width: int, height: int, depth?: int): void;
  36711. /** @hidden */
  36712. _rebuild(): void;
  36713. /** @hidden */
  36714. _swapAndDie(target: InternalTexture): void;
  36715. /**
  36716. * Dispose the current allocated resources
  36717. */
  36718. dispose(): void;
  36719. }
  36720. }
  36721. declare module BABYLON {
  36722. /**
  36723. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36724. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36725. */
  36726. export class Analyser {
  36727. /**
  36728. * Gets or sets the smoothing
  36729. * @ignorenaming
  36730. */
  36731. SMOOTHING: number;
  36732. /**
  36733. * Gets or sets the FFT table size
  36734. * @ignorenaming
  36735. */
  36736. FFT_SIZE: number;
  36737. /**
  36738. * Gets or sets the bar graph amplitude
  36739. * @ignorenaming
  36740. */
  36741. BARGRAPHAMPLITUDE: number;
  36742. /**
  36743. * Gets or sets the position of the debug canvas
  36744. * @ignorenaming
  36745. */
  36746. DEBUGCANVASPOS: {
  36747. x: number;
  36748. y: number;
  36749. };
  36750. /**
  36751. * Gets or sets the debug canvas size
  36752. * @ignorenaming
  36753. */
  36754. DEBUGCANVASSIZE: {
  36755. width: number;
  36756. height: number;
  36757. };
  36758. private _byteFreqs;
  36759. private _byteTime;
  36760. private _floatFreqs;
  36761. private _webAudioAnalyser;
  36762. private _debugCanvas;
  36763. private _debugCanvasContext;
  36764. private _scene;
  36765. private _registerFunc;
  36766. private _audioEngine;
  36767. /**
  36768. * Creates a new analyser
  36769. * @param scene defines hosting scene
  36770. */
  36771. constructor(scene: Scene);
  36772. /**
  36773. * Get the number of data values you will have to play with for the visualization
  36774. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36775. * @returns a number
  36776. */
  36777. getFrequencyBinCount(): number;
  36778. /**
  36779. * Gets the current frequency data as a byte array
  36780. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36781. * @returns a Uint8Array
  36782. */
  36783. getByteFrequencyData(): Uint8Array;
  36784. /**
  36785. * Gets the current waveform as a byte array
  36786. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36787. * @returns a Uint8Array
  36788. */
  36789. getByteTimeDomainData(): Uint8Array;
  36790. /**
  36791. * Gets the current frequency data as a float array
  36792. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36793. * @returns a Float32Array
  36794. */
  36795. getFloatFrequencyData(): Float32Array;
  36796. /**
  36797. * Renders the debug canvas
  36798. */
  36799. drawDebugCanvas(): void;
  36800. /**
  36801. * Stops rendering the debug canvas and removes it
  36802. */
  36803. stopDebugCanvas(): void;
  36804. /**
  36805. * Connects two audio nodes
  36806. * @param inputAudioNode defines first node to connect
  36807. * @param outputAudioNode defines second node to connect
  36808. */
  36809. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36810. /**
  36811. * Releases all associated resources
  36812. */
  36813. dispose(): void;
  36814. }
  36815. }
  36816. declare module BABYLON {
  36817. /**
  36818. * This represents an audio engine and it is responsible
  36819. * to play, synchronize and analyse sounds throughout the application.
  36820. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36821. */
  36822. export interface IAudioEngine extends IDisposable {
  36823. /**
  36824. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36825. */
  36826. readonly canUseWebAudio: boolean;
  36827. /**
  36828. * Gets the current AudioContext if available.
  36829. */
  36830. readonly audioContext: Nullable<AudioContext>;
  36831. /**
  36832. * The master gain node defines the global audio volume of your audio engine.
  36833. */
  36834. readonly masterGain: GainNode;
  36835. /**
  36836. * Gets whether or not mp3 are supported by your browser.
  36837. */
  36838. readonly isMP3supported: boolean;
  36839. /**
  36840. * Gets whether or not ogg are supported by your browser.
  36841. */
  36842. readonly isOGGsupported: boolean;
  36843. /**
  36844. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36845. * @ignoreNaming
  36846. */
  36847. WarnedWebAudioUnsupported: boolean;
  36848. /**
  36849. * Defines if the audio engine relies on a custom unlocked button.
  36850. * In this case, the embedded button will not be displayed.
  36851. */
  36852. useCustomUnlockedButton: boolean;
  36853. /**
  36854. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36855. */
  36856. readonly unlocked: boolean;
  36857. /**
  36858. * Event raised when audio has been unlocked on the browser.
  36859. */
  36860. onAudioUnlockedObservable: Observable<AudioEngine>;
  36861. /**
  36862. * Event raised when audio has been locked on the browser.
  36863. */
  36864. onAudioLockedObservable: Observable<AudioEngine>;
  36865. /**
  36866. * Flags the audio engine in Locked state.
  36867. * This happens due to new browser policies preventing audio to autoplay.
  36868. */
  36869. lock(): void;
  36870. /**
  36871. * Unlocks the audio engine once a user action has been done on the dom.
  36872. * This is helpful to resume play once browser policies have been satisfied.
  36873. */
  36874. unlock(): void;
  36875. /**
  36876. * Gets the global volume sets on the master gain.
  36877. * @returns the global volume if set or -1 otherwise
  36878. */
  36879. getGlobalVolume(): number;
  36880. /**
  36881. * Sets the global volume of your experience (sets on the master gain).
  36882. * @param newVolume Defines the new global volume of the application
  36883. */
  36884. setGlobalVolume(newVolume: number): void;
  36885. /**
  36886. * Connect the audio engine to an audio analyser allowing some amazing
  36887. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36888. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36889. * @param analyser The analyser to connect to the engine
  36890. */
  36891. connectToAnalyser(analyser: Analyser): void;
  36892. }
  36893. /**
  36894. * This represents the default audio engine used in babylon.
  36895. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36896. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36897. */
  36898. export class AudioEngine implements IAudioEngine {
  36899. private _audioContext;
  36900. private _audioContextInitialized;
  36901. private _muteButton;
  36902. private _hostElement;
  36903. /**
  36904. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36905. */
  36906. canUseWebAudio: boolean;
  36907. /**
  36908. * The master gain node defines the global audio volume of your audio engine.
  36909. */
  36910. masterGain: GainNode;
  36911. /**
  36912. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36913. * @ignoreNaming
  36914. */
  36915. WarnedWebAudioUnsupported: boolean;
  36916. /**
  36917. * Gets whether or not mp3 are supported by your browser.
  36918. */
  36919. isMP3supported: boolean;
  36920. /**
  36921. * Gets whether or not ogg are supported by your browser.
  36922. */
  36923. isOGGsupported: boolean;
  36924. /**
  36925. * Gets whether audio has been unlocked on the device.
  36926. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36927. * a user interaction has happened.
  36928. */
  36929. unlocked: boolean;
  36930. /**
  36931. * Defines if the audio engine relies on a custom unlocked button.
  36932. * In this case, the embedded button will not be displayed.
  36933. */
  36934. useCustomUnlockedButton: boolean;
  36935. /**
  36936. * Event raised when audio has been unlocked on the browser.
  36937. */
  36938. onAudioUnlockedObservable: Observable<AudioEngine>;
  36939. /**
  36940. * Event raised when audio has been locked on the browser.
  36941. */
  36942. onAudioLockedObservable: Observable<AudioEngine>;
  36943. /**
  36944. * Gets the current AudioContext if available.
  36945. */
  36946. get audioContext(): Nullable<AudioContext>;
  36947. private _connectedAnalyser;
  36948. /**
  36949. * Instantiates a new audio engine.
  36950. *
  36951. * There should be only one per page as some browsers restrict the number
  36952. * of audio contexts you can create.
  36953. * @param hostElement defines the host element where to display the mute icon if necessary
  36954. */
  36955. constructor(hostElement?: Nullable<HTMLElement>);
  36956. /**
  36957. * Flags the audio engine in Locked state.
  36958. * This happens due to new browser policies preventing audio to autoplay.
  36959. */
  36960. lock(): void;
  36961. /**
  36962. * Unlocks the audio engine once a user action has been done on the dom.
  36963. * This is helpful to resume play once browser policies have been satisfied.
  36964. */
  36965. unlock(): void;
  36966. private _resumeAudioContext;
  36967. private _initializeAudioContext;
  36968. private _tryToRun;
  36969. private _triggerRunningState;
  36970. private _triggerSuspendedState;
  36971. private _displayMuteButton;
  36972. private _moveButtonToTopLeft;
  36973. private _onResize;
  36974. private _hideMuteButton;
  36975. /**
  36976. * Destroy and release the resources associated with the audio ccontext.
  36977. */
  36978. dispose(): void;
  36979. /**
  36980. * Gets the global volume sets on the master gain.
  36981. * @returns the global volume if set or -1 otherwise
  36982. */
  36983. getGlobalVolume(): number;
  36984. /**
  36985. * Sets the global volume of your experience (sets on the master gain).
  36986. * @param newVolume Defines the new global volume of the application
  36987. */
  36988. setGlobalVolume(newVolume: number): void;
  36989. /**
  36990. * Connect the audio engine to an audio analyser allowing some amazing
  36991. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36992. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36993. * @param analyser The analyser to connect to the engine
  36994. */
  36995. connectToAnalyser(analyser: Analyser): void;
  36996. }
  36997. }
  36998. declare module BABYLON {
  36999. /**
  37000. * Interface used to present a loading screen while loading a scene
  37001. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37002. */
  37003. export interface ILoadingScreen {
  37004. /**
  37005. * Function called to display the loading screen
  37006. */
  37007. displayLoadingUI: () => void;
  37008. /**
  37009. * Function called to hide the loading screen
  37010. */
  37011. hideLoadingUI: () => void;
  37012. /**
  37013. * Gets or sets the color to use for the background
  37014. */
  37015. loadingUIBackgroundColor: string;
  37016. /**
  37017. * Gets or sets the text to display while loading
  37018. */
  37019. loadingUIText: string;
  37020. }
  37021. /**
  37022. * Class used for the default loading screen
  37023. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37024. */
  37025. export class DefaultLoadingScreen implements ILoadingScreen {
  37026. private _renderingCanvas;
  37027. private _loadingText;
  37028. private _loadingDivBackgroundColor;
  37029. private _loadingDiv;
  37030. private _loadingTextDiv;
  37031. /** Gets or sets the logo url to use for the default loading screen */
  37032. static DefaultLogoUrl: string;
  37033. /** Gets or sets the spinner url to use for the default loading screen */
  37034. static DefaultSpinnerUrl: string;
  37035. /**
  37036. * Creates a new default loading screen
  37037. * @param _renderingCanvas defines the canvas used to render the scene
  37038. * @param _loadingText defines the default text to display
  37039. * @param _loadingDivBackgroundColor defines the default background color
  37040. */
  37041. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37042. /**
  37043. * Function called to display the loading screen
  37044. */
  37045. displayLoadingUI(): void;
  37046. /**
  37047. * Function called to hide the loading screen
  37048. */
  37049. hideLoadingUI(): void;
  37050. /**
  37051. * Gets or sets the text to display while loading
  37052. */
  37053. set loadingUIText(text: string);
  37054. get loadingUIText(): string;
  37055. /**
  37056. * Gets or sets the color to use for the background
  37057. */
  37058. get loadingUIBackgroundColor(): string;
  37059. set loadingUIBackgroundColor(color: string);
  37060. private _resizeLoadingUI;
  37061. }
  37062. }
  37063. declare module BABYLON {
  37064. /**
  37065. * Interface for any object that can request an animation frame
  37066. */
  37067. export interface ICustomAnimationFrameRequester {
  37068. /**
  37069. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37070. */
  37071. renderFunction?: Function;
  37072. /**
  37073. * Called to request the next frame to render to
  37074. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37075. */
  37076. requestAnimationFrame: Function;
  37077. /**
  37078. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37079. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37080. */
  37081. requestID?: number;
  37082. }
  37083. }
  37084. declare module BABYLON {
  37085. /**
  37086. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37087. */
  37088. export class PerformanceMonitor {
  37089. private _enabled;
  37090. private _rollingFrameTime;
  37091. private _lastFrameTimeMs;
  37092. /**
  37093. * constructor
  37094. * @param frameSampleSize The number of samples required to saturate the sliding window
  37095. */
  37096. constructor(frameSampleSize?: number);
  37097. /**
  37098. * Samples current frame
  37099. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37100. */
  37101. sampleFrame(timeMs?: number): void;
  37102. /**
  37103. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37104. */
  37105. get averageFrameTime(): number;
  37106. /**
  37107. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37108. */
  37109. get averageFrameTimeVariance(): number;
  37110. /**
  37111. * Returns the frame time of the most recent frame
  37112. */
  37113. get instantaneousFrameTime(): number;
  37114. /**
  37115. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37116. */
  37117. get averageFPS(): number;
  37118. /**
  37119. * Returns the average framerate in frames per second using the most recent frame time
  37120. */
  37121. get instantaneousFPS(): number;
  37122. /**
  37123. * Returns true if enough samples have been taken to completely fill the sliding window
  37124. */
  37125. get isSaturated(): boolean;
  37126. /**
  37127. * Enables contributions to the sliding window sample set
  37128. */
  37129. enable(): void;
  37130. /**
  37131. * Disables contributions to the sliding window sample set
  37132. * Samples will not be interpolated over the disabled period
  37133. */
  37134. disable(): void;
  37135. /**
  37136. * Returns true if sampling is enabled
  37137. */
  37138. get isEnabled(): boolean;
  37139. /**
  37140. * Resets performance monitor
  37141. */
  37142. reset(): void;
  37143. }
  37144. /**
  37145. * RollingAverage
  37146. *
  37147. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37148. */
  37149. export class RollingAverage {
  37150. /**
  37151. * Current average
  37152. */
  37153. average: number;
  37154. /**
  37155. * Current variance
  37156. */
  37157. variance: number;
  37158. protected _samples: Array<number>;
  37159. protected _sampleCount: number;
  37160. protected _pos: number;
  37161. protected _m2: number;
  37162. /**
  37163. * constructor
  37164. * @param length The number of samples required to saturate the sliding window
  37165. */
  37166. constructor(length: number);
  37167. /**
  37168. * Adds a sample to the sample set
  37169. * @param v The sample value
  37170. */
  37171. add(v: number): void;
  37172. /**
  37173. * Returns previously added values or null if outside of history or outside the sliding window domain
  37174. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37175. * @return Value previously recorded with add() or null if outside of range
  37176. */
  37177. history(i: number): number;
  37178. /**
  37179. * Returns true if enough samples have been taken to completely fill the sliding window
  37180. * @return true if sample-set saturated
  37181. */
  37182. isSaturated(): boolean;
  37183. /**
  37184. * Resets the rolling average (equivalent to 0 samples taken so far)
  37185. */
  37186. reset(): void;
  37187. /**
  37188. * Wraps a value around the sample range boundaries
  37189. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37190. * @return Wrapped position in sample range
  37191. */
  37192. protected _wrapPosition(i: number): number;
  37193. }
  37194. }
  37195. declare module BABYLON {
  37196. /**
  37197. * This class is used to track a performance counter which is number based.
  37198. * The user has access to many properties which give statistics of different nature.
  37199. *
  37200. * The implementer can track two kinds of Performance Counter: time and count.
  37201. * 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.
  37202. * 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.
  37203. */
  37204. export class PerfCounter {
  37205. /**
  37206. * Gets or sets a global boolean to turn on and off all the counters
  37207. */
  37208. static Enabled: boolean;
  37209. /**
  37210. * Returns the smallest value ever
  37211. */
  37212. get min(): number;
  37213. /**
  37214. * Returns the biggest value ever
  37215. */
  37216. get max(): number;
  37217. /**
  37218. * Returns the average value since the performance counter is running
  37219. */
  37220. get average(): number;
  37221. /**
  37222. * Returns the average value of the last second the counter was monitored
  37223. */
  37224. get lastSecAverage(): number;
  37225. /**
  37226. * Returns the current value
  37227. */
  37228. get current(): number;
  37229. /**
  37230. * Gets the accumulated total
  37231. */
  37232. get total(): number;
  37233. /**
  37234. * Gets the total value count
  37235. */
  37236. get count(): number;
  37237. /**
  37238. * Creates a new counter
  37239. */
  37240. constructor();
  37241. /**
  37242. * Call this method to start monitoring a new frame.
  37243. * 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.
  37244. */
  37245. fetchNewFrame(): void;
  37246. /**
  37247. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37248. * @param newCount the count value to add to the monitored count
  37249. * @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.
  37250. */
  37251. addCount(newCount: number, fetchResult: boolean): void;
  37252. /**
  37253. * Start monitoring this performance counter
  37254. */
  37255. beginMonitoring(): void;
  37256. /**
  37257. * Compute the time lapsed since the previous beginMonitoring() call.
  37258. * @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
  37259. */
  37260. endMonitoring(newFrame?: boolean): void;
  37261. private _fetchResult;
  37262. private _startMonitoringTime;
  37263. private _min;
  37264. private _max;
  37265. private _average;
  37266. private _current;
  37267. private _totalValueCount;
  37268. private _totalAccumulated;
  37269. private _lastSecAverage;
  37270. private _lastSecAccumulated;
  37271. private _lastSecTime;
  37272. private _lastSecValueCount;
  37273. }
  37274. }
  37275. declare module BABYLON {
  37276. interface ThinEngine {
  37277. /** @hidden */
  37278. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37279. }
  37280. }
  37281. declare module BABYLON {
  37282. /**
  37283. * Defines the interface used by display changed events
  37284. */
  37285. export interface IDisplayChangedEventArgs {
  37286. /** Gets the vrDisplay object (if any) */
  37287. vrDisplay: Nullable<any>;
  37288. /** Gets a boolean indicating if webVR is supported */
  37289. vrSupported: boolean;
  37290. }
  37291. /**
  37292. * Defines the interface used by objects containing a viewport (like a camera)
  37293. */
  37294. interface IViewportOwnerLike {
  37295. /**
  37296. * Gets or sets the viewport
  37297. */
  37298. viewport: IViewportLike;
  37299. }
  37300. /**
  37301. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37302. */
  37303. export class Engine extends ThinEngine {
  37304. /** Defines that alpha blending is disabled */
  37305. static readonly ALPHA_DISABLE: number;
  37306. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37307. static readonly ALPHA_ADD: number;
  37308. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37309. static readonly ALPHA_COMBINE: number;
  37310. /** Defines that alpha blending to DEST - SRC * DEST */
  37311. static readonly ALPHA_SUBTRACT: number;
  37312. /** Defines that alpha blending to SRC * DEST */
  37313. static readonly ALPHA_MULTIPLY: number;
  37314. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37315. static readonly ALPHA_MAXIMIZED: number;
  37316. /** Defines that alpha blending to SRC + DEST */
  37317. static readonly ALPHA_ONEONE: number;
  37318. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37319. static readonly ALPHA_PREMULTIPLIED: number;
  37320. /**
  37321. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37322. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37323. */
  37324. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37325. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37326. static readonly ALPHA_INTERPOLATE: number;
  37327. /**
  37328. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37329. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37330. */
  37331. static readonly ALPHA_SCREENMODE: number;
  37332. /** Defines that the ressource is not delayed*/
  37333. static readonly DELAYLOADSTATE_NONE: number;
  37334. /** Defines that the ressource was successfully delay loaded */
  37335. static readonly DELAYLOADSTATE_LOADED: number;
  37336. /** Defines that the ressource is currently delay loading */
  37337. static readonly DELAYLOADSTATE_LOADING: number;
  37338. /** Defines that the ressource is delayed and has not started loading */
  37339. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37340. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37341. static readonly NEVER: number;
  37342. /** 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 */
  37343. static readonly ALWAYS: number;
  37344. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37345. static readonly LESS: number;
  37346. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37347. static readonly EQUAL: number;
  37348. /** 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 */
  37349. static readonly LEQUAL: number;
  37350. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37351. static readonly GREATER: number;
  37352. /** 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 */
  37353. static readonly GEQUAL: number;
  37354. /** 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 */
  37355. static readonly NOTEQUAL: number;
  37356. /** Passed to stencilOperation to specify that stencil value must be kept */
  37357. static readonly KEEP: number;
  37358. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37359. static readonly REPLACE: number;
  37360. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37361. static readonly INCR: number;
  37362. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37363. static readonly DECR: number;
  37364. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37365. static readonly INVERT: number;
  37366. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37367. static readonly INCR_WRAP: number;
  37368. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37369. static readonly DECR_WRAP: number;
  37370. /** Texture is not repeating outside of 0..1 UVs */
  37371. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37372. /** Texture is repeating outside of 0..1 UVs */
  37373. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37374. /** Texture is repeating and mirrored */
  37375. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37376. /** ALPHA */
  37377. static readonly TEXTUREFORMAT_ALPHA: number;
  37378. /** LUMINANCE */
  37379. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37380. /** LUMINANCE_ALPHA */
  37381. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37382. /** RGB */
  37383. static readonly TEXTUREFORMAT_RGB: number;
  37384. /** RGBA */
  37385. static readonly TEXTUREFORMAT_RGBA: number;
  37386. /** RED */
  37387. static readonly TEXTUREFORMAT_RED: number;
  37388. /** RED (2nd reference) */
  37389. static readonly TEXTUREFORMAT_R: number;
  37390. /** RG */
  37391. static readonly TEXTUREFORMAT_RG: number;
  37392. /** RED_INTEGER */
  37393. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37394. /** RED_INTEGER (2nd reference) */
  37395. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37396. /** RG_INTEGER */
  37397. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37398. /** RGB_INTEGER */
  37399. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37400. /** RGBA_INTEGER */
  37401. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37402. /** UNSIGNED_BYTE */
  37403. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37404. /** UNSIGNED_BYTE (2nd reference) */
  37405. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37406. /** FLOAT */
  37407. static readonly TEXTURETYPE_FLOAT: number;
  37408. /** HALF_FLOAT */
  37409. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37410. /** BYTE */
  37411. static readonly TEXTURETYPE_BYTE: number;
  37412. /** SHORT */
  37413. static readonly TEXTURETYPE_SHORT: number;
  37414. /** UNSIGNED_SHORT */
  37415. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37416. /** INT */
  37417. static readonly TEXTURETYPE_INT: number;
  37418. /** UNSIGNED_INT */
  37419. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37420. /** UNSIGNED_SHORT_4_4_4_4 */
  37421. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37422. /** UNSIGNED_SHORT_5_5_5_1 */
  37423. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37424. /** UNSIGNED_SHORT_5_6_5 */
  37425. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37426. /** UNSIGNED_INT_2_10_10_10_REV */
  37427. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37428. /** UNSIGNED_INT_24_8 */
  37429. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37430. /** UNSIGNED_INT_10F_11F_11F_REV */
  37431. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37432. /** UNSIGNED_INT_5_9_9_9_REV */
  37433. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37434. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37435. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37436. /** nearest is mag = nearest and min = nearest and mip = linear */
  37437. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37438. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37439. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37440. /** Trilinear is mag = linear and min = linear and mip = linear */
  37441. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37442. /** nearest is mag = nearest and min = nearest and mip = linear */
  37443. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37444. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37445. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37446. /** Trilinear is mag = linear and min = linear and mip = linear */
  37447. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37448. /** mag = nearest and min = nearest and mip = nearest */
  37449. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37450. /** mag = nearest and min = linear and mip = nearest */
  37451. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37452. /** mag = nearest and min = linear and mip = linear */
  37453. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37454. /** mag = nearest and min = linear and mip = none */
  37455. static readonly TEXTURE_NEAREST_LINEAR: number;
  37456. /** mag = nearest and min = nearest and mip = none */
  37457. static readonly TEXTURE_NEAREST_NEAREST: number;
  37458. /** mag = linear and min = nearest and mip = nearest */
  37459. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37460. /** mag = linear and min = nearest and mip = linear */
  37461. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37462. /** mag = linear and min = linear and mip = none */
  37463. static readonly TEXTURE_LINEAR_LINEAR: number;
  37464. /** mag = linear and min = nearest and mip = none */
  37465. static readonly TEXTURE_LINEAR_NEAREST: number;
  37466. /** Explicit coordinates mode */
  37467. static readonly TEXTURE_EXPLICIT_MODE: number;
  37468. /** Spherical coordinates mode */
  37469. static readonly TEXTURE_SPHERICAL_MODE: number;
  37470. /** Planar coordinates mode */
  37471. static readonly TEXTURE_PLANAR_MODE: number;
  37472. /** Cubic coordinates mode */
  37473. static readonly TEXTURE_CUBIC_MODE: number;
  37474. /** Projection coordinates mode */
  37475. static readonly TEXTURE_PROJECTION_MODE: number;
  37476. /** Skybox coordinates mode */
  37477. static readonly TEXTURE_SKYBOX_MODE: number;
  37478. /** Inverse Cubic coordinates mode */
  37479. static readonly TEXTURE_INVCUBIC_MODE: number;
  37480. /** Equirectangular coordinates mode */
  37481. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37482. /** Equirectangular Fixed coordinates mode */
  37483. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37484. /** Equirectangular Fixed Mirrored coordinates mode */
  37485. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37486. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37487. static readonly SCALEMODE_FLOOR: number;
  37488. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37489. static readonly SCALEMODE_NEAREST: number;
  37490. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37491. static readonly SCALEMODE_CEILING: number;
  37492. /**
  37493. * Returns the current npm package of the sdk
  37494. */
  37495. static get NpmPackage(): string;
  37496. /**
  37497. * Returns the current version of the framework
  37498. */
  37499. static get Version(): string;
  37500. /** Gets the list of created engines */
  37501. static get Instances(): Engine[];
  37502. /**
  37503. * Gets the latest created engine
  37504. */
  37505. static get LastCreatedEngine(): Nullable<Engine>;
  37506. /**
  37507. * Gets the latest created scene
  37508. */
  37509. static get LastCreatedScene(): Nullable<Scene>;
  37510. /**
  37511. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37512. * @param flag defines which part of the materials must be marked as dirty
  37513. * @param predicate defines a predicate used to filter which materials should be affected
  37514. */
  37515. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37516. /**
  37517. * Method called to create the default loading screen.
  37518. * This can be overriden in your own app.
  37519. * @param canvas The rendering canvas element
  37520. * @returns The loading screen
  37521. */
  37522. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37523. /**
  37524. * Method called to create the default rescale post process on each engine.
  37525. */
  37526. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37527. /**
  37528. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37529. **/
  37530. enableOfflineSupport: boolean;
  37531. /**
  37532. * 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)
  37533. **/
  37534. disableManifestCheck: boolean;
  37535. /**
  37536. * Gets the list of created scenes
  37537. */
  37538. scenes: Scene[];
  37539. /**
  37540. * Event raised when a new scene is created
  37541. */
  37542. onNewSceneAddedObservable: Observable<Scene>;
  37543. /**
  37544. * Gets the list of created postprocesses
  37545. */
  37546. postProcesses: PostProcess[];
  37547. /**
  37548. * Gets a boolean indicating if the pointer is currently locked
  37549. */
  37550. isPointerLock: boolean;
  37551. /**
  37552. * Observable event triggered each time the rendering canvas is resized
  37553. */
  37554. onResizeObservable: Observable<Engine>;
  37555. /**
  37556. * Observable event triggered each time the canvas loses focus
  37557. */
  37558. onCanvasBlurObservable: Observable<Engine>;
  37559. /**
  37560. * Observable event triggered each time the canvas gains focus
  37561. */
  37562. onCanvasFocusObservable: Observable<Engine>;
  37563. /**
  37564. * Observable event triggered each time the canvas receives pointerout event
  37565. */
  37566. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37567. /**
  37568. * Observable raised when the engine begins a new frame
  37569. */
  37570. onBeginFrameObservable: Observable<Engine>;
  37571. /**
  37572. * If set, will be used to request the next animation frame for the render loop
  37573. */
  37574. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37575. /**
  37576. * Observable raised when the engine ends the current frame
  37577. */
  37578. onEndFrameObservable: Observable<Engine>;
  37579. /**
  37580. * Observable raised when the engine is about to compile a shader
  37581. */
  37582. onBeforeShaderCompilationObservable: Observable<Engine>;
  37583. /**
  37584. * Observable raised when the engine has jsut compiled a shader
  37585. */
  37586. onAfterShaderCompilationObservable: Observable<Engine>;
  37587. /**
  37588. * Gets the audio engine
  37589. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37590. * @ignorenaming
  37591. */
  37592. static audioEngine: IAudioEngine;
  37593. /**
  37594. * Default AudioEngine factory responsible of creating the Audio Engine.
  37595. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37596. */
  37597. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37598. /**
  37599. * Default offline support factory responsible of creating a tool used to store data locally.
  37600. * By default, this will create a Database object if the workload has been embedded.
  37601. */
  37602. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37603. private _loadingScreen;
  37604. private _pointerLockRequested;
  37605. private _rescalePostProcess;
  37606. private _deterministicLockstep;
  37607. private _lockstepMaxSteps;
  37608. private _timeStep;
  37609. protected get _supportsHardwareTextureRescaling(): boolean;
  37610. private _fps;
  37611. private _deltaTime;
  37612. /** @hidden */
  37613. _drawCalls: PerfCounter;
  37614. /** 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 */
  37615. canvasTabIndex: number;
  37616. /**
  37617. * Turn this value on if you want to pause FPS computation when in background
  37618. */
  37619. disablePerformanceMonitorInBackground: boolean;
  37620. private _performanceMonitor;
  37621. /**
  37622. * Gets the performance monitor attached to this engine
  37623. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37624. */
  37625. get performanceMonitor(): PerformanceMonitor;
  37626. private _onFocus;
  37627. private _onBlur;
  37628. private _onCanvasPointerOut;
  37629. private _onCanvasBlur;
  37630. private _onCanvasFocus;
  37631. private _onFullscreenChange;
  37632. private _onPointerLockChange;
  37633. /**
  37634. * Gets the HTML element used to attach event listeners
  37635. * @returns a HTML element
  37636. */
  37637. getInputElement(): Nullable<HTMLElement>;
  37638. /**
  37639. * Creates a new engine
  37640. * @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
  37641. * @param antialias defines enable antialiasing (default: false)
  37642. * @param options defines further options to be sent to the getContext() function
  37643. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37644. */
  37645. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37646. /**
  37647. * Gets current aspect ratio
  37648. * @param viewportOwner defines the camera to use to get the aspect ratio
  37649. * @param useScreen defines if screen size must be used (or the current render target if any)
  37650. * @returns a number defining the aspect ratio
  37651. */
  37652. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37653. /**
  37654. * Gets current screen aspect ratio
  37655. * @returns a number defining the aspect ratio
  37656. */
  37657. getScreenAspectRatio(): number;
  37658. /**
  37659. * Gets the client rect of the HTML canvas attached with the current webGL context
  37660. * @returns a client rectanglee
  37661. */
  37662. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37663. /**
  37664. * Gets the client rect of the HTML element used for events
  37665. * @returns a client rectanglee
  37666. */
  37667. getInputElementClientRect(): Nullable<ClientRect>;
  37668. /**
  37669. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37670. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37671. * @returns true if engine is in deterministic lock step mode
  37672. */
  37673. isDeterministicLockStep(): boolean;
  37674. /**
  37675. * Gets the max steps when engine is running in deterministic lock step
  37676. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37677. * @returns the max steps
  37678. */
  37679. getLockstepMaxSteps(): number;
  37680. /**
  37681. * Returns the time in ms between steps when using deterministic lock step.
  37682. * @returns time step in (ms)
  37683. */
  37684. getTimeStep(): number;
  37685. /**
  37686. * Force the mipmap generation for the given render target texture
  37687. * @param texture defines the render target texture to use
  37688. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37689. */
  37690. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37691. /** States */
  37692. /**
  37693. * Set various states to the webGL context
  37694. * @param culling defines backface culling state
  37695. * @param zOffset defines the value to apply to zOffset (0 by default)
  37696. * @param force defines if states must be applied even if cache is up to date
  37697. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37698. */
  37699. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37700. /**
  37701. * Set the z offset to apply to current rendering
  37702. * @param value defines the offset to apply
  37703. */
  37704. setZOffset(value: number): void;
  37705. /**
  37706. * Gets the current value of the zOffset
  37707. * @returns the current zOffset state
  37708. */
  37709. getZOffset(): number;
  37710. /**
  37711. * Enable or disable depth buffering
  37712. * @param enable defines the state to set
  37713. */
  37714. setDepthBuffer(enable: boolean): void;
  37715. /**
  37716. * Gets a boolean indicating if depth writing is enabled
  37717. * @returns the current depth writing state
  37718. */
  37719. getDepthWrite(): boolean;
  37720. /**
  37721. * Enable or disable depth writing
  37722. * @param enable defines the state to set
  37723. */
  37724. setDepthWrite(enable: boolean): void;
  37725. /**
  37726. * Gets a boolean indicating if stencil buffer is enabled
  37727. * @returns the current stencil buffer state
  37728. */
  37729. getStencilBuffer(): boolean;
  37730. /**
  37731. * Enable or disable the stencil buffer
  37732. * @param enable defines if the stencil buffer must be enabled or disabled
  37733. */
  37734. setStencilBuffer(enable: boolean): void;
  37735. /**
  37736. * Gets the current stencil mask
  37737. * @returns a number defining the new stencil mask to use
  37738. */
  37739. getStencilMask(): number;
  37740. /**
  37741. * Sets the current stencil mask
  37742. * @param mask defines the new stencil mask to use
  37743. */
  37744. setStencilMask(mask: number): void;
  37745. /**
  37746. * Gets the current stencil function
  37747. * @returns a number defining the stencil function to use
  37748. */
  37749. getStencilFunction(): number;
  37750. /**
  37751. * Gets the current stencil reference value
  37752. * @returns a number defining the stencil reference value to use
  37753. */
  37754. getStencilFunctionReference(): number;
  37755. /**
  37756. * Gets the current stencil mask
  37757. * @returns a number defining the stencil mask to use
  37758. */
  37759. getStencilFunctionMask(): number;
  37760. /**
  37761. * Sets the current stencil function
  37762. * @param stencilFunc defines the new stencil function to use
  37763. */
  37764. setStencilFunction(stencilFunc: number): void;
  37765. /**
  37766. * Sets the current stencil reference
  37767. * @param reference defines the new stencil reference to use
  37768. */
  37769. setStencilFunctionReference(reference: number): void;
  37770. /**
  37771. * Sets the current stencil mask
  37772. * @param mask defines the new stencil mask to use
  37773. */
  37774. setStencilFunctionMask(mask: number): void;
  37775. /**
  37776. * Gets the current stencil operation when stencil fails
  37777. * @returns a number defining stencil operation to use when stencil fails
  37778. */
  37779. getStencilOperationFail(): number;
  37780. /**
  37781. * Gets the current stencil operation when depth fails
  37782. * @returns a number defining stencil operation to use when depth fails
  37783. */
  37784. getStencilOperationDepthFail(): number;
  37785. /**
  37786. * Gets the current stencil operation when stencil passes
  37787. * @returns a number defining stencil operation to use when stencil passes
  37788. */
  37789. getStencilOperationPass(): number;
  37790. /**
  37791. * Sets the stencil operation to use when stencil fails
  37792. * @param operation defines the stencil operation to use when stencil fails
  37793. */
  37794. setStencilOperationFail(operation: number): void;
  37795. /**
  37796. * Sets the stencil operation to use when depth fails
  37797. * @param operation defines the stencil operation to use when depth fails
  37798. */
  37799. setStencilOperationDepthFail(operation: number): void;
  37800. /**
  37801. * Sets the stencil operation to use when stencil passes
  37802. * @param operation defines the stencil operation to use when stencil passes
  37803. */
  37804. setStencilOperationPass(operation: number): void;
  37805. /**
  37806. * Sets a boolean indicating if the dithering state is enabled or disabled
  37807. * @param value defines the dithering state
  37808. */
  37809. setDitheringState(value: boolean): void;
  37810. /**
  37811. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37812. * @param value defines the rasterizer state
  37813. */
  37814. setRasterizerState(value: boolean): void;
  37815. /**
  37816. * Gets the current depth function
  37817. * @returns a number defining the depth function
  37818. */
  37819. getDepthFunction(): Nullable<number>;
  37820. /**
  37821. * Sets the current depth function
  37822. * @param depthFunc defines the function to use
  37823. */
  37824. setDepthFunction(depthFunc: number): void;
  37825. /**
  37826. * Sets the current depth function to GREATER
  37827. */
  37828. setDepthFunctionToGreater(): void;
  37829. /**
  37830. * Sets the current depth function to GEQUAL
  37831. */
  37832. setDepthFunctionToGreaterOrEqual(): void;
  37833. /**
  37834. * Sets the current depth function to LESS
  37835. */
  37836. setDepthFunctionToLess(): void;
  37837. /**
  37838. * Sets the current depth function to LEQUAL
  37839. */
  37840. setDepthFunctionToLessOrEqual(): void;
  37841. private _cachedStencilBuffer;
  37842. private _cachedStencilFunction;
  37843. private _cachedStencilMask;
  37844. private _cachedStencilOperationPass;
  37845. private _cachedStencilOperationFail;
  37846. private _cachedStencilOperationDepthFail;
  37847. private _cachedStencilReference;
  37848. /**
  37849. * Caches the the state of the stencil buffer
  37850. */
  37851. cacheStencilState(): void;
  37852. /**
  37853. * Restores the state of the stencil buffer
  37854. */
  37855. restoreStencilState(): void;
  37856. /**
  37857. * Directly set the WebGL Viewport
  37858. * @param x defines the x coordinate of the viewport (in screen space)
  37859. * @param y defines the y coordinate of the viewport (in screen space)
  37860. * @param width defines the width of the viewport (in screen space)
  37861. * @param height defines the height of the viewport (in screen space)
  37862. * @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
  37863. */
  37864. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37865. /**
  37866. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37867. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37868. * @param y defines the y-coordinate of the corner of the clear rectangle
  37869. * @param width defines the width of the clear rectangle
  37870. * @param height defines the height of the clear rectangle
  37871. * @param clearColor defines the clear color
  37872. */
  37873. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37874. /**
  37875. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37876. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37877. * @param y defines the y-coordinate of the corner of the clear rectangle
  37878. * @param width defines the width of the clear rectangle
  37879. * @param height defines the height of the clear rectangle
  37880. */
  37881. enableScissor(x: number, y: number, width: number, height: number): void;
  37882. /**
  37883. * Disable previously set scissor test rectangle
  37884. */
  37885. disableScissor(): void;
  37886. protected _reportDrawCall(): void;
  37887. /**
  37888. * Initializes a webVR display and starts listening to display change events
  37889. * The onVRDisplayChangedObservable will be notified upon these changes
  37890. * @returns The onVRDisplayChangedObservable
  37891. */
  37892. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37893. /** @hidden */
  37894. _prepareVRComponent(): void;
  37895. /** @hidden */
  37896. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37897. /** @hidden */
  37898. _submitVRFrame(): void;
  37899. /**
  37900. * Call this function to leave webVR mode
  37901. * Will do nothing if webVR is not supported or if there is no webVR device
  37902. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37903. */
  37904. disableVR(): void;
  37905. /**
  37906. * Gets a boolean indicating that the system is in VR mode and is presenting
  37907. * @returns true if VR mode is engaged
  37908. */
  37909. isVRPresenting(): boolean;
  37910. /** @hidden */
  37911. _requestVRFrame(): void;
  37912. /** @hidden */
  37913. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37914. /**
  37915. * Gets the source code of the vertex shader associated with a specific webGL program
  37916. * @param program defines the program to use
  37917. * @returns a string containing the source code of the vertex shader associated with the program
  37918. */
  37919. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37920. /**
  37921. * Gets the source code of the fragment shader associated with a specific webGL program
  37922. * @param program defines the program to use
  37923. * @returns a string containing the source code of the fragment shader associated with the program
  37924. */
  37925. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37926. /**
  37927. * Sets a depth stencil texture from a render target to the according uniform.
  37928. * @param channel The texture channel
  37929. * @param uniform The uniform to set
  37930. * @param texture The render target texture containing the depth stencil texture to apply
  37931. */
  37932. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37933. /**
  37934. * Sets a texture to the webGL context from a postprocess
  37935. * @param channel defines the channel to use
  37936. * @param postProcess defines the source postprocess
  37937. */
  37938. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37939. /**
  37940. * Binds the output of the passed in post process to the texture channel specified
  37941. * @param channel The channel the texture should be bound to
  37942. * @param postProcess The post process which's output should be bound
  37943. */
  37944. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37945. protected _rebuildBuffers(): void;
  37946. /** @hidden */
  37947. _renderFrame(): void;
  37948. _renderLoop(): void;
  37949. /** @hidden */
  37950. _renderViews(): boolean;
  37951. /**
  37952. * Toggle full screen mode
  37953. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37954. */
  37955. switchFullscreen(requestPointerLock: boolean): void;
  37956. /**
  37957. * Enters full screen mode
  37958. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37959. */
  37960. enterFullscreen(requestPointerLock: boolean): void;
  37961. /**
  37962. * Exits full screen mode
  37963. */
  37964. exitFullscreen(): void;
  37965. /**
  37966. * Enters Pointerlock mode
  37967. */
  37968. enterPointerlock(): void;
  37969. /**
  37970. * Exits Pointerlock mode
  37971. */
  37972. exitPointerlock(): void;
  37973. /**
  37974. * Begin a new frame
  37975. */
  37976. beginFrame(): void;
  37977. /**
  37978. * Enf the current frame
  37979. */
  37980. endFrame(): void;
  37981. resize(): void;
  37982. /**
  37983. * Force a specific size of the canvas
  37984. * @param width defines the new canvas' width
  37985. * @param height defines the new canvas' height
  37986. * @returns true if the size was changed
  37987. */
  37988. setSize(width: number, height: number): boolean;
  37989. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37990. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37991. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37992. _releaseTexture(texture: InternalTexture): void;
  37993. /**
  37994. * @hidden
  37995. * Rescales a texture
  37996. * @param source input texutre
  37997. * @param destination destination texture
  37998. * @param scene scene to use to render the resize
  37999. * @param internalFormat format to use when resizing
  38000. * @param onComplete callback to be called when resize has completed
  38001. */
  38002. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38003. /**
  38004. * Gets the current framerate
  38005. * @returns a number representing the framerate
  38006. */
  38007. getFps(): number;
  38008. /**
  38009. * Gets the time spent between current and previous frame
  38010. * @returns a number representing the delta time in ms
  38011. */
  38012. getDeltaTime(): number;
  38013. private _measureFps;
  38014. /** @hidden */
  38015. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38016. /**
  38017. * Updates the sample count of a render target texture
  38018. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38019. * @param texture defines the texture to update
  38020. * @param samples defines the sample count to set
  38021. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38022. */
  38023. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38024. /**
  38025. * Updates a depth texture Comparison Mode and Function.
  38026. * If the comparison Function is equal to 0, the mode will be set to none.
  38027. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38028. * @param texture The texture to set the comparison function for
  38029. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38030. */
  38031. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38032. /**
  38033. * Creates a webGL buffer to use with instanciation
  38034. * @param capacity defines the size of the buffer
  38035. * @returns the webGL buffer
  38036. */
  38037. createInstancesBuffer(capacity: number): DataBuffer;
  38038. /**
  38039. * Delete a webGL buffer used with instanciation
  38040. * @param buffer defines the webGL buffer to delete
  38041. */
  38042. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38043. private _clientWaitAsync;
  38044. /** @hidden */
  38045. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38046. dispose(): void;
  38047. private _disableTouchAction;
  38048. /**
  38049. * Display the loading screen
  38050. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38051. */
  38052. displayLoadingUI(): void;
  38053. /**
  38054. * Hide the loading screen
  38055. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38056. */
  38057. hideLoadingUI(): void;
  38058. /**
  38059. * Gets the current loading screen object
  38060. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38061. */
  38062. get loadingScreen(): ILoadingScreen;
  38063. /**
  38064. * Sets the current loading screen object
  38065. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38066. */
  38067. set loadingScreen(loadingScreen: ILoadingScreen);
  38068. /**
  38069. * Sets the current loading screen text
  38070. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38071. */
  38072. set loadingUIText(text: string);
  38073. /**
  38074. * Sets the current loading screen background color
  38075. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38076. */
  38077. set loadingUIBackgroundColor(color: string);
  38078. /** Pointerlock and fullscreen */
  38079. /**
  38080. * Ask the browser to promote the current element to pointerlock mode
  38081. * @param element defines the DOM element to promote
  38082. */
  38083. static _RequestPointerlock(element: HTMLElement): void;
  38084. /**
  38085. * Asks the browser to exit pointerlock mode
  38086. */
  38087. static _ExitPointerlock(): void;
  38088. /**
  38089. * Ask the browser to promote the current element to fullscreen rendering mode
  38090. * @param element defines the DOM element to promote
  38091. */
  38092. static _RequestFullscreen(element: HTMLElement): void;
  38093. /**
  38094. * Asks the browser to exit fullscreen mode
  38095. */
  38096. static _ExitFullscreen(): void;
  38097. }
  38098. }
  38099. declare module BABYLON {
  38100. /**
  38101. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38102. * during the life time of the application.
  38103. */
  38104. export class EngineStore {
  38105. /** Gets the list of created engines */
  38106. static Instances: Engine[];
  38107. /** @hidden */
  38108. static _LastCreatedScene: Nullable<Scene>;
  38109. /**
  38110. * Gets the latest created engine
  38111. */
  38112. static get LastCreatedEngine(): Nullable<Engine>;
  38113. /**
  38114. * Gets the latest created scene
  38115. */
  38116. static get LastCreatedScene(): Nullable<Scene>;
  38117. /**
  38118. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38119. * @ignorenaming
  38120. */
  38121. static UseFallbackTexture: boolean;
  38122. /**
  38123. * Texture content used if a texture cannot loaded
  38124. * @ignorenaming
  38125. */
  38126. static FallbackTexture: string;
  38127. }
  38128. }
  38129. declare module BABYLON {
  38130. /**
  38131. * Helper class that provides a small promise polyfill
  38132. */
  38133. export class PromisePolyfill {
  38134. /**
  38135. * Static function used to check if the polyfill is required
  38136. * If this is the case then the function will inject the polyfill to window.Promise
  38137. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38138. */
  38139. static Apply(force?: boolean): void;
  38140. }
  38141. }
  38142. declare module BABYLON {
  38143. /**
  38144. * Interface for screenshot methods with describe argument called `size` as object with options
  38145. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38146. */
  38147. export interface IScreenshotSize {
  38148. /**
  38149. * number in pixels for canvas height
  38150. */
  38151. height?: number;
  38152. /**
  38153. * multiplier allowing render at a higher or lower resolution
  38154. * If value is defined then height and width will be ignored and taken from camera
  38155. */
  38156. precision?: number;
  38157. /**
  38158. * number in pixels for canvas width
  38159. */
  38160. width?: number;
  38161. }
  38162. }
  38163. declare module BABYLON {
  38164. interface IColor4Like {
  38165. r: float;
  38166. g: float;
  38167. b: float;
  38168. a: float;
  38169. }
  38170. /**
  38171. * Class containing a set of static utilities functions
  38172. */
  38173. export class Tools {
  38174. /**
  38175. * Gets or sets the base URL to use to load assets
  38176. */
  38177. static get BaseUrl(): string;
  38178. static set BaseUrl(value: string);
  38179. /**
  38180. * Enable/Disable Custom HTTP Request Headers globally.
  38181. * default = false
  38182. * @see CustomRequestHeaders
  38183. */
  38184. static UseCustomRequestHeaders: boolean;
  38185. /**
  38186. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38187. * i.e. when loading files, where the server/service expects an Authorization header
  38188. */
  38189. static CustomRequestHeaders: {
  38190. [key: string]: string;
  38191. };
  38192. /**
  38193. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38194. */
  38195. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38196. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38197. /**
  38198. * Default behaviour for cors in the application.
  38199. * It can be a string if the expected behavior is identical in the entire app.
  38200. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38201. */
  38202. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38203. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38204. /**
  38205. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38206. * @ignorenaming
  38207. */
  38208. static get UseFallbackTexture(): boolean;
  38209. static set UseFallbackTexture(value: boolean);
  38210. /**
  38211. * Use this object to register external classes like custom textures or material
  38212. * to allow the laoders to instantiate them
  38213. */
  38214. static get RegisteredExternalClasses(): {
  38215. [key: string]: Object;
  38216. };
  38217. static set RegisteredExternalClasses(classes: {
  38218. [key: string]: Object;
  38219. });
  38220. /**
  38221. * Texture content used if a texture cannot loaded
  38222. * @ignorenaming
  38223. */
  38224. static get fallbackTexture(): string;
  38225. static set fallbackTexture(value: string);
  38226. /**
  38227. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38228. * @param u defines the coordinate on X axis
  38229. * @param v defines the coordinate on Y axis
  38230. * @param width defines the width of the source data
  38231. * @param height defines the height of the source data
  38232. * @param pixels defines the source byte array
  38233. * @param color defines the output color
  38234. */
  38235. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38236. /**
  38237. * Interpolates between a and b via alpha
  38238. * @param a The lower value (returned when alpha = 0)
  38239. * @param b The upper value (returned when alpha = 1)
  38240. * @param alpha The interpolation-factor
  38241. * @return The mixed value
  38242. */
  38243. static Mix(a: number, b: number, alpha: number): number;
  38244. /**
  38245. * Tries to instantiate a new object from a given class name
  38246. * @param className defines the class name to instantiate
  38247. * @returns the new object or null if the system was not able to do the instantiation
  38248. */
  38249. static Instantiate(className: string): any;
  38250. /**
  38251. * Provides a slice function that will work even on IE
  38252. * @param data defines the array to slice
  38253. * @param start defines the start of the data (optional)
  38254. * @param end defines the end of the data (optional)
  38255. * @returns the new sliced array
  38256. */
  38257. static Slice<T>(data: T, start?: number, end?: number): T;
  38258. /**
  38259. * Polyfill for setImmediate
  38260. * @param action defines the action to execute after the current execution block
  38261. */
  38262. static SetImmediate(action: () => void): void;
  38263. /**
  38264. * Function indicating if a number is an exponent of 2
  38265. * @param value defines the value to test
  38266. * @returns true if the value is an exponent of 2
  38267. */
  38268. static IsExponentOfTwo(value: number): boolean;
  38269. private static _tmpFloatArray;
  38270. /**
  38271. * Returns the nearest 32-bit single precision float representation of a Number
  38272. * @param value A Number. If the parameter is of a different type, it will get converted
  38273. * to a number or to NaN if it cannot be converted
  38274. * @returns number
  38275. */
  38276. static FloatRound(value: number): number;
  38277. /**
  38278. * Extracts the filename from a path
  38279. * @param path defines the path to use
  38280. * @returns the filename
  38281. */
  38282. static GetFilename(path: string): string;
  38283. /**
  38284. * Extracts the "folder" part of a path (everything before the filename).
  38285. * @param uri The URI to extract the info from
  38286. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38287. * @returns The "folder" part of the path
  38288. */
  38289. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38290. /**
  38291. * Extracts text content from a DOM element hierarchy
  38292. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38293. */
  38294. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38295. /**
  38296. * Convert an angle in radians to degrees
  38297. * @param angle defines the angle to convert
  38298. * @returns the angle in degrees
  38299. */
  38300. static ToDegrees(angle: number): number;
  38301. /**
  38302. * Convert an angle in degrees to radians
  38303. * @param angle defines the angle to convert
  38304. * @returns the angle in radians
  38305. */
  38306. static ToRadians(angle: number): number;
  38307. /**
  38308. * Returns an array if obj is not an array
  38309. * @param obj defines the object to evaluate as an array
  38310. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38311. * @returns either obj directly if obj is an array or a new array containing obj
  38312. */
  38313. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38314. /**
  38315. * Gets the pointer prefix to use
  38316. * @param engine defines the engine we are finding the prefix for
  38317. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38318. */
  38319. static GetPointerPrefix(engine: Engine): string;
  38320. /**
  38321. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38322. * @param url define the url we are trying
  38323. * @param element define the dom element where to configure the cors policy
  38324. */
  38325. static SetCorsBehavior(url: string | string[], element: {
  38326. crossOrigin: string | null;
  38327. }): void;
  38328. /**
  38329. * Removes unwanted characters from an url
  38330. * @param url defines the url to clean
  38331. * @returns the cleaned url
  38332. */
  38333. static CleanUrl(url: string): string;
  38334. /**
  38335. * Gets or sets a function used to pre-process url before using them to load assets
  38336. */
  38337. static get PreprocessUrl(): (url: string) => string;
  38338. static set PreprocessUrl(processor: (url: string) => string);
  38339. /**
  38340. * Loads an image as an HTMLImageElement.
  38341. * @param input url string, ArrayBuffer, or Blob to load
  38342. * @param onLoad callback called when the image successfully loads
  38343. * @param onError callback called when the image fails to load
  38344. * @param offlineProvider offline provider for caching
  38345. * @param mimeType optional mime type
  38346. * @returns the HTMLImageElement of the loaded image
  38347. */
  38348. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38349. /**
  38350. * Loads a file from a url
  38351. * @param url url string, ArrayBuffer, or Blob to load
  38352. * @param onSuccess callback called when the file successfully loads
  38353. * @param onProgress callback called while file is loading (if the server supports this mode)
  38354. * @param offlineProvider defines the offline provider for caching
  38355. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38356. * @param onError callback called when the file fails to load
  38357. * @returns a file request object
  38358. */
  38359. 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;
  38360. /**
  38361. * Loads a file from a url
  38362. * @param url the file url to load
  38363. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38364. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38365. */
  38366. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38367. /**
  38368. * Load a script (identified by an url). When the url returns, the
  38369. * content of this file is added into a new script element, attached to the DOM (body element)
  38370. * @param scriptUrl defines the url of the script to laod
  38371. * @param onSuccess defines the callback called when the script is loaded
  38372. * @param onError defines the callback to call if an error occurs
  38373. * @param scriptId defines the id of the script element
  38374. */
  38375. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38376. /**
  38377. * Load an asynchronous script (identified by an url). When the url returns, the
  38378. * content of this file is added into a new script element, attached to the DOM (body element)
  38379. * @param scriptUrl defines the url of the script to laod
  38380. * @param scriptId defines the id of the script element
  38381. * @returns a promise request object
  38382. */
  38383. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38384. /**
  38385. * Loads a file from a blob
  38386. * @param fileToLoad defines the blob to use
  38387. * @param callback defines the callback to call when data is loaded
  38388. * @param progressCallback defines the callback to call during loading process
  38389. * @returns a file request object
  38390. */
  38391. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38392. /**
  38393. * Reads a file from a File object
  38394. * @param file defines the file to load
  38395. * @param onSuccess defines the callback to call when data is loaded
  38396. * @param onProgress defines the callback to call during loading process
  38397. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38398. * @param onError defines the callback to call when an error occurs
  38399. * @returns a file request object
  38400. */
  38401. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38402. /**
  38403. * Creates a data url from a given string content
  38404. * @param content defines the content to convert
  38405. * @returns the new data url link
  38406. */
  38407. static FileAsURL(content: string): string;
  38408. /**
  38409. * Format the given number to a specific decimal format
  38410. * @param value defines the number to format
  38411. * @param decimals defines the number of decimals to use
  38412. * @returns the formatted string
  38413. */
  38414. static Format(value: number, decimals?: number): string;
  38415. /**
  38416. * Tries to copy an object by duplicating every property
  38417. * @param source defines the source object
  38418. * @param destination defines the target object
  38419. * @param doNotCopyList defines a list of properties to avoid
  38420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38421. */
  38422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38423. /**
  38424. * Gets a boolean indicating if the given object has no own property
  38425. * @param obj defines the object to test
  38426. * @returns true if object has no own property
  38427. */
  38428. static IsEmpty(obj: any): boolean;
  38429. /**
  38430. * Function used to register events at window level
  38431. * @param windowElement defines the Window object to use
  38432. * @param events defines the events to register
  38433. */
  38434. static RegisterTopRootEvents(windowElement: Window, events: {
  38435. name: string;
  38436. handler: Nullable<(e: FocusEvent) => any>;
  38437. }[]): void;
  38438. /**
  38439. * Function used to unregister events from window level
  38440. * @param windowElement defines the Window object to use
  38441. * @param events defines the events to unregister
  38442. */
  38443. static UnregisterTopRootEvents(windowElement: Window, events: {
  38444. name: string;
  38445. handler: Nullable<(e: FocusEvent) => any>;
  38446. }[]): void;
  38447. /**
  38448. * @ignore
  38449. */
  38450. static _ScreenshotCanvas: HTMLCanvasElement;
  38451. /**
  38452. * Dumps the current bound framebuffer
  38453. * @param width defines the rendering width
  38454. * @param height defines the rendering height
  38455. * @param engine defines the hosting engine
  38456. * @param successCallback defines the callback triggered once the data are available
  38457. * @param mimeType defines the mime type of the result
  38458. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38459. */
  38460. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38461. /**
  38462. * Converts the canvas data to blob.
  38463. * This acts as a polyfill for browsers not supporting the to blob function.
  38464. * @param canvas Defines the canvas to extract the data from
  38465. * @param successCallback Defines the callback triggered once the data are available
  38466. * @param mimeType Defines the mime type of the result
  38467. */
  38468. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38469. /**
  38470. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38471. * @param successCallback defines the callback triggered once the data are available
  38472. * @param mimeType defines the mime type of the result
  38473. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38474. */
  38475. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38476. /**
  38477. * Downloads a blob in the browser
  38478. * @param blob defines the blob to download
  38479. * @param fileName defines the name of the downloaded file
  38480. */
  38481. static Download(blob: Blob, fileName: string): void;
  38482. /**
  38483. * Captures a screenshot of the current rendering
  38484. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38485. * @param engine defines the rendering engine
  38486. * @param camera defines the source camera
  38487. * @param size This parameter can be set to a single number or to an object with the
  38488. * following (optional) properties: precision, width, height. If a single number is passed,
  38489. * it will be used for both width and height. If an object is passed, the screenshot size
  38490. * will be derived from the parameters. The precision property is a multiplier allowing
  38491. * rendering at a higher or lower resolution
  38492. * @param successCallback defines the callback receives a single parameter which contains the
  38493. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38494. * src parameter of an <img> to display it
  38495. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38496. * Check your browser for supported MIME types
  38497. */
  38498. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38499. /**
  38500. * Captures a screenshot of the current rendering
  38501. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38502. * @param engine defines the rendering engine
  38503. * @param camera defines the source camera
  38504. * @param size This parameter can be set to a single number or to an object with the
  38505. * following (optional) properties: precision, width, height. If a single number is passed,
  38506. * it will be used for both width and height. If an object is passed, the screenshot size
  38507. * will be derived from the parameters. The precision property is a multiplier allowing
  38508. * rendering at a higher or lower resolution
  38509. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38510. * Check your browser for supported MIME types
  38511. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38512. * to the src parameter of an <img> to display it
  38513. */
  38514. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38515. /**
  38516. * Generates an image screenshot from the specified camera.
  38517. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38518. * @param engine The engine to use for rendering
  38519. * @param camera The camera to use for rendering
  38520. * @param size This parameter can be set to a single number or to an object with the
  38521. * following (optional) properties: precision, width, height. If a single number is passed,
  38522. * it will be used for both width and height. If an object is passed, the screenshot size
  38523. * will be derived from the parameters. The precision property is a multiplier allowing
  38524. * rendering at a higher or lower resolution
  38525. * @param successCallback The callback receives a single parameter which contains the
  38526. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38527. * src parameter of an <img> to display it
  38528. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38529. * Check your browser for supported MIME types
  38530. * @param samples Texture samples (default: 1)
  38531. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38532. * @param fileName A name for for the downloaded file.
  38533. */
  38534. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38535. /**
  38536. * Generates an image screenshot from the specified camera.
  38537. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38538. * @param engine The engine to use for rendering
  38539. * @param camera The camera to use for rendering
  38540. * @param size This parameter can be set to a single number or to an object with the
  38541. * following (optional) properties: precision, width, height. If a single number is passed,
  38542. * it will be used for both width and height. If an object is passed, the screenshot size
  38543. * will be derived from the parameters. The precision property is a multiplier allowing
  38544. * rendering at a higher or lower resolution
  38545. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38546. * Check your browser for supported MIME types
  38547. * @param samples Texture samples (default: 1)
  38548. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38549. * @param fileName A name for for the downloaded file.
  38550. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38551. * to the src parameter of an <img> to display it
  38552. */
  38553. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38554. /**
  38555. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38556. * Be aware Math.random() could cause collisions, but:
  38557. * "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"
  38558. * @returns a pseudo random id
  38559. */
  38560. static RandomId(): string;
  38561. /**
  38562. * Test if the given uri is a base64 string
  38563. * @param uri The uri to test
  38564. * @return True if the uri is a base64 string or false otherwise
  38565. */
  38566. static IsBase64(uri: string): boolean;
  38567. /**
  38568. * Decode the given base64 uri.
  38569. * @param uri The uri to decode
  38570. * @return The decoded base64 data.
  38571. */
  38572. static DecodeBase64(uri: string): ArrayBuffer;
  38573. /**
  38574. * Gets the absolute url.
  38575. * @param url the input url
  38576. * @return the absolute url
  38577. */
  38578. static GetAbsoluteUrl(url: string): string;
  38579. /**
  38580. * No log
  38581. */
  38582. static readonly NoneLogLevel: number;
  38583. /**
  38584. * Only message logs
  38585. */
  38586. static readonly MessageLogLevel: number;
  38587. /**
  38588. * Only warning logs
  38589. */
  38590. static readonly WarningLogLevel: number;
  38591. /**
  38592. * Only error logs
  38593. */
  38594. static readonly ErrorLogLevel: number;
  38595. /**
  38596. * All logs
  38597. */
  38598. static readonly AllLogLevel: number;
  38599. /**
  38600. * Gets a value indicating the number of loading errors
  38601. * @ignorenaming
  38602. */
  38603. static get errorsCount(): number;
  38604. /**
  38605. * Callback called when a new log is added
  38606. */
  38607. static OnNewCacheEntry: (entry: string) => void;
  38608. /**
  38609. * Log a message to the console
  38610. * @param message defines the message to log
  38611. */
  38612. static Log(message: string): void;
  38613. /**
  38614. * Write a warning message to the console
  38615. * @param message defines the message to log
  38616. */
  38617. static Warn(message: string): void;
  38618. /**
  38619. * Write an error message to the console
  38620. * @param message defines the message to log
  38621. */
  38622. static Error(message: string): void;
  38623. /**
  38624. * Gets current log cache (list of logs)
  38625. */
  38626. static get LogCache(): string;
  38627. /**
  38628. * Clears the log cache
  38629. */
  38630. static ClearLogCache(): void;
  38631. /**
  38632. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38633. */
  38634. static set LogLevels(level: number);
  38635. /**
  38636. * Checks if the window object exists
  38637. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38638. */
  38639. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38640. /**
  38641. * No performance log
  38642. */
  38643. static readonly PerformanceNoneLogLevel: number;
  38644. /**
  38645. * Use user marks to log performance
  38646. */
  38647. static readonly PerformanceUserMarkLogLevel: number;
  38648. /**
  38649. * Log performance to the console
  38650. */
  38651. static readonly PerformanceConsoleLogLevel: number;
  38652. private static _performance;
  38653. /**
  38654. * Sets the current performance log level
  38655. */
  38656. static set PerformanceLogLevel(level: number);
  38657. private static _StartPerformanceCounterDisabled;
  38658. private static _EndPerformanceCounterDisabled;
  38659. private static _StartUserMark;
  38660. private static _EndUserMark;
  38661. private static _StartPerformanceConsole;
  38662. private static _EndPerformanceConsole;
  38663. /**
  38664. * Starts a performance counter
  38665. */
  38666. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38667. /**
  38668. * Ends a specific performance coutner
  38669. */
  38670. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38671. /**
  38672. * Gets either window.performance.now() if supported or Date.now() else
  38673. */
  38674. static get Now(): number;
  38675. /**
  38676. * This method will return the name of the class used to create the instance of the given object.
  38677. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38678. * @param object the object to get the class name from
  38679. * @param isType defines if the object is actually a type
  38680. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38681. */
  38682. static GetClassName(object: any, isType?: boolean): string;
  38683. /**
  38684. * Gets the first element of an array satisfying a given predicate
  38685. * @param array defines the array to browse
  38686. * @param predicate defines the predicate to use
  38687. * @returns null if not found or the element
  38688. */
  38689. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38690. /**
  38691. * This method will return the name of the full name of the class, including its owning module (if any).
  38692. * 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).
  38693. * @param object the object to get the class name from
  38694. * @param isType defines if the object is actually a type
  38695. * @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.
  38696. * @ignorenaming
  38697. */
  38698. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38699. /**
  38700. * Returns a promise that resolves after the given amount of time.
  38701. * @param delay Number of milliseconds to delay
  38702. * @returns Promise that resolves after the given amount of time
  38703. */
  38704. static DelayAsync(delay: number): Promise<void>;
  38705. /**
  38706. * Utility function to detect if the current user agent is Safari
  38707. * @returns whether or not the current user agent is safari
  38708. */
  38709. static IsSafari(): boolean;
  38710. }
  38711. /**
  38712. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38713. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38714. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38715. * @param name The name of the class, case should be preserved
  38716. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38717. */
  38718. export function className(name: string, module?: string): (target: Object) => void;
  38719. /**
  38720. * An implementation of a loop for asynchronous functions.
  38721. */
  38722. export class AsyncLoop {
  38723. /**
  38724. * Defines the number of iterations for the loop
  38725. */
  38726. iterations: number;
  38727. /**
  38728. * Defines the current index of the loop.
  38729. */
  38730. index: number;
  38731. private _done;
  38732. private _fn;
  38733. private _successCallback;
  38734. /**
  38735. * Constructor.
  38736. * @param iterations the number of iterations.
  38737. * @param func the function to run each iteration
  38738. * @param successCallback the callback that will be called upon succesful execution
  38739. * @param offset starting offset.
  38740. */
  38741. constructor(
  38742. /**
  38743. * Defines the number of iterations for the loop
  38744. */
  38745. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38746. /**
  38747. * Execute the next iteration. Must be called after the last iteration was finished.
  38748. */
  38749. executeNext(): void;
  38750. /**
  38751. * Break the loop and run the success callback.
  38752. */
  38753. breakLoop(): void;
  38754. /**
  38755. * Create and run an async loop.
  38756. * @param iterations the number of iterations.
  38757. * @param fn the function to run each iteration
  38758. * @param successCallback the callback that will be called upon succesful execution
  38759. * @param offset starting offset.
  38760. * @returns the created async loop object
  38761. */
  38762. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38763. /**
  38764. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38765. * @param iterations total number of iterations
  38766. * @param syncedIterations number of synchronous iterations in each async iteration.
  38767. * @param fn the function to call each iteration.
  38768. * @param callback a success call back that will be called when iterating stops.
  38769. * @param breakFunction a break condition (optional)
  38770. * @param timeout timeout settings for the setTimeout function. default - 0.
  38771. * @returns the created async loop object
  38772. */
  38773. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38774. }
  38775. }
  38776. declare module BABYLON {
  38777. /**
  38778. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38779. * The underlying implementation relies on an associative array to ensure the best performances.
  38780. * The value can be anything including 'null' but except 'undefined'
  38781. */
  38782. export class StringDictionary<T> {
  38783. /**
  38784. * This will clear this dictionary and copy the content from the 'source' one.
  38785. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38786. * @param source the dictionary to take the content from and copy to this dictionary
  38787. */
  38788. copyFrom(source: StringDictionary<T>): void;
  38789. /**
  38790. * Get a value based from its key
  38791. * @param key the given key to get the matching value from
  38792. * @return the value if found, otherwise undefined is returned
  38793. */
  38794. get(key: string): T | undefined;
  38795. /**
  38796. * Get a value from its key or add it if it doesn't exist.
  38797. * This method will ensure you that a given key/data will be present in the dictionary.
  38798. * @param key the given key to get the matching value from
  38799. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38800. * The factory will only be invoked if there's no data for the given key.
  38801. * @return the value corresponding to the key.
  38802. */
  38803. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38804. /**
  38805. * Get a value from its key if present in the dictionary otherwise add it
  38806. * @param key the key to get the value from
  38807. * @param val if there's no such key/value pair in the dictionary add it with this value
  38808. * @return the value corresponding to the key
  38809. */
  38810. getOrAdd(key: string, val: T): T;
  38811. /**
  38812. * Check if there's a given key in the dictionary
  38813. * @param key the key to check for
  38814. * @return true if the key is present, false otherwise
  38815. */
  38816. contains(key: string): boolean;
  38817. /**
  38818. * Add a new key and its corresponding value
  38819. * @param key the key to add
  38820. * @param value the value corresponding to the key
  38821. * @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
  38822. */
  38823. add(key: string, value: T): boolean;
  38824. /**
  38825. * Update a specific value associated to a key
  38826. * @param key defines the key to use
  38827. * @param value defines the value to store
  38828. * @returns true if the value was updated (or false if the key was not found)
  38829. */
  38830. set(key: string, value: T): boolean;
  38831. /**
  38832. * Get the element of the given key and remove it from the dictionary
  38833. * @param key defines the key to search
  38834. * @returns the value associated with the key or null if not found
  38835. */
  38836. getAndRemove(key: string): Nullable<T>;
  38837. /**
  38838. * Remove a key/value from the dictionary.
  38839. * @param key the key to remove
  38840. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38841. */
  38842. remove(key: string): boolean;
  38843. /**
  38844. * Clear the whole content of the dictionary
  38845. */
  38846. clear(): void;
  38847. /**
  38848. * Gets the current count
  38849. */
  38850. get count(): number;
  38851. /**
  38852. * Execute a callback on each key/val of the dictionary.
  38853. * Note that you can remove any element in this dictionary in the callback implementation
  38854. * @param callback the callback to execute on a given key/value pair
  38855. */
  38856. forEach(callback: (key: string, val: T) => void): void;
  38857. /**
  38858. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38859. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38860. * Note that you can remove any element in this dictionary in the callback implementation
  38861. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38862. * @returns the first item
  38863. */
  38864. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38865. private _count;
  38866. private _data;
  38867. }
  38868. }
  38869. declare module BABYLON {
  38870. /** @hidden */
  38871. export interface ICollisionCoordinator {
  38872. createCollider(): Collider;
  38873. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38874. init(scene: Scene): void;
  38875. }
  38876. /** @hidden */
  38877. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38878. private _scene;
  38879. private _scaledPosition;
  38880. private _scaledVelocity;
  38881. private _finalPosition;
  38882. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38883. createCollider(): Collider;
  38884. init(scene: Scene): void;
  38885. private _collideWithWorld;
  38886. }
  38887. }
  38888. declare module BABYLON {
  38889. /**
  38890. * Class used to manage all inputs for the scene.
  38891. */
  38892. export class InputManager {
  38893. /** The distance in pixel that you have to move to prevent some events */
  38894. static DragMovementThreshold: number;
  38895. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38896. static LongPressDelay: number;
  38897. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38898. static DoubleClickDelay: number;
  38899. /** If you need to check double click without raising a single click at first click, enable this flag */
  38900. static ExclusiveDoubleClickMode: boolean;
  38901. /** 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. */
  38902. private _alreadyAttached;
  38903. private _wheelEventName;
  38904. private _onPointerMove;
  38905. private _onPointerDown;
  38906. private _onPointerUp;
  38907. private _initClickEvent;
  38908. private _initActionManager;
  38909. private _delayedSimpleClick;
  38910. private _delayedSimpleClickTimeout;
  38911. private _previousDelayedSimpleClickTimeout;
  38912. private _meshPickProceed;
  38913. private _previousButtonPressed;
  38914. private _currentPickResult;
  38915. private _previousPickResult;
  38916. private _totalPointersPressed;
  38917. private _doubleClickOccured;
  38918. private _pointerOverMesh;
  38919. private _pickedDownMesh;
  38920. private _pickedUpMesh;
  38921. private _pointerX;
  38922. private _pointerY;
  38923. private _unTranslatedPointerX;
  38924. private _unTranslatedPointerY;
  38925. private _startingPointerPosition;
  38926. private _previousStartingPointerPosition;
  38927. private _startingPointerTime;
  38928. private _previousStartingPointerTime;
  38929. private _pointerCaptures;
  38930. private _onKeyDown;
  38931. private _onKeyUp;
  38932. private _onCanvasFocusObserver;
  38933. private _onCanvasBlurObserver;
  38934. private _scene;
  38935. /**
  38936. * Creates a new InputManager
  38937. * @param scene defines the hosting scene
  38938. */
  38939. constructor(scene: Scene);
  38940. /**
  38941. * Gets the mesh that is currently under the pointer
  38942. */
  38943. get meshUnderPointer(): Nullable<AbstractMesh>;
  38944. /**
  38945. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38946. */
  38947. get unTranslatedPointer(): Vector2;
  38948. /**
  38949. * Gets or sets the current on-screen X position of the pointer
  38950. */
  38951. get pointerX(): number;
  38952. set pointerX(value: number);
  38953. /**
  38954. * Gets or sets the current on-screen Y position of the pointer
  38955. */
  38956. get pointerY(): number;
  38957. set pointerY(value: number);
  38958. private _updatePointerPosition;
  38959. private _processPointerMove;
  38960. private _setRayOnPointerInfo;
  38961. private _checkPrePointerObservable;
  38962. /**
  38963. * Use this method to simulate a pointer move on a mesh
  38964. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38965. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38966. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38967. */
  38968. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38969. /**
  38970. * Use this method to simulate a pointer down on a mesh
  38971. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38972. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38973. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38974. */
  38975. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38976. private _processPointerDown;
  38977. /** @hidden */
  38978. _isPointerSwiping(): boolean;
  38979. /**
  38980. * Use this method to simulate a pointer up on a mesh
  38981. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38982. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38983. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38984. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38985. */
  38986. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38987. private _processPointerUp;
  38988. /**
  38989. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38990. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38991. * @returns true if the pointer was captured
  38992. */
  38993. isPointerCaptured(pointerId?: number): boolean;
  38994. /**
  38995. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38996. * @param attachUp defines if you want to attach events to pointerup
  38997. * @param attachDown defines if you want to attach events to pointerdown
  38998. * @param attachMove defines if you want to attach events to pointermove
  38999. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39000. */
  39001. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39002. /**
  39003. * Detaches all event handlers
  39004. */
  39005. detachControl(): void;
  39006. /**
  39007. * Force the value of meshUnderPointer
  39008. * @param mesh defines the mesh to use
  39009. */
  39010. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39011. /**
  39012. * Gets the mesh under the pointer
  39013. * @returns a Mesh or null if no mesh is under the pointer
  39014. */
  39015. getPointerOverMesh(): Nullable<AbstractMesh>;
  39016. }
  39017. }
  39018. declare module BABYLON {
  39019. /**
  39020. * This class defines the direct association between an animation and a target
  39021. */
  39022. export class TargetedAnimation {
  39023. /**
  39024. * Animation to perform
  39025. */
  39026. animation: Animation;
  39027. /**
  39028. * Target to animate
  39029. */
  39030. target: any;
  39031. /**
  39032. * Returns the string "TargetedAnimation"
  39033. * @returns "TargetedAnimation"
  39034. */
  39035. getClassName(): string;
  39036. /**
  39037. * Serialize the object
  39038. * @returns the JSON object representing the current entity
  39039. */
  39040. serialize(): any;
  39041. }
  39042. /**
  39043. * Use this class to create coordinated animations on multiple targets
  39044. */
  39045. export class AnimationGroup implements IDisposable {
  39046. /** The name of the animation group */
  39047. name: string;
  39048. private _scene;
  39049. private _targetedAnimations;
  39050. private _animatables;
  39051. private _from;
  39052. private _to;
  39053. private _isStarted;
  39054. private _isPaused;
  39055. private _speedRatio;
  39056. private _loopAnimation;
  39057. private _isAdditive;
  39058. /**
  39059. * Gets or sets the unique id of the node
  39060. */
  39061. uniqueId: number;
  39062. /**
  39063. * This observable will notify when one animation have ended
  39064. */
  39065. onAnimationEndObservable: Observable<TargetedAnimation>;
  39066. /**
  39067. * Observer raised when one animation loops
  39068. */
  39069. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39070. /**
  39071. * Observer raised when all animations have looped
  39072. */
  39073. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39074. /**
  39075. * This observable will notify when all animations have ended.
  39076. */
  39077. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39078. /**
  39079. * This observable will notify when all animations have paused.
  39080. */
  39081. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39082. /**
  39083. * This observable will notify when all animations are playing.
  39084. */
  39085. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39086. /**
  39087. * Gets the first frame
  39088. */
  39089. get from(): number;
  39090. /**
  39091. * Gets the last frame
  39092. */
  39093. get to(): number;
  39094. /**
  39095. * Define if the animations are started
  39096. */
  39097. get isStarted(): boolean;
  39098. /**
  39099. * Gets a value indicating that the current group is playing
  39100. */
  39101. get isPlaying(): boolean;
  39102. /**
  39103. * Gets or sets the speed ratio to use for all animations
  39104. */
  39105. get speedRatio(): number;
  39106. /**
  39107. * Gets or sets the speed ratio to use for all animations
  39108. */
  39109. set speedRatio(value: number);
  39110. /**
  39111. * Gets or sets if all animations should loop or not
  39112. */
  39113. get loopAnimation(): boolean;
  39114. set loopAnimation(value: boolean);
  39115. /**
  39116. * Gets or sets if all animations should be evaluated additively
  39117. */
  39118. get isAdditive(): boolean;
  39119. set isAdditive(value: boolean);
  39120. /**
  39121. * Gets the targeted animations for this animation group
  39122. */
  39123. get targetedAnimations(): Array<TargetedAnimation>;
  39124. /**
  39125. * returning the list of animatables controlled by this animation group.
  39126. */
  39127. get animatables(): Array<Animatable>;
  39128. /**
  39129. * Gets the list of target animations
  39130. */
  39131. get children(): TargetedAnimation[];
  39132. /**
  39133. * Instantiates a new Animation Group.
  39134. * This helps managing several animations at once.
  39135. * @see https://doc.babylonjs.com/how_to/group
  39136. * @param name Defines the name of the group
  39137. * @param scene Defines the scene the group belongs to
  39138. */
  39139. constructor(
  39140. /** The name of the animation group */
  39141. name: string, scene?: Nullable<Scene>);
  39142. /**
  39143. * Add an animation (with its target) in the group
  39144. * @param animation defines the animation we want to add
  39145. * @param target defines the target of the animation
  39146. * @returns the TargetedAnimation object
  39147. */
  39148. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39149. /**
  39150. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39151. * It can add constant keys at begin or end
  39152. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39153. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39154. * @returns the animation group
  39155. */
  39156. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39157. private _animationLoopCount;
  39158. private _animationLoopFlags;
  39159. private _processLoop;
  39160. /**
  39161. * Start all animations on given targets
  39162. * @param loop defines if animations must loop
  39163. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39164. * @param from defines the from key (optional)
  39165. * @param to defines the to key (optional)
  39166. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39167. * @returns the current animation group
  39168. */
  39169. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39170. /**
  39171. * Pause all animations
  39172. * @returns the animation group
  39173. */
  39174. pause(): AnimationGroup;
  39175. /**
  39176. * Play all animations to initial state
  39177. * This function will start() the animations if they were not started or will restart() them if they were paused
  39178. * @param loop defines if animations must loop
  39179. * @returns the animation group
  39180. */
  39181. play(loop?: boolean): AnimationGroup;
  39182. /**
  39183. * Reset all animations to initial state
  39184. * @returns the animation group
  39185. */
  39186. reset(): AnimationGroup;
  39187. /**
  39188. * Restart animations from key 0
  39189. * @returns the animation group
  39190. */
  39191. restart(): AnimationGroup;
  39192. /**
  39193. * Stop all animations
  39194. * @returns the animation group
  39195. */
  39196. stop(): AnimationGroup;
  39197. /**
  39198. * Set animation weight for all animatables
  39199. * @param weight defines the weight to use
  39200. * @return the animationGroup
  39201. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39202. */
  39203. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39204. /**
  39205. * Synchronize and normalize all animatables with a source animatable
  39206. * @param root defines the root animatable to synchronize with
  39207. * @return the animationGroup
  39208. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39209. */
  39210. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39211. /**
  39212. * Goes to a specific frame in this animation group
  39213. * @param frame the frame number to go to
  39214. * @return the animationGroup
  39215. */
  39216. goToFrame(frame: number): AnimationGroup;
  39217. /**
  39218. * Dispose all associated resources
  39219. */
  39220. dispose(): void;
  39221. private _checkAnimationGroupEnded;
  39222. /**
  39223. * Clone the current animation group and returns a copy
  39224. * @param newName defines the name of the new group
  39225. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39226. * @returns the new aniamtion group
  39227. */
  39228. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39229. /**
  39230. * Serializes the animationGroup to an object
  39231. * @returns Serialized object
  39232. */
  39233. serialize(): any;
  39234. /**
  39235. * Returns a new AnimationGroup object parsed from the source provided.
  39236. * @param parsedAnimationGroup defines the source
  39237. * @param scene defines the scene that will receive the animationGroup
  39238. * @returns a new AnimationGroup
  39239. */
  39240. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39241. /**
  39242. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39243. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39244. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39245. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39246. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39247. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39248. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39249. */
  39250. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39251. /**
  39252. * Returns the string "AnimationGroup"
  39253. * @returns "AnimationGroup"
  39254. */
  39255. getClassName(): string;
  39256. /**
  39257. * Creates a detailled string about the object
  39258. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39259. * @returns a string representing the object
  39260. */
  39261. toString(fullDetails?: boolean): string;
  39262. }
  39263. }
  39264. declare module BABYLON {
  39265. /**
  39266. * Define an interface for all classes that will hold resources
  39267. */
  39268. export interface IDisposable {
  39269. /**
  39270. * Releases all held resources
  39271. */
  39272. dispose(): void;
  39273. }
  39274. /** Interface defining initialization parameters for Scene class */
  39275. export interface SceneOptions {
  39276. /**
  39277. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39278. * It will improve performance when the number of geometries becomes important.
  39279. */
  39280. useGeometryUniqueIdsMap?: boolean;
  39281. /**
  39282. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39283. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39284. */
  39285. useMaterialMeshMap?: boolean;
  39286. /**
  39287. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39288. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39289. */
  39290. useClonedMeshMap?: boolean;
  39291. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39292. virtual?: boolean;
  39293. }
  39294. /**
  39295. * Represents a scene to be rendered by the engine.
  39296. * @see https://doc.babylonjs.com/features/scene
  39297. */
  39298. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39299. /** The fog is deactivated */
  39300. static readonly FOGMODE_NONE: number;
  39301. /** The fog density is following an exponential function */
  39302. static readonly FOGMODE_EXP: number;
  39303. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39304. static readonly FOGMODE_EXP2: number;
  39305. /** The fog density is following a linear function. */
  39306. static readonly FOGMODE_LINEAR: number;
  39307. /**
  39308. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39309. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39310. */
  39311. static MinDeltaTime: number;
  39312. /**
  39313. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39314. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39315. */
  39316. static MaxDeltaTime: number;
  39317. /**
  39318. * Factory used to create the default material.
  39319. * @param name The name of the material to create
  39320. * @param scene The scene to create the material for
  39321. * @returns The default material
  39322. */
  39323. static DefaultMaterialFactory(scene: Scene): Material;
  39324. /**
  39325. * Factory used to create the a collision coordinator.
  39326. * @returns The collision coordinator
  39327. */
  39328. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39329. /** @hidden */
  39330. _inputManager: InputManager;
  39331. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39332. cameraToUseForPointers: Nullable<Camera>;
  39333. /** @hidden */
  39334. readonly _isScene: boolean;
  39335. /** @hidden */
  39336. _blockEntityCollection: boolean;
  39337. /**
  39338. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39339. */
  39340. autoClear: boolean;
  39341. /**
  39342. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39343. */
  39344. autoClearDepthAndStencil: boolean;
  39345. /**
  39346. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39347. */
  39348. clearColor: Color4;
  39349. /**
  39350. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39351. */
  39352. ambientColor: Color3;
  39353. /**
  39354. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39355. * It should only be one of the following (if not the default embedded one):
  39356. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39357. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39358. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39359. * The material properties need to be setup according to the type of texture in use.
  39360. */
  39361. environmentBRDFTexture: BaseTexture;
  39362. /**
  39363. * Texture used in all pbr material as the reflection texture.
  39364. * As in the majority of the scene they are the same (exception for multi room and so on),
  39365. * this is easier to reference from here than from all the materials.
  39366. */
  39367. get environmentTexture(): Nullable<BaseTexture>;
  39368. /**
  39369. * Texture used in all pbr material as the reflection texture.
  39370. * As in the majority of the scene they are the same (exception for multi room and so on),
  39371. * this is easier to set here than in all the materials.
  39372. */
  39373. set environmentTexture(value: Nullable<BaseTexture>);
  39374. /** @hidden */
  39375. protected _environmentIntensity: number;
  39376. /**
  39377. * Intensity of the environment in all pbr material.
  39378. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39379. * As in the majority of the scene they are the same (exception for multi room and so on),
  39380. * this is easier to reference from here than from all the materials.
  39381. */
  39382. get environmentIntensity(): number;
  39383. /**
  39384. * Intensity of the environment in all pbr material.
  39385. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39386. * As in the majority of the scene they are the same (exception for multi room and so on),
  39387. * this is easier to set here than in all the materials.
  39388. */
  39389. set environmentIntensity(value: number);
  39390. /** @hidden */
  39391. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39392. /**
  39393. * Default image processing configuration used either in the rendering
  39394. * Forward main pass or through the imageProcessingPostProcess if present.
  39395. * As in the majority of the scene they are the same (exception for multi camera),
  39396. * this is easier to reference from here than from all the materials and post process.
  39397. *
  39398. * No setter as we it is a shared configuration, you can set the values instead.
  39399. */
  39400. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39401. private _forceWireframe;
  39402. /**
  39403. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39404. */
  39405. set forceWireframe(value: boolean);
  39406. get forceWireframe(): boolean;
  39407. private _skipFrustumClipping;
  39408. /**
  39409. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39410. */
  39411. set skipFrustumClipping(value: boolean);
  39412. get skipFrustumClipping(): boolean;
  39413. private _forcePointsCloud;
  39414. /**
  39415. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39416. */
  39417. set forcePointsCloud(value: boolean);
  39418. get forcePointsCloud(): boolean;
  39419. /**
  39420. * Gets or sets the active clipplane 1
  39421. */
  39422. clipPlane: Nullable<Plane>;
  39423. /**
  39424. * Gets or sets the active clipplane 2
  39425. */
  39426. clipPlane2: Nullable<Plane>;
  39427. /**
  39428. * Gets or sets the active clipplane 3
  39429. */
  39430. clipPlane3: Nullable<Plane>;
  39431. /**
  39432. * Gets or sets the active clipplane 4
  39433. */
  39434. clipPlane4: Nullable<Plane>;
  39435. /**
  39436. * Gets or sets the active clipplane 5
  39437. */
  39438. clipPlane5: Nullable<Plane>;
  39439. /**
  39440. * Gets or sets the active clipplane 6
  39441. */
  39442. clipPlane6: Nullable<Plane>;
  39443. /**
  39444. * Gets or sets a boolean indicating if animations are enabled
  39445. */
  39446. animationsEnabled: boolean;
  39447. private _animationPropertiesOverride;
  39448. /**
  39449. * Gets or sets the animation properties override
  39450. */
  39451. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39452. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39453. /**
  39454. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39455. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39456. */
  39457. useConstantAnimationDeltaTime: boolean;
  39458. /**
  39459. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39460. * Please note that it requires to run a ray cast through the scene on every frame
  39461. */
  39462. constantlyUpdateMeshUnderPointer: boolean;
  39463. /**
  39464. * Defines the HTML cursor to use when hovering over interactive elements
  39465. */
  39466. hoverCursor: string;
  39467. /**
  39468. * Defines the HTML default cursor to use (empty by default)
  39469. */
  39470. defaultCursor: string;
  39471. /**
  39472. * Defines whether cursors are handled by the scene.
  39473. */
  39474. doNotHandleCursors: boolean;
  39475. /**
  39476. * This is used to call preventDefault() on pointer down
  39477. * in order to block unwanted artifacts like system double clicks
  39478. */
  39479. preventDefaultOnPointerDown: boolean;
  39480. /**
  39481. * This is used to call preventDefault() on pointer up
  39482. * in order to block unwanted artifacts like system double clicks
  39483. */
  39484. preventDefaultOnPointerUp: boolean;
  39485. /**
  39486. * Gets or sets user defined metadata
  39487. */
  39488. metadata: any;
  39489. /**
  39490. * For internal use only. Please do not use.
  39491. */
  39492. reservedDataStore: any;
  39493. /**
  39494. * Gets the name of the plugin used to load this scene (null by default)
  39495. */
  39496. loadingPluginName: string;
  39497. /**
  39498. * Use this array to add regular expressions used to disable offline support for specific urls
  39499. */
  39500. disableOfflineSupportExceptionRules: RegExp[];
  39501. /**
  39502. * An event triggered when the scene is disposed.
  39503. */
  39504. onDisposeObservable: Observable<Scene>;
  39505. private _onDisposeObserver;
  39506. /** Sets a function to be executed when this scene is disposed. */
  39507. set onDispose(callback: () => void);
  39508. /**
  39509. * An event triggered before rendering the scene (right after animations and physics)
  39510. */
  39511. onBeforeRenderObservable: Observable<Scene>;
  39512. private _onBeforeRenderObserver;
  39513. /** Sets a function to be executed before rendering this scene */
  39514. set beforeRender(callback: Nullable<() => void>);
  39515. /**
  39516. * An event triggered after rendering the scene
  39517. */
  39518. onAfterRenderObservable: Observable<Scene>;
  39519. /**
  39520. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39521. */
  39522. onAfterRenderCameraObservable: Observable<Camera>;
  39523. private _onAfterRenderObserver;
  39524. /** Sets a function to be executed after rendering this scene */
  39525. set afterRender(callback: Nullable<() => void>);
  39526. /**
  39527. * An event triggered before animating the scene
  39528. */
  39529. onBeforeAnimationsObservable: Observable<Scene>;
  39530. /**
  39531. * An event triggered after animations processing
  39532. */
  39533. onAfterAnimationsObservable: Observable<Scene>;
  39534. /**
  39535. * An event triggered before draw calls are ready to be sent
  39536. */
  39537. onBeforeDrawPhaseObservable: Observable<Scene>;
  39538. /**
  39539. * An event triggered after draw calls have been sent
  39540. */
  39541. onAfterDrawPhaseObservable: Observable<Scene>;
  39542. /**
  39543. * An event triggered when the scene is ready
  39544. */
  39545. onReadyObservable: Observable<Scene>;
  39546. /**
  39547. * An event triggered before rendering a camera
  39548. */
  39549. onBeforeCameraRenderObservable: Observable<Camera>;
  39550. private _onBeforeCameraRenderObserver;
  39551. /** Sets a function to be executed before rendering a camera*/
  39552. set beforeCameraRender(callback: () => void);
  39553. /**
  39554. * An event triggered after rendering a camera
  39555. */
  39556. onAfterCameraRenderObservable: Observable<Camera>;
  39557. private _onAfterCameraRenderObserver;
  39558. /** Sets a function to be executed after rendering a camera*/
  39559. set afterCameraRender(callback: () => void);
  39560. /**
  39561. * An event triggered when active meshes evaluation is about to start
  39562. */
  39563. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39564. /**
  39565. * An event triggered when active meshes evaluation is done
  39566. */
  39567. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39568. /**
  39569. * An event triggered when particles rendering is about to start
  39570. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39571. */
  39572. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39573. /**
  39574. * An event triggered when particles rendering is done
  39575. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39576. */
  39577. onAfterParticlesRenderingObservable: Observable<Scene>;
  39578. /**
  39579. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39580. */
  39581. onDataLoadedObservable: Observable<Scene>;
  39582. /**
  39583. * An event triggered when a camera is created
  39584. */
  39585. onNewCameraAddedObservable: Observable<Camera>;
  39586. /**
  39587. * An event triggered when a camera is removed
  39588. */
  39589. onCameraRemovedObservable: Observable<Camera>;
  39590. /**
  39591. * An event triggered when a light is created
  39592. */
  39593. onNewLightAddedObservable: Observable<Light>;
  39594. /**
  39595. * An event triggered when a light is removed
  39596. */
  39597. onLightRemovedObservable: Observable<Light>;
  39598. /**
  39599. * An event triggered when a geometry is created
  39600. */
  39601. onNewGeometryAddedObservable: Observable<Geometry>;
  39602. /**
  39603. * An event triggered when a geometry is removed
  39604. */
  39605. onGeometryRemovedObservable: Observable<Geometry>;
  39606. /**
  39607. * An event triggered when a transform node is created
  39608. */
  39609. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39610. /**
  39611. * An event triggered when a transform node is removed
  39612. */
  39613. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39614. /**
  39615. * An event triggered when a mesh is created
  39616. */
  39617. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39618. /**
  39619. * An event triggered when a mesh is removed
  39620. */
  39621. onMeshRemovedObservable: Observable<AbstractMesh>;
  39622. /**
  39623. * An event triggered when a skeleton is created
  39624. */
  39625. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39626. /**
  39627. * An event triggered when a skeleton is removed
  39628. */
  39629. onSkeletonRemovedObservable: Observable<Skeleton>;
  39630. /**
  39631. * An event triggered when a material is created
  39632. */
  39633. onNewMaterialAddedObservable: Observable<Material>;
  39634. /**
  39635. * An event triggered when a material is removed
  39636. */
  39637. onMaterialRemovedObservable: Observable<Material>;
  39638. /**
  39639. * An event triggered when a texture is created
  39640. */
  39641. onNewTextureAddedObservable: Observable<BaseTexture>;
  39642. /**
  39643. * An event triggered when a texture is removed
  39644. */
  39645. onTextureRemovedObservable: Observable<BaseTexture>;
  39646. /**
  39647. * An event triggered when render targets are about to be rendered
  39648. * Can happen multiple times per frame.
  39649. */
  39650. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39651. /**
  39652. * An event triggered when render targets were rendered.
  39653. * Can happen multiple times per frame.
  39654. */
  39655. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39656. /**
  39657. * An event triggered before calculating deterministic simulation step
  39658. */
  39659. onBeforeStepObservable: Observable<Scene>;
  39660. /**
  39661. * An event triggered after calculating deterministic simulation step
  39662. */
  39663. onAfterStepObservable: Observable<Scene>;
  39664. /**
  39665. * An event triggered when the activeCamera property is updated
  39666. */
  39667. onActiveCameraChanged: Observable<Scene>;
  39668. /**
  39669. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39670. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39671. * 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)
  39672. */
  39673. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39674. /**
  39675. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39676. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39677. * 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)
  39678. */
  39679. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39680. /**
  39681. * This Observable will when a mesh has been imported into the scene.
  39682. */
  39683. onMeshImportedObservable: Observable<AbstractMesh>;
  39684. /**
  39685. * This Observable will when an animation file has been imported into the scene.
  39686. */
  39687. onAnimationFileImportedObservable: Observable<Scene>;
  39688. /**
  39689. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39690. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39691. */
  39692. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39693. /** @hidden */
  39694. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39695. /**
  39696. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39697. */
  39698. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39699. /**
  39700. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39701. */
  39702. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39703. /**
  39704. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39705. */
  39706. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39707. /** Callback called when a pointer move is detected */
  39708. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39709. /** Callback called when a pointer down is detected */
  39710. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39711. /** Callback called when a pointer up is detected */
  39712. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39713. /** Callback called when a pointer pick is detected */
  39714. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39715. /**
  39716. * 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).
  39717. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39718. */
  39719. onPrePointerObservable: Observable<PointerInfoPre>;
  39720. /**
  39721. * Observable event triggered each time an input event is received from the rendering canvas
  39722. */
  39723. onPointerObservable: Observable<PointerInfo>;
  39724. /**
  39725. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39726. */
  39727. get unTranslatedPointer(): Vector2;
  39728. /**
  39729. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39730. */
  39731. static get DragMovementThreshold(): number;
  39732. static set DragMovementThreshold(value: number);
  39733. /**
  39734. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39735. */
  39736. static get LongPressDelay(): number;
  39737. static set LongPressDelay(value: number);
  39738. /**
  39739. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39740. */
  39741. static get DoubleClickDelay(): number;
  39742. static set DoubleClickDelay(value: number);
  39743. /** If you need to check double click without raising a single click at first click, enable this flag */
  39744. static get ExclusiveDoubleClickMode(): boolean;
  39745. static set ExclusiveDoubleClickMode(value: boolean);
  39746. /** @hidden */
  39747. _mirroredCameraPosition: Nullable<Vector3>;
  39748. /**
  39749. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39750. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39751. */
  39752. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39753. /**
  39754. * Observable event triggered each time an keyboard event is received from the hosting window
  39755. */
  39756. onKeyboardObservable: Observable<KeyboardInfo>;
  39757. private _useRightHandedSystem;
  39758. /**
  39759. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39760. */
  39761. set useRightHandedSystem(value: boolean);
  39762. get useRightHandedSystem(): boolean;
  39763. private _timeAccumulator;
  39764. private _currentStepId;
  39765. private _currentInternalStep;
  39766. /**
  39767. * Sets the step Id used by deterministic lock step
  39768. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39769. * @param newStepId defines the step Id
  39770. */
  39771. setStepId(newStepId: number): void;
  39772. /**
  39773. * Gets the step Id used by deterministic lock step
  39774. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39775. * @returns the step Id
  39776. */
  39777. getStepId(): number;
  39778. /**
  39779. * Gets the internal step used by deterministic lock step
  39780. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39781. * @returns the internal step
  39782. */
  39783. getInternalStep(): number;
  39784. private _fogEnabled;
  39785. /**
  39786. * Gets or sets a boolean indicating if fog is enabled on this scene
  39787. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39788. * (Default is true)
  39789. */
  39790. set fogEnabled(value: boolean);
  39791. get fogEnabled(): boolean;
  39792. private _fogMode;
  39793. /**
  39794. * Gets or sets the fog mode to use
  39795. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39796. * | mode | value |
  39797. * | --- | --- |
  39798. * | FOGMODE_NONE | 0 |
  39799. * | FOGMODE_EXP | 1 |
  39800. * | FOGMODE_EXP2 | 2 |
  39801. * | FOGMODE_LINEAR | 3 |
  39802. */
  39803. set fogMode(value: number);
  39804. get fogMode(): number;
  39805. /**
  39806. * Gets or sets the fog color to use
  39807. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39808. * (Default is Color3(0.2, 0.2, 0.3))
  39809. */
  39810. fogColor: Color3;
  39811. /**
  39812. * Gets or sets the fog density to use
  39813. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39814. * (Default is 0.1)
  39815. */
  39816. fogDensity: number;
  39817. /**
  39818. * Gets or sets the fog start distance to use
  39819. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39820. * (Default is 0)
  39821. */
  39822. fogStart: number;
  39823. /**
  39824. * Gets or sets the fog end distance to use
  39825. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39826. * (Default is 1000)
  39827. */
  39828. fogEnd: number;
  39829. /**
  39830. * Flag indicating that the frame buffer binding is handled by another component
  39831. */
  39832. prePass: boolean;
  39833. private _shadowsEnabled;
  39834. /**
  39835. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39836. */
  39837. set shadowsEnabled(value: boolean);
  39838. get shadowsEnabled(): boolean;
  39839. private _lightsEnabled;
  39840. /**
  39841. * Gets or sets a boolean indicating if lights are enabled on this scene
  39842. */
  39843. set lightsEnabled(value: boolean);
  39844. get lightsEnabled(): boolean;
  39845. /** All of the active cameras added to this scene. */
  39846. activeCameras: Camera[];
  39847. /** @hidden */
  39848. _activeCamera: Nullable<Camera>;
  39849. /** Gets or sets the current active camera */
  39850. get activeCamera(): Nullable<Camera>;
  39851. set activeCamera(value: Nullable<Camera>);
  39852. private _defaultMaterial;
  39853. /** The default material used on meshes when no material is affected */
  39854. get defaultMaterial(): Material;
  39855. /** The default material used on meshes when no material is affected */
  39856. set defaultMaterial(value: Material);
  39857. private _texturesEnabled;
  39858. /**
  39859. * Gets or sets a boolean indicating if textures are enabled on this scene
  39860. */
  39861. set texturesEnabled(value: boolean);
  39862. get texturesEnabled(): boolean;
  39863. /**
  39864. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39865. */
  39866. physicsEnabled: boolean;
  39867. /**
  39868. * Gets or sets a boolean indicating if particles are enabled on this scene
  39869. */
  39870. particlesEnabled: boolean;
  39871. /**
  39872. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39873. */
  39874. spritesEnabled: boolean;
  39875. private _skeletonsEnabled;
  39876. /**
  39877. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39878. */
  39879. set skeletonsEnabled(value: boolean);
  39880. get skeletonsEnabled(): boolean;
  39881. /**
  39882. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39883. */
  39884. lensFlaresEnabled: boolean;
  39885. /**
  39886. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39887. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39888. */
  39889. collisionsEnabled: boolean;
  39890. private _collisionCoordinator;
  39891. /** @hidden */
  39892. get collisionCoordinator(): ICollisionCoordinator;
  39893. /**
  39894. * Defines the gravity applied to this scene (used only for collisions)
  39895. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39896. */
  39897. gravity: Vector3;
  39898. /**
  39899. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39900. */
  39901. postProcessesEnabled: boolean;
  39902. /**
  39903. * Gets the current postprocess manager
  39904. */
  39905. postProcessManager: PostProcessManager;
  39906. /**
  39907. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39908. */
  39909. renderTargetsEnabled: boolean;
  39910. /**
  39911. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39912. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39913. */
  39914. dumpNextRenderTargets: boolean;
  39915. /**
  39916. * The list of user defined render targets added to the scene
  39917. */
  39918. customRenderTargets: RenderTargetTexture[];
  39919. /**
  39920. * Defines if texture loading must be delayed
  39921. * If true, textures will only be loaded when they need to be rendered
  39922. */
  39923. useDelayedTextureLoading: boolean;
  39924. /**
  39925. * Gets the list of meshes imported to the scene through SceneLoader
  39926. */
  39927. importedMeshesFiles: String[];
  39928. /**
  39929. * Gets or sets a boolean indicating if probes are enabled on this scene
  39930. */
  39931. probesEnabled: boolean;
  39932. /**
  39933. * Gets or sets the current offline provider to use to store scene data
  39934. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39935. */
  39936. offlineProvider: IOfflineProvider;
  39937. /**
  39938. * Gets or sets the action manager associated with the scene
  39939. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39940. */
  39941. actionManager: AbstractActionManager;
  39942. private _meshesForIntersections;
  39943. /**
  39944. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39945. */
  39946. proceduralTexturesEnabled: boolean;
  39947. private _engine;
  39948. private _totalVertices;
  39949. /** @hidden */
  39950. _activeIndices: PerfCounter;
  39951. /** @hidden */
  39952. _activeParticles: PerfCounter;
  39953. /** @hidden */
  39954. _activeBones: PerfCounter;
  39955. private _animationRatio;
  39956. /** @hidden */
  39957. _animationTimeLast: number;
  39958. /** @hidden */
  39959. _animationTime: number;
  39960. /**
  39961. * Gets or sets a general scale for animation speed
  39962. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39963. */
  39964. animationTimeScale: number;
  39965. /** @hidden */
  39966. _cachedMaterial: Nullable<Material>;
  39967. /** @hidden */
  39968. _cachedEffect: Nullable<Effect>;
  39969. /** @hidden */
  39970. _cachedVisibility: Nullable<number>;
  39971. private _renderId;
  39972. private _frameId;
  39973. private _executeWhenReadyTimeoutId;
  39974. private _intermediateRendering;
  39975. private _viewUpdateFlag;
  39976. private _projectionUpdateFlag;
  39977. /** @hidden */
  39978. _toBeDisposed: Nullable<IDisposable>[];
  39979. private _activeRequests;
  39980. /** @hidden */
  39981. _pendingData: any[];
  39982. private _isDisposed;
  39983. /**
  39984. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39985. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39986. */
  39987. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39988. private _activeMeshes;
  39989. private _processedMaterials;
  39990. private _renderTargets;
  39991. /** @hidden */
  39992. _activeParticleSystems: SmartArray<IParticleSystem>;
  39993. private _activeSkeletons;
  39994. private _softwareSkinnedMeshes;
  39995. private _renderingManager;
  39996. /** @hidden */
  39997. _activeAnimatables: Animatable[];
  39998. private _transformMatrix;
  39999. private _sceneUbo;
  40000. /** @hidden */
  40001. _viewMatrix: Matrix;
  40002. private _projectionMatrix;
  40003. /** @hidden */
  40004. _forcedViewPosition: Nullable<Vector3>;
  40005. /** @hidden */
  40006. _frustumPlanes: Plane[];
  40007. /**
  40008. * Gets the list of frustum planes (built from the active camera)
  40009. */
  40010. get frustumPlanes(): Plane[];
  40011. /**
  40012. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40013. * This is useful if there are more lights that the maximum simulteanous authorized
  40014. */
  40015. requireLightSorting: boolean;
  40016. /** @hidden */
  40017. readonly useMaterialMeshMap: boolean;
  40018. /** @hidden */
  40019. readonly useClonedMeshMap: boolean;
  40020. private _externalData;
  40021. private _uid;
  40022. /**
  40023. * @hidden
  40024. * Backing store of defined scene components.
  40025. */
  40026. _components: ISceneComponent[];
  40027. /**
  40028. * @hidden
  40029. * Backing store of defined scene components.
  40030. */
  40031. _serializableComponents: ISceneSerializableComponent[];
  40032. /**
  40033. * List of components to register on the next registration step.
  40034. */
  40035. private _transientComponents;
  40036. /**
  40037. * Registers the transient components if needed.
  40038. */
  40039. private _registerTransientComponents;
  40040. /**
  40041. * @hidden
  40042. * Add a component to the scene.
  40043. * Note that the ccomponent could be registered on th next frame if this is called after
  40044. * the register component stage.
  40045. * @param component Defines the component to add to the scene
  40046. */
  40047. _addComponent(component: ISceneComponent): void;
  40048. /**
  40049. * @hidden
  40050. * Gets a component from the scene.
  40051. * @param name defines the name of the component to retrieve
  40052. * @returns the component or null if not present
  40053. */
  40054. _getComponent(name: string): Nullable<ISceneComponent>;
  40055. /**
  40056. * @hidden
  40057. * Defines the actions happening before camera updates.
  40058. */
  40059. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40060. /**
  40061. * @hidden
  40062. * Defines the actions happening before clear the canvas.
  40063. */
  40064. _beforeClearStage: Stage<SimpleStageAction>;
  40065. /**
  40066. * @hidden
  40067. * Defines the actions when collecting render targets for the frame.
  40068. */
  40069. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40070. /**
  40071. * @hidden
  40072. * Defines the actions happening for one camera in the frame.
  40073. */
  40074. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40075. /**
  40076. * @hidden
  40077. * Defines the actions happening during the per mesh ready checks.
  40078. */
  40079. _isReadyForMeshStage: Stage<MeshStageAction>;
  40080. /**
  40081. * @hidden
  40082. * Defines the actions happening before evaluate active mesh checks.
  40083. */
  40084. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40085. /**
  40086. * @hidden
  40087. * Defines the actions happening during the evaluate sub mesh checks.
  40088. */
  40089. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40090. /**
  40091. * @hidden
  40092. * Defines the actions happening during the active mesh stage.
  40093. */
  40094. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40095. /**
  40096. * @hidden
  40097. * Defines the actions happening during the per camera render target step.
  40098. */
  40099. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40100. /**
  40101. * @hidden
  40102. * Defines the actions happening just before the active camera is drawing.
  40103. */
  40104. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40105. /**
  40106. * @hidden
  40107. * Defines the actions happening just before a render target is drawing.
  40108. */
  40109. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40110. /**
  40111. * @hidden
  40112. * Defines the actions happening just before a rendering group is drawing.
  40113. */
  40114. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40115. /**
  40116. * @hidden
  40117. * Defines the actions happening just before a mesh is drawing.
  40118. */
  40119. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40120. /**
  40121. * @hidden
  40122. * Defines the actions happening just after a mesh has been drawn.
  40123. */
  40124. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40125. /**
  40126. * @hidden
  40127. * Defines the actions happening just after a rendering group has been drawn.
  40128. */
  40129. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40130. /**
  40131. * @hidden
  40132. * Defines the actions happening just after the active camera has been drawn.
  40133. */
  40134. _afterCameraDrawStage: Stage<CameraStageAction>;
  40135. /**
  40136. * @hidden
  40137. * Defines the actions happening just after a render target has been drawn.
  40138. */
  40139. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40140. /**
  40141. * @hidden
  40142. * Defines the actions happening just after rendering all cameras and computing intersections.
  40143. */
  40144. _afterRenderStage: Stage<SimpleStageAction>;
  40145. /**
  40146. * @hidden
  40147. * Defines the actions happening when a pointer move event happens.
  40148. */
  40149. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40150. /**
  40151. * @hidden
  40152. * Defines the actions happening when a pointer down event happens.
  40153. */
  40154. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40155. /**
  40156. * @hidden
  40157. * Defines the actions happening when a pointer up event happens.
  40158. */
  40159. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40160. /**
  40161. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40162. */
  40163. private geometriesByUniqueId;
  40164. /**
  40165. * Creates a new Scene
  40166. * @param engine defines the engine to use to render this scene
  40167. * @param options defines the scene options
  40168. */
  40169. constructor(engine: Engine, options?: SceneOptions);
  40170. /**
  40171. * Gets a string identifying the name of the class
  40172. * @returns "Scene" string
  40173. */
  40174. getClassName(): string;
  40175. private _defaultMeshCandidates;
  40176. /**
  40177. * @hidden
  40178. */
  40179. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40180. private _defaultSubMeshCandidates;
  40181. /**
  40182. * @hidden
  40183. */
  40184. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40185. /**
  40186. * Sets the default candidate providers for the scene.
  40187. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40188. * and getCollidingSubMeshCandidates to their default function
  40189. */
  40190. setDefaultCandidateProviders(): void;
  40191. /**
  40192. * Gets the mesh that is currently under the pointer
  40193. */
  40194. get meshUnderPointer(): Nullable<AbstractMesh>;
  40195. /**
  40196. * Gets or sets the current on-screen X position of the pointer
  40197. */
  40198. get pointerX(): number;
  40199. set pointerX(value: number);
  40200. /**
  40201. * Gets or sets the current on-screen Y position of the pointer
  40202. */
  40203. get pointerY(): number;
  40204. set pointerY(value: number);
  40205. /**
  40206. * Gets the cached material (ie. the latest rendered one)
  40207. * @returns the cached material
  40208. */
  40209. getCachedMaterial(): Nullable<Material>;
  40210. /**
  40211. * Gets the cached effect (ie. the latest rendered one)
  40212. * @returns the cached effect
  40213. */
  40214. getCachedEffect(): Nullable<Effect>;
  40215. /**
  40216. * Gets the cached visibility state (ie. the latest rendered one)
  40217. * @returns the cached visibility state
  40218. */
  40219. getCachedVisibility(): Nullable<number>;
  40220. /**
  40221. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40222. * @param material defines the current material
  40223. * @param effect defines the current effect
  40224. * @param visibility defines the current visibility state
  40225. * @returns true if one parameter is not cached
  40226. */
  40227. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40228. /**
  40229. * Gets the engine associated with the scene
  40230. * @returns an Engine
  40231. */
  40232. getEngine(): Engine;
  40233. /**
  40234. * Gets the total number of vertices rendered per frame
  40235. * @returns the total number of vertices rendered per frame
  40236. */
  40237. getTotalVertices(): number;
  40238. /**
  40239. * Gets the performance counter for total vertices
  40240. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40241. */
  40242. get totalVerticesPerfCounter(): PerfCounter;
  40243. /**
  40244. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40245. * @returns the total number of active indices rendered per frame
  40246. */
  40247. getActiveIndices(): number;
  40248. /**
  40249. * Gets the performance counter for active indices
  40250. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40251. */
  40252. get totalActiveIndicesPerfCounter(): PerfCounter;
  40253. /**
  40254. * Gets the total number of active particles rendered per frame
  40255. * @returns the total number of active particles rendered per frame
  40256. */
  40257. getActiveParticles(): number;
  40258. /**
  40259. * Gets the performance counter for active particles
  40260. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40261. */
  40262. get activeParticlesPerfCounter(): PerfCounter;
  40263. /**
  40264. * Gets the total number of active bones rendered per frame
  40265. * @returns the total number of active bones rendered per frame
  40266. */
  40267. getActiveBones(): number;
  40268. /**
  40269. * Gets the performance counter for active bones
  40270. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40271. */
  40272. get activeBonesPerfCounter(): PerfCounter;
  40273. /**
  40274. * Gets the array of active meshes
  40275. * @returns an array of AbstractMesh
  40276. */
  40277. getActiveMeshes(): SmartArray<AbstractMesh>;
  40278. /**
  40279. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40280. * @returns a number
  40281. */
  40282. getAnimationRatio(): number;
  40283. /**
  40284. * Gets an unique Id for the current render phase
  40285. * @returns a number
  40286. */
  40287. getRenderId(): number;
  40288. /**
  40289. * Gets an unique Id for the current frame
  40290. * @returns a number
  40291. */
  40292. getFrameId(): number;
  40293. /** Call this function if you want to manually increment the render Id*/
  40294. incrementRenderId(): void;
  40295. private _createUbo;
  40296. /**
  40297. * Use this method to simulate a pointer move on a mesh
  40298. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40299. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40300. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40301. * @returns the current scene
  40302. */
  40303. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40304. /**
  40305. * Use this method to simulate a pointer down on a mesh
  40306. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40307. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40308. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40309. * @returns the current scene
  40310. */
  40311. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40312. /**
  40313. * Use this method to simulate a pointer up on a mesh
  40314. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40315. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40316. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40317. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40318. * @returns the current scene
  40319. */
  40320. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40321. /**
  40322. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40323. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40324. * @returns true if the pointer was captured
  40325. */
  40326. isPointerCaptured(pointerId?: number): boolean;
  40327. /**
  40328. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40329. * @param attachUp defines if you want to attach events to pointerup
  40330. * @param attachDown defines if you want to attach events to pointerdown
  40331. * @param attachMove defines if you want to attach events to pointermove
  40332. */
  40333. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40334. /** Detaches all event handlers*/
  40335. detachControl(): void;
  40336. /**
  40337. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40338. * Delay loaded resources are not taking in account
  40339. * @return true if all required resources are ready
  40340. */
  40341. isReady(): boolean;
  40342. /** Resets all cached information relative to material (including effect and visibility) */
  40343. resetCachedMaterial(): void;
  40344. /**
  40345. * Registers a function to be called before every frame render
  40346. * @param func defines the function to register
  40347. */
  40348. registerBeforeRender(func: () => void): void;
  40349. /**
  40350. * Unregisters a function called before every frame render
  40351. * @param func defines the function to unregister
  40352. */
  40353. unregisterBeforeRender(func: () => void): void;
  40354. /**
  40355. * Registers a function to be called after every frame render
  40356. * @param func defines the function to register
  40357. */
  40358. registerAfterRender(func: () => void): void;
  40359. /**
  40360. * Unregisters a function called after every frame render
  40361. * @param func defines the function to unregister
  40362. */
  40363. unregisterAfterRender(func: () => void): void;
  40364. private _executeOnceBeforeRender;
  40365. /**
  40366. * The provided function will run before render once and will be disposed afterwards.
  40367. * A timeout delay can be provided so that the function will be executed in N ms.
  40368. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40369. * @param func The function to be executed.
  40370. * @param timeout optional delay in ms
  40371. */
  40372. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40373. /** @hidden */
  40374. _addPendingData(data: any): void;
  40375. /** @hidden */
  40376. _removePendingData(data: any): void;
  40377. /**
  40378. * Returns the number of items waiting to be loaded
  40379. * @returns the number of items waiting to be loaded
  40380. */
  40381. getWaitingItemsCount(): number;
  40382. /**
  40383. * Returns a boolean indicating if the scene is still loading data
  40384. */
  40385. get isLoading(): boolean;
  40386. /**
  40387. * Registers a function to be executed when the scene is ready
  40388. * @param {Function} func - the function to be executed
  40389. */
  40390. executeWhenReady(func: () => void): void;
  40391. /**
  40392. * Returns a promise that resolves when the scene is ready
  40393. * @returns A promise that resolves when the scene is ready
  40394. */
  40395. whenReadyAsync(): Promise<void>;
  40396. /** @hidden */
  40397. _checkIsReady(): void;
  40398. /**
  40399. * Gets all animatable attached to the scene
  40400. */
  40401. get animatables(): Animatable[];
  40402. /**
  40403. * Resets the last animation time frame.
  40404. * Useful to override when animations start running when loading a scene for the first time.
  40405. */
  40406. resetLastAnimationTimeFrame(): void;
  40407. /**
  40408. * Gets the current view matrix
  40409. * @returns a Matrix
  40410. */
  40411. getViewMatrix(): Matrix;
  40412. /**
  40413. * Gets the current projection matrix
  40414. * @returns a Matrix
  40415. */
  40416. getProjectionMatrix(): Matrix;
  40417. /**
  40418. * Gets the current transform matrix
  40419. * @returns a Matrix made of View * Projection
  40420. */
  40421. getTransformMatrix(): Matrix;
  40422. /**
  40423. * Sets the current transform matrix
  40424. * @param viewL defines the View matrix to use
  40425. * @param projectionL defines the Projection matrix to use
  40426. * @param viewR defines the right View matrix to use (if provided)
  40427. * @param projectionR defines the right Projection matrix to use (if provided)
  40428. */
  40429. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40430. /**
  40431. * Gets the uniform buffer used to store scene data
  40432. * @returns a UniformBuffer
  40433. */
  40434. getSceneUniformBuffer(): UniformBuffer;
  40435. /**
  40436. * Gets an unique (relatively to the current scene) Id
  40437. * @returns an unique number for the scene
  40438. */
  40439. getUniqueId(): number;
  40440. /**
  40441. * Add a mesh to the list of scene's meshes
  40442. * @param newMesh defines the mesh to add
  40443. * @param recursive if all child meshes should also be added to the scene
  40444. */
  40445. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40446. /**
  40447. * Remove a mesh for the list of scene's meshes
  40448. * @param toRemove defines the mesh to remove
  40449. * @param recursive if all child meshes should also be removed from the scene
  40450. * @returns the index where the mesh was in the mesh list
  40451. */
  40452. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40453. /**
  40454. * Add a transform node to the list of scene's transform nodes
  40455. * @param newTransformNode defines the transform node to add
  40456. */
  40457. addTransformNode(newTransformNode: TransformNode): void;
  40458. /**
  40459. * Remove a transform node for the list of scene's transform nodes
  40460. * @param toRemove defines the transform node to remove
  40461. * @returns the index where the transform node was in the transform node list
  40462. */
  40463. removeTransformNode(toRemove: TransformNode): number;
  40464. /**
  40465. * Remove a skeleton for the list of scene's skeletons
  40466. * @param toRemove defines the skeleton to remove
  40467. * @returns the index where the skeleton was in the skeleton list
  40468. */
  40469. removeSkeleton(toRemove: Skeleton): number;
  40470. /**
  40471. * Remove a morph target for the list of scene's morph targets
  40472. * @param toRemove defines the morph target to remove
  40473. * @returns the index where the morph target was in the morph target list
  40474. */
  40475. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40476. /**
  40477. * Remove a light for the list of scene's lights
  40478. * @param toRemove defines the light to remove
  40479. * @returns the index where the light was in the light list
  40480. */
  40481. removeLight(toRemove: Light): number;
  40482. /**
  40483. * Remove a camera for the list of scene's cameras
  40484. * @param toRemove defines the camera to remove
  40485. * @returns the index where the camera was in the camera list
  40486. */
  40487. removeCamera(toRemove: Camera): number;
  40488. /**
  40489. * Remove a particle system for the list of scene's particle systems
  40490. * @param toRemove defines the particle system to remove
  40491. * @returns the index where the particle system was in the particle system list
  40492. */
  40493. removeParticleSystem(toRemove: IParticleSystem): number;
  40494. /**
  40495. * Remove a animation for the list of scene's animations
  40496. * @param toRemove defines the animation to remove
  40497. * @returns the index where the animation was in the animation list
  40498. */
  40499. removeAnimation(toRemove: Animation): number;
  40500. /**
  40501. * Will stop the animation of the given target
  40502. * @param target - the target
  40503. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40504. * @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)
  40505. */
  40506. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40507. /**
  40508. * Removes the given animation group from this scene.
  40509. * @param toRemove The animation group to remove
  40510. * @returns The index of the removed animation group
  40511. */
  40512. removeAnimationGroup(toRemove: AnimationGroup): number;
  40513. /**
  40514. * Removes the given multi-material from this scene.
  40515. * @param toRemove The multi-material to remove
  40516. * @returns The index of the removed multi-material
  40517. */
  40518. removeMultiMaterial(toRemove: MultiMaterial): number;
  40519. /**
  40520. * Removes the given material from this scene.
  40521. * @param toRemove The material to remove
  40522. * @returns The index of the removed material
  40523. */
  40524. removeMaterial(toRemove: Material): number;
  40525. /**
  40526. * Removes the given action manager from this scene.
  40527. * @param toRemove The action manager to remove
  40528. * @returns The index of the removed action manager
  40529. */
  40530. removeActionManager(toRemove: AbstractActionManager): number;
  40531. /**
  40532. * Removes the given texture from this scene.
  40533. * @param toRemove The texture to remove
  40534. * @returns The index of the removed texture
  40535. */
  40536. removeTexture(toRemove: BaseTexture): number;
  40537. /**
  40538. * Adds the given light to this scene
  40539. * @param newLight The light to add
  40540. */
  40541. addLight(newLight: Light): void;
  40542. /**
  40543. * Sorts the list list based on light priorities
  40544. */
  40545. sortLightsByPriority(): void;
  40546. /**
  40547. * Adds the given camera to this scene
  40548. * @param newCamera The camera to add
  40549. */
  40550. addCamera(newCamera: Camera): void;
  40551. /**
  40552. * Adds the given skeleton to this scene
  40553. * @param newSkeleton The skeleton to add
  40554. */
  40555. addSkeleton(newSkeleton: Skeleton): void;
  40556. /**
  40557. * Adds the given particle system to this scene
  40558. * @param newParticleSystem The particle system to add
  40559. */
  40560. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40561. /**
  40562. * Adds the given animation to this scene
  40563. * @param newAnimation The animation to add
  40564. */
  40565. addAnimation(newAnimation: Animation): void;
  40566. /**
  40567. * Adds the given animation group to this scene.
  40568. * @param newAnimationGroup The animation group to add
  40569. */
  40570. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40571. /**
  40572. * Adds the given multi-material to this scene
  40573. * @param newMultiMaterial The multi-material to add
  40574. */
  40575. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40576. /**
  40577. * Adds the given material to this scene
  40578. * @param newMaterial The material to add
  40579. */
  40580. addMaterial(newMaterial: Material): void;
  40581. /**
  40582. * Adds the given morph target to this scene
  40583. * @param newMorphTargetManager The morph target to add
  40584. */
  40585. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40586. /**
  40587. * Adds the given geometry to this scene
  40588. * @param newGeometry The geometry to add
  40589. */
  40590. addGeometry(newGeometry: Geometry): void;
  40591. /**
  40592. * Adds the given action manager to this scene
  40593. * @param newActionManager The action manager to add
  40594. */
  40595. addActionManager(newActionManager: AbstractActionManager): void;
  40596. /**
  40597. * Adds the given texture to this scene.
  40598. * @param newTexture The texture to add
  40599. */
  40600. addTexture(newTexture: BaseTexture): void;
  40601. /**
  40602. * Switch active camera
  40603. * @param newCamera defines the new active camera
  40604. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40605. */
  40606. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40607. /**
  40608. * sets the active camera of the scene using its ID
  40609. * @param id defines the camera's ID
  40610. * @return the new active camera or null if none found.
  40611. */
  40612. setActiveCameraByID(id: string): Nullable<Camera>;
  40613. /**
  40614. * sets the active camera of the scene using its name
  40615. * @param name defines the camera's name
  40616. * @returns the new active camera or null if none found.
  40617. */
  40618. setActiveCameraByName(name: string): Nullable<Camera>;
  40619. /**
  40620. * get an animation group using its name
  40621. * @param name defines the material's name
  40622. * @return the animation group or null if none found.
  40623. */
  40624. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40625. /**
  40626. * Get a material using its unique id
  40627. * @param uniqueId defines the material's unique id
  40628. * @return the material or null if none found.
  40629. */
  40630. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40631. /**
  40632. * get a material using its id
  40633. * @param id defines the material's ID
  40634. * @return the material or null if none found.
  40635. */
  40636. getMaterialByID(id: string): Nullable<Material>;
  40637. /**
  40638. * Gets a the last added material using a given id
  40639. * @param id defines the material's ID
  40640. * @return the last material with the given id or null if none found.
  40641. */
  40642. getLastMaterialByID(id: string): Nullable<Material>;
  40643. /**
  40644. * Gets a material using its name
  40645. * @param name defines the material's name
  40646. * @return the material or null if none found.
  40647. */
  40648. getMaterialByName(name: string): Nullable<Material>;
  40649. /**
  40650. * Get a texture using its unique id
  40651. * @param uniqueId defines the texture's unique id
  40652. * @return the texture or null if none found.
  40653. */
  40654. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40655. /**
  40656. * Gets a camera using its id
  40657. * @param id defines the id to look for
  40658. * @returns the camera or null if not found
  40659. */
  40660. getCameraByID(id: string): Nullable<Camera>;
  40661. /**
  40662. * Gets a camera using its unique id
  40663. * @param uniqueId defines the unique id to look for
  40664. * @returns the camera or null if not found
  40665. */
  40666. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40667. /**
  40668. * Gets a camera using its name
  40669. * @param name defines the camera's name
  40670. * @return the camera or null if none found.
  40671. */
  40672. getCameraByName(name: string): Nullable<Camera>;
  40673. /**
  40674. * Gets a bone using its id
  40675. * @param id defines the bone's id
  40676. * @return the bone or null if not found
  40677. */
  40678. getBoneByID(id: string): Nullable<Bone>;
  40679. /**
  40680. * Gets a bone using its id
  40681. * @param name defines the bone's name
  40682. * @return the bone or null if not found
  40683. */
  40684. getBoneByName(name: string): Nullable<Bone>;
  40685. /**
  40686. * Gets a light node using its name
  40687. * @param name defines the the light's name
  40688. * @return the light or null if none found.
  40689. */
  40690. getLightByName(name: string): Nullable<Light>;
  40691. /**
  40692. * Gets a light node using its id
  40693. * @param id defines the light's id
  40694. * @return the light or null if none found.
  40695. */
  40696. getLightByID(id: string): Nullable<Light>;
  40697. /**
  40698. * Gets a light node using its scene-generated unique ID
  40699. * @param uniqueId defines the light's unique id
  40700. * @return the light or null if none found.
  40701. */
  40702. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40703. /**
  40704. * Gets a particle system by id
  40705. * @param id defines the particle system id
  40706. * @return the corresponding system or null if none found
  40707. */
  40708. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40709. /**
  40710. * Gets a geometry using its ID
  40711. * @param id defines the geometry's id
  40712. * @return the geometry or null if none found.
  40713. */
  40714. getGeometryByID(id: string): Nullable<Geometry>;
  40715. private _getGeometryByUniqueID;
  40716. /**
  40717. * Add a new geometry to this scene
  40718. * @param geometry defines the geometry to be added to the scene.
  40719. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40720. * @return a boolean defining if the geometry was added or not
  40721. */
  40722. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40723. /**
  40724. * Removes an existing geometry
  40725. * @param geometry defines the geometry to be removed from the scene
  40726. * @return a boolean defining if the geometry was removed or not
  40727. */
  40728. removeGeometry(geometry: Geometry): boolean;
  40729. /**
  40730. * Gets the list of geometries attached to the scene
  40731. * @returns an array of Geometry
  40732. */
  40733. getGeometries(): Geometry[];
  40734. /**
  40735. * Gets the first added mesh found of a given ID
  40736. * @param id defines the id to search for
  40737. * @return the mesh found or null if not found at all
  40738. */
  40739. getMeshByID(id: string): Nullable<AbstractMesh>;
  40740. /**
  40741. * Gets a list of meshes using their id
  40742. * @param id defines the id to search for
  40743. * @returns a list of meshes
  40744. */
  40745. getMeshesByID(id: string): Array<AbstractMesh>;
  40746. /**
  40747. * Gets the first added transform node found of a given ID
  40748. * @param id defines the id to search for
  40749. * @return the found transform node or null if not found at all.
  40750. */
  40751. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40752. /**
  40753. * Gets a transform node with its auto-generated unique id
  40754. * @param uniqueId efines the unique id to search for
  40755. * @return the found transform node or null if not found at all.
  40756. */
  40757. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40758. /**
  40759. * Gets a list of transform nodes using their id
  40760. * @param id defines the id to search for
  40761. * @returns a list of transform nodes
  40762. */
  40763. getTransformNodesByID(id: string): Array<TransformNode>;
  40764. /**
  40765. * Gets a mesh with its auto-generated unique id
  40766. * @param uniqueId defines the unique id to search for
  40767. * @return the found mesh or null if not found at all.
  40768. */
  40769. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40770. /**
  40771. * Gets a the last added mesh using a given id
  40772. * @param id defines the id to search for
  40773. * @return the found mesh or null if not found at all.
  40774. */
  40775. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40776. /**
  40777. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40778. * @param id defines the id to search for
  40779. * @return the found node or null if not found at all
  40780. */
  40781. getLastEntryByID(id: string): Nullable<Node>;
  40782. /**
  40783. * Gets a node (Mesh, Camera, Light) using a given id
  40784. * @param id defines the id to search for
  40785. * @return the found node or null if not found at all
  40786. */
  40787. getNodeByID(id: string): Nullable<Node>;
  40788. /**
  40789. * Gets a node (Mesh, Camera, Light) using a given name
  40790. * @param name defines the name to search for
  40791. * @return the found node or null if not found at all.
  40792. */
  40793. getNodeByName(name: string): Nullable<Node>;
  40794. /**
  40795. * Gets a mesh using a given name
  40796. * @param name defines the name to search for
  40797. * @return the found mesh or null if not found at all.
  40798. */
  40799. getMeshByName(name: string): Nullable<AbstractMesh>;
  40800. /**
  40801. * Gets a transform node using a given name
  40802. * @param name defines the name to search for
  40803. * @return the found transform node or null if not found at all.
  40804. */
  40805. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40806. /**
  40807. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40808. * @param id defines the id to search for
  40809. * @return the found skeleton or null if not found at all.
  40810. */
  40811. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40812. /**
  40813. * Gets a skeleton using a given auto generated unique id
  40814. * @param uniqueId defines the unique id to search for
  40815. * @return the found skeleton or null if not found at all.
  40816. */
  40817. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40818. /**
  40819. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40820. * @param id defines the id to search for
  40821. * @return the found skeleton or null if not found at all.
  40822. */
  40823. getSkeletonById(id: string): Nullable<Skeleton>;
  40824. /**
  40825. * Gets a skeleton using a given name
  40826. * @param name defines the name to search for
  40827. * @return the found skeleton or null if not found at all.
  40828. */
  40829. getSkeletonByName(name: string): Nullable<Skeleton>;
  40830. /**
  40831. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40832. * @param id defines the id to search for
  40833. * @return the found morph target manager or null if not found at all.
  40834. */
  40835. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40836. /**
  40837. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40838. * @param id defines the id to search for
  40839. * @return the found morph target or null if not found at all.
  40840. */
  40841. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40842. /**
  40843. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40844. * @param name defines the name to search for
  40845. * @return the found morph target or null if not found at all.
  40846. */
  40847. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40848. /**
  40849. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40850. * @param name defines the name to search for
  40851. * @return the found post process or null if not found at all.
  40852. */
  40853. getPostProcessByName(name: string): Nullable<PostProcess>;
  40854. /**
  40855. * Gets a boolean indicating if the given mesh is active
  40856. * @param mesh defines the mesh to look for
  40857. * @returns true if the mesh is in the active list
  40858. */
  40859. isActiveMesh(mesh: AbstractMesh): boolean;
  40860. /**
  40861. * Return a unique id as a string which can serve as an identifier for the scene
  40862. */
  40863. get uid(): string;
  40864. /**
  40865. * Add an externaly attached data from its key.
  40866. * This method call will fail and return false, if such key already exists.
  40867. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40868. * @param key the unique key that identifies the data
  40869. * @param data the data object to associate to the key for this Engine instance
  40870. * @return true if no such key were already present and the data was added successfully, false otherwise
  40871. */
  40872. addExternalData<T>(key: string, data: T): boolean;
  40873. /**
  40874. * Get an externaly attached data from its key
  40875. * @param key the unique key that identifies the data
  40876. * @return the associated data, if present (can be null), or undefined if not present
  40877. */
  40878. getExternalData<T>(key: string): Nullable<T>;
  40879. /**
  40880. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40881. * @param key the unique key that identifies the data
  40882. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40883. * @return the associated data, can be null if the factory returned null.
  40884. */
  40885. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40886. /**
  40887. * Remove an externaly attached data from the Engine instance
  40888. * @param key the unique key that identifies the data
  40889. * @return true if the data was successfully removed, false if it doesn't exist
  40890. */
  40891. removeExternalData(key: string): boolean;
  40892. private _evaluateSubMesh;
  40893. /**
  40894. * Clear the processed materials smart array preventing retention point in material dispose.
  40895. */
  40896. freeProcessedMaterials(): void;
  40897. private _preventFreeActiveMeshesAndRenderingGroups;
  40898. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40899. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40900. * when disposing several meshes in a row or a hierarchy of meshes.
  40901. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40902. */
  40903. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40904. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40905. /**
  40906. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40907. */
  40908. freeActiveMeshes(): void;
  40909. /**
  40910. * Clear the info related to rendering groups preventing retention points during dispose.
  40911. */
  40912. freeRenderingGroups(): void;
  40913. /** @hidden */
  40914. _isInIntermediateRendering(): boolean;
  40915. /**
  40916. * Lambda returning the list of potentially active meshes.
  40917. */
  40918. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40919. /**
  40920. * Lambda returning the list of potentially active sub meshes.
  40921. */
  40922. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40923. /**
  40924. * Lambda returning the list of potentially intersecting sub meshes.
  40925. */
  40926. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40927. /**
  40928. * Lambda returning the list of potentially colliding sub meshes.
  40929. */
  40930. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40931. private _activeMeshesFrozen;
  40932. private _skipEvaluateActiveMeshesCompletely;
  40933. /**
  40934. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40935. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40936. * @returns the current scene
  40937. */
  40938. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40939. /**
  40940. * Use this function to restart evaluating active meshes on every frame
  40941. * @returns the current scene
  40942. */
  40943. unfreezeActiveMeshes(): Scene;
  40944. private _evaluateActiveMeshes;
  40945. private _activeMesh;
  40946. /**
  40947. * Update the transform matrix to update from the current active camera
  40948. * @param force defines a boolean used to force the update even if cache is up to date
  40949. */
  40950. updateTransformMatrix(force?: boolean): void;
  40951. private _bindFrameBuffer;
  40952. /** @hidden */
  40953. _allowPostProcessClearColor: boolean;
  40954. /** @hidden */
  40955. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40956. private _processSubCameras;
  40957. private _checkIntersections;
  40958. /** @hidden */
  40959. _advancePhysicsEngineStep(step: number): void;
  40960. /**
  40961. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40962. */
  40963. getDeterministicFrameTime: () => number;
  40964. /** @hidden */
  40965. _animate(): void;
  40966. /** Execute all animations (for a frame) */
  40967. animate(): void;
  40968. /**
  40969. * Render the scene
  40970. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40971. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40972. */
  40973. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40974. /**
  40975. * Freeze all materials
  40976. * A frozen material will not be updatable but should be faster to render
  40977. */
  40978. freezeMaterials(): void;
  40979. /**
  40980. * Unfreeze all materials
  40981. * A frozen material will not be updatable but should be faster to render
  40982. */
  40983. unfreezeMaterials(): void;
  40984. /**
  40985. * Releases all held ressources
  40986. */
  40987. dispose(): void;
  40988. /**
  40989. * Gets if the scene is already disposed
  40990. */
  40991. get isDisposed(): boolean;
  40992. /**
  40993. * Call this function to reduce memory footprint of the scene.
  40994. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40995. */
  40996. clearCachedVertexData(): void;
  40997. /**
  40998. * This function will remove the local cached buffer data from texture.
  40999. * It will save memory but will prevent the texture from being rebuilt
  41000. */
  41001. cleanCachedTextureBuffer(): void;
  41002. /**
  41003. * Get the world extend vectors with an optional filter
  41004. *
  41005. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41006. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41007. */
  41008. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41009. min: Vector3;
  41010. max: Vector3;
  41011. };
  41012. /**
  41013. * Creates a ray that can be used to pick in the scene
  41014. * @param x defines the x coordinate of the origin (on-screen)
  41015. * @param y defines the y coordinate of the origin (on-screen)
  41016. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41017. * @param camera defines the camera to use for the picking
  41018. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41019. * @returns a Ray
  41020. */
  41021. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41022. /**
  41023. * Creates a ray that can be used to pick in the scene
  41024. * @param x defines the x coordinate of the origin (on-screen)
  41025. * @param y defines the y coordinate of the origin (on-screen)
  41026. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41027. * @param result defines the ray where to store the picking ray
  41028. * @param camera defines the camera to use for the picking
  41029. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41030. * @returns the current scene
  41031. */
  41032. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41033. /**
  41034. * Creates a ray that can be used to pick in the scene
  41035. * @param x defines the x coordinate of the origin (on-screen)
  41036. * @param y defines the y coordinate of the origin (on-screen)
  41037. * @param camera defines the camera to use for the picking
  41038. * @returns a Ray
  41039. */
  41040. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41041. /**
  41042. * Creates a ray that can be used to pick in the scene
  41043. * @param x defines the x coordinate of the origin (on-screen)
  41044. * @param y defines the y coordinate of the origin (on-screen)
  41045. * @param result defines the ray where to store the picking ray
  41046. * @param camera defines the camera to use for the picking
  41047. * @returns the current scene
  41048. */
  41049. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41050. /** Launch a ray to try to pick a mesh in the scene
  41051. * @param x position on screen
  41052. * @param y position on screen
  41053. * @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
  41054. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41055. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41056. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41057. * @returns a PickingInfo
  41058. */
  41059. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41060. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41061. * @param x position on screen
  41062. * @param y position on screen
  41063. * @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
  41064. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41065. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41066. * @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)
  41067. */
  41068. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41069. /** Use the given ray to pick a mesh in the scene
  41070. * @param ray The ray to use to pick meshes
  41071. * @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
  41072. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41073. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41074. * @returns a PickingInfo
  41075. */
  41076. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41077. /**
  41078. * Launch a ray to try to pick a mesh in the scene
  41079. * @param x X position on screen
  41080. * @param y Y position on screen
  41081. * @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
  41082. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41083. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41084. * @returns an array of PickingInfo
  41085. */
  41086. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41087. /**
  41088. * Launch a ray to try to pick a mesh in the scene
  41089. * @param ray Ray to use
  41090. * @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
  41091. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41092. * @returns an array of PickingInfo
  41093. */
  41094. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41095. /**
  41096. * Force the value of meshUnderPointer
  41097. * @param mesh defines the mesh to use
  41098. */
  41099. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41100. /**
  41101. * Gets the mesh under the pointer
  41102. * @returns a Mesh or null if no mesh is under the pointer
  41103. */
  41104. getPointerOverMesh(): Nullable<AbstractMesh>;
  41105. /** @hidden */
  41106. _rebuildGeometries(): void;
  41107. /** @hidden */
  41108. _rebuildTextures(): void;
  41109. private _getByTags;
  41110. /**
  41111. * Get a list of meshes by tags
  41112. * @param tagsQuery defines the tags query to use
  41113. * @param forEach defines a predicate used to filter results
  41114. * @returns an array of Mesh
  41115. */
  41116. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41117. /**
  41118. * Get a list of cameras by tags
  41119. * @param tagsQuery defines the tags query to use
  41120. * @param forEach defines a predicate used to filter results
  41121. * @returns an array of Camera
  41122. */
  41123. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41124. /**
  41125. * Get a list of lights by tags
  41126. * @param tagsQuery defines the tags query to use
  41127. * @param forEach defines a predicate used to filter results
  41128. * @returns an array of Light
  41129. */
  41130. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41131. /**
  41132. * Get a list of materials by tags
  41133. * @param tagsQuery defines the tags query to use
  41134. * @param forEach defines a predicate used to filter results
  41135. * @returns an array of Material
  41136. */
  41137. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41138. /**
  41139. * Get a list of transform nodes by tags
  41140. * @param tagsQuery defines the tags query to use
  41141. * @param forEach defines a predicate used to filter results
  41142. * @returns an array of TransformNode
  41143. */
  41144. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41145. /**
  41146. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41147. * This allowed control for front to back rendering or reversly depending of the special needs.
  41148. *
  41149. * @param renderingGroupId The rendering group id corresponding to its index
  41150. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41151. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41152. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41153. */
  41154. 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;
  41155. /**
  41156. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41157. *
  41158. * @param renderingGroupId The rendering group id corresponding to its index
  41159. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41160. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41161. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41162. */
  41163. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41164. /**
  41165. * Gets the current auto clear configuration for one rendering group of the rendering
  41166. * manager.
  41167. * @param index the rendering group index to get the information for
  41168. * @returns The auto clear setup for the requested rendering group
  41169. */
  41170. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41171. private _blockMaterialDirtyMechanism;
  41172. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41173. get blockMaterialDirtyMechanism(): boolean;
  41174. set blockMaterialDirtyMechanism(value: boolean);
  41175. /**
  41176. * Will flag all materials as dirty to trigger new shader compilation
  41177. * @param flag defines the flag used to specify which material part must be marked as dirty
  41178. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41179. */
  41180. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41181. /** @hidden */
  41182. _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;
  41183. /** @hidden */
  41184. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41185. /** @hidden */
  41186. _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;
  41187. /** @hidden */
  41188. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41189. /** @hidden */
  41190. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41191. /** @hidden */
  41192. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41193. }
  41194. }
  41195. declare module BABYLON {
  41196. /**
  41197. * Set of assets to keep when moving a scene into an asset container.
  41198. */
  41199. export class KeepAssets extends AbstractScene {
  41200. }
  41201. /**
  41202. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41203. */
  41204. export class InstantiatedEntries {
  41205. /**
  41206. * List of new root nodes (eg. nodes with no parent)
  41207. */
  41208. rootNodes: TransformNode[];
  41209. /**
  41210. * List of new skeletons
  41211. */
  41212. skeletons: Skeleton[];
  41213. /**
  41214. * List of new animation groups
  41215. */
  41216. animationGroups: AnimationGroup[];
  41217. }
  41218. /**
  41219. * Container with a set of assets that can be added or removed from a scene.
  41220. */
  41221. export class AssetContainer extends AbstractScene {
  41222. private _wasAddedToScene;
  41223. /**
  41224. * The scene the AssetContainer belongs to.
  41225. */
  41226. scene: Scene;
  41227. /**
  41228. * Instantiates an AssetContainer.
  41229. * @param scene The scene the AssetContainer belongs to.
  41230. */
  41231. constructor(scene: Scene);
  41232. /**
  41233. * Instantiate or clone all meshes and add the new ones to the scene.
  41234. * Skeletons and animation groups will all be cloned
  41235. * @param nameFunction defines an optional function used to get new names for clones
  41236. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41237. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41238. */
  41239. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41240. /**
  41241. * Adds all the assets from the container to the scene.
  41242. */
  41243. addAllToScene(): void;
  41244. /**
  41245. * Removes all the assets in the container from the scene
  41246. */
  41247. removeAllFromScene(): void;
  41248. /**
  41249. * Disposes all the assets in the container
  41250. */
  41251. dispose(): void;
  41252. private _moveAssets;
  41253. /**
  41254. * Removes all the assets contained in the scene and adds them to the container.
  41255. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41256. */
  41257. moveAllFromScene(keepAssets?: KeepAssets): void;
  41258. /**
  41259. * 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.
  41260. * @returns the root mesh
  41261. */
  41262. createRootMesh(): Mesh;
  41263. /**
  41264. * Merge animations (direct and animation groups) from this asset container into a scene
  41265. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41266. * @param animatables set of animatables to retarget to a node from the scene
  41267. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41268. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41269. */
  41270. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41271. }
  41272. }
  41273. declare module BABYLON {
  41274. /**
  41275. * Defines how the parser contract is defined.
  41276. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41277. */
  41278. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41279. /**
  41280. * Defines how the individual parser contract is defined.
  41281. * These parser can parse an individual asset
  41282. */
  41283. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41284. /**
  41285. * Base class of the scene acting as a container for the different elements composing a scene.
  41286. * This class is dynamically extended by the different components of the scene increasing
  41287. * flexibility and reducing coupling
  41288. */
  41289. export abstract class AbstractScene {
  41290. /**
  41291. * Stores the list of available parsers in the application.
  41292. */
  41293. private static _BabylonFileParsers;
  41294. /**
  41295. * Stores the list of available individual parsers in the application.
  41296. */
  41297. private static _IndividualBabylonFileParsers;
  41298. /**
  41299. * Adds a parser in the list of available ones
  41300. * @param name Defines the name of the parser
  41301. * @param parser Defines the parser to add
  41302. */
  41303. static AddParser(name: string, parser: BabylonFileParser): void;
  41304. /**
  41305. * Gets a general parser from the list of avaialble ones
  41306. * @param name Defines the name of the parser
  41307. * @returns the requested parser or null
  41308. */
  41309. static GetParser(name: string): Nullable<BabylonFileParser>;
  41310. /**
  41311. * Adds n individual parser in the list of available ones
  41312. * @param name Defines the name of the parser
  41313. * @param parser Defines the parser to add
  41314. */
  41315. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41316. /**
  41317. * Gets an individual parser from the list of avaialble ones
  41318. * @param name Defines the name of the parser
  41319. * @returns the requested parser or null
  41320. */
  41321. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41322. /**
  41323. * Parser json data and populate both a scene and its associated container object
  41324. * @param jsonData Defines the data to parse
  41325. * @param scene Defines the scene to parse the data for
  41326. * @param container Defines the container attached to the parsing sequence
  41327. * @param rootUrl Defines the root url of the data
  41328. */
  41329. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41330. /**
  41331. * Gets the list of root nodes (ie. nodes with no parent)
  41332. */
  41333. rootNodes: Node[];
  41334. /** All of the cameras added to this scene
  41335. * @see https://doc.babylonjs.com/babylon101/cameras
  41336. */
  41337. cameras: Camera[];
  41338. /**
  41339. * All of the lights added to this scene
  41340. * @see https://doc.babylonjs.com/babylon101/lights
  41341. */
  41342. lights: Light[];
  41343. /**
  41344. * All of the (abstract) meshes added to this scene
  41345. */
  41346. meshes: AbstractMesh[];
  41347. /**
  41348. * The list of skeletons added to the scene
  41349. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41350. */
  41351. skeletons: Skeleton[];
  41352. /**
  41353. * All of the particle systems added to this scene
  41354. * @see https://doc.babylonjs.com/babylon101/particles
  41355. */
  41356. particleSystems: IParticleSystem[];
  41357. /**
  41358. * Gets a list of Animations associated with the scene
  41359. */
  41360. animations: Animation[];
  41361. /**
  41362. * All of the animation groups added to this scene
  41363. * @see https://doc.babylonjs.com/how_to/group
  41364. */
  41365. animationGroups: AnimationGroup[];
  41366. /**
  41367. * All of the multi-materials added to this scene
  41368. * @see https://doc.babylonjs.com/how_to/multi_materials
  41369. */
  41370. multiMaterials: MultiMaterial[];
  41371. /**
  41372. * All of the materials added to this scene
  41373. * In the context of a Scene, it is not supposed to be modified manually.
  41374. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41375. * Note also that the order of the Material within the array is not significant and might change.
  41376. * @see https://doc.babylonjs.com/babylon101/materials
  41377. */
  41378. materials: Material[];
  41379. /**
  41380. * The list of morph target managers added to the scene
  41381. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41382. */
  41383. morphTargetManagers: MorphTargetManager[];
  41384. /**
  41385. * The list of geometries used in the scene.
  41386. */
  41387. geometries: Geometry[];
  41388. /**
  41389. * All of the tranform nodes added to this scene
  41390. * In the context of a Scene, it is not supposed to be modified manually.
  41391. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41392. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41393. * @see https://doc.babylonjs.com/how_to/transformnode
  41394. */
  41395. transformNodes: TransformNode[];
  41396. /**
  41397. * ActionManagers available on the scene.
  41398. */
  41399. actionManagers: AbstractActionManager[];
  41400. /**
  41401. * Textures to keep.
  41402. */
  41403. textures: BaseTexture[];
  41404. /** @hidden */
  41405. protected _environmentTexture: Nullable<BaseTexture>;
  41406. /**
  41407. * Texture used in all pbr material as the reflection texture.
  41408. * As in the majority of the scene they are the same (exception for multi room and so on),
  41409. * this is easier to reference from here than from all the materials.
  41410. */
  41411. get environmentTexture(): Nullable<BaseTexture>;
  41412. set environmentTexture(value: Nullable<BaseTexture>);
  41413. /**
  41414. * The list of postprocesses added to the scene
  41415. */
  41416. postProcesses: PostProcess[];
  41417. /**
  41418. * @returns all meshes, lights, cameras, transformNodes and bones
  41419. */
  41420. getNodes(): Array<Node>;
  41421. }
  41422. }
  41423. declare module BABYLON {
  41424. /**
  41425. * Interface used to define options for Sound class
  41426. */
  41427. export interface ISoundOptions {
  41428. /**
  41429. * Does the sound autoplay once loaded.
  41430. */
  41431. autoplay?: boolean;
  41432. /**
  41433. * Does the sound loop after it finishes playing once.
  41434. */
  41435. loop?: boolean;
  41436. /**
  41437. * Sound's volume
  41438. */
  41439. volume?: number;
  41440. /**
  41441. * Is it a spatial sound?
  41442. */
  41443. spatialSound?: boolean;
  41444. /**
  41445. * Maximum distance to hear that sound
  41446. */
  41447. maxDistance?: number;
  41448. /**
  41449. * Uses user defined attenuation function
  41450. */
  41451. useCustomAttenuation?: boolean;
  41452. /**
  41453. * Define the roll off factor of spatial sounds.
  41454. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41455. */
  41456. rolloffFactor?: number;
  41457. /**
  41458. * Define the reference distance the sound should be heard perfectly.
  41459. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41460. */
  41461. refDistance?: number;
  41462. /**
  41463. * Define the distance attenuation model the sound will follow.
  41464. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41465. */
  41466. distanceModel?: string;
  41467. /**
  41468. * Defines the playback speed (1 by default)
  41469. */
  41470. playbackRate?: number;
  41471. /**
  41472. * Defines if the sound is from a streaming source
  41473. */
  41474. streaming?: boolean;
  41475. /**
  41476. * Defines an optional length (in seconds) inside the sound file
  41477. */
  41478. length?: number;
  41479. /**
  41480. * Defines an optional offset (in seconds) inside the sound file
  41481. */
  41482. offset?: number;
  41483. /**
  41484. * If true, URLs will not be required to state the audio file codec to use.
  41485. */
  41486. skipCodecCheck?: boolean;
  41487. }
  41488. /**
  41489. * Defines a sound that can be played in the application.
  41490. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41491. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41492. */
  41493. export class Sound {
  41494. /**
  41495. * The name of the sound in the scene.
  41496. */
  41497. name: string;
  41498. /**
  41499. * Does the sound autoplay once loaded.
  41500. */
  41501. autoplay: boolean;
  41502. /**
  41503. * Does the sound loop after it finishes playing once.
  41504. */
  41505. loop: boolean;
  41506. /**
  41507. * Does the sound use a custom attenuation curve to simulate the falloff
  41508. * happening when the source gets further away from the camera.
  41509. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41510. */
  41511. useCustomAttenuation: boolean;
  41512. /**
  41513. * The sound track id this sound belongs to.
  41514. */
  41515. soundTrackId: number;
  41516. /**
  41517. * Is this sound currently played.
  41518. */
  41519. isPlaying: boolean;
  41520. /**
  41521. * Is this sound currently paused.
  41522. */
  41523. isPaused: boolean;
  41524. /**
  41525. * Does this sound enables spatial sound.
  41526. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41527. */
  41528. spatialSound: boolean;
  41529. /**
  41530. * Define the reference distance the sound should be heard perfectly.
  41531. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41532. */
  41533. refDistance: number;
  41534. /**
  41535. * Define the roll off factor of spatial sounds.
  41536. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41537. */
  41538. rolloffFactor: number;
  41539. /**
  41540. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41541. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41542. */
  41543. maxDistance: number;
  41544. /**
  41545. * Define the distance attenuation model the sound will follow.
  41546. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41547. */
  41548. distanceModel: string;
  41549. /**
  41550. * @hidden
  41551. * Back Compat
  41552. **/
  41553. onended: () => any;
  41554. /**
  41555. * Gets or sets an object used to store user defined information for the sound.
  41556. */
  41557. metadata: any;
  41558. /**
  41559. * Observable event when the current playing sound finishes.
  41560. */
  41561. onEndedObservable: Observable<Sound>;
  41562. private _panningModel;
  41563. private _playbackRate;
  41564. private _streaming;
  41565. private _startTime;
  41566. private _startOffset;
  41567. private _position;
  41568. /** @hidden */
  41569. _positionInEmitterSpace: boolean;
  41570. private _localDirection;
  41571. private _volume;
  41572. private _isReadyToPlay;
  41573. private _isDirectional;
  41574. private _readyToPlayCallback;
  41575. private _audioBuffer;
  41576. private _soundSource;
  41577. private _streamingSource;
  41578. private _soundPanner;
  41579. private _soundGain;
  41580. private _inputAudioNode;
  41581. private _outputAudioNode;
  41582. private _coneInnerAngle;
  41583. private _coneOuterAngle;
  41584. private _coneOuterGain;
  41585. private _scene;
  41586. private _connectedTransformNode;
  41587. private _customAttenuationFunction;
  41588. private _registerFunc;
  41589. private _isOutputConnected;
  41590. private _htmlAudioElement;
  41591. private _urlType;
  41592. private _length?;
  41593. private _offset?;
  41594. /** @hidden */
  41595. static _SceneComponentInitialization: (scene: Scene) => void;
  41596. /**
  41597. * Create a sound and attach it to a scene
  41598. * @param name Name of your sound
  41599. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41600. * @param scene defines the scene the sound belongs to
  41601. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41602. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41603. */
  41604. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41605. /**
  41606. * Release the sound and its associated resources
  41607. */
  41608. dispose(): void;
  41609. /**
  41610. * Gets if the sounds is ready to be played or not.
  41611. * @returns true if ready, otherwise false
  41612. */
  41613. isReady(): boolean;
  41614. private _soundLoaded;
  41615. /**
  41616. * Sets the data of the sound from an audiobuffer
  41617. * @param audioBuffer The audioBuffer containing the data
  41618. */
  41619. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41620. /**
  41621. * Updates the current sounds options such as maxdistance, loop...
  41622. * @param options A JSON object containing values named as the object properties
  41623. */
  41624. updateOptions(options: ISoundOptions): void;
  41625. private _createSpatialParameters;
  41626. private _updateSpatialParameters;
  41627. /**
  41628. * Switch the panning model to HRTF:
  41629. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41630. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41631. */
  41632. switchPanningModelToHRTF(): void;
  41633. /**
  41634. * Switch the panning model to Equal Power:
  41635. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41636. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41637. */
  41638. switchPanningModelToEqualPower(): void;
  41639. private _switchPanningModel;
  41640. /**
  41641. * Connect this sound to a sound track audio node like gain...
  41642. * @param soundTrackAudioNode the sound track audio node to connect to
  41643. */
  41644. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41645. /**
  41646. * Transform this sound into a directional source
  41647. * @param coneInnerAngle Size of the inner cone in degree
  41648. * @param coneOuterAngle Size of the outer cone in degree
  41649. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41650. */
  41651. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41652. /**
  41653. * Gets or sets the inner angle for the directional cone.
  41654. */
  41655. get directionalConeInnerAngle(): number;
  41656. /**
  41657. * Gets or sets the inner angle for the directional cone.
  41658. */
  41659. set directionalConeInnerAngle(value: number);
  41660. /**
  41661. * Gets or sets the outer angle for the directional cone.
  41662. */
  41663. get directionalConeOuterAngle(): number;
  41664. /**
  41665. * Gets or sets the outer angle for the directional cone.
  41666. */
  41667. set directionalConeOuterAngle(value: number);
  41668. /**
  41669. * Sets the position of the emitter if spatial sound is enabled
  41670. * @param newPosition Defines the new posisiton
  41671. */
  41672. setPosition(newPosition: Vector3): void;
  41673. /**
  41674. * Sets the local direction of the emitter if spatial sound is enabled
  41675. * @param newLocalDirection Defines the new local direction
  41676. */
  41677. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41678. private _updateDirection;
  41679. /** @hidden */
  41680. updateDistanceFromListener(): void;
  41681. /**
  41682. * Sets a new custom attenuation function for the sound.
  41683. * @param callback Defines the function used for the attenuation
  41684. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41685. */
  41686. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41687. /**
  41688. * Play the sound
  41689. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41690. * @param offset (optional) Start the sound at a specific time in seconds
  41691. * @param length (optional) Sound duration (in seconds)
  41692. */
  41693. play(time?: number, offset?: number, length?: number): void;
  41694. private _onended;
  41695. /**
  41696. * Stop the sound
  41697. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41698. */
  41699. stop(time?: number): void;
  41700. /**
  41701. * Put the sound in pause
  41702. */
  41703. pause(): void;
  41704. /**
  41705. * Sets a dedicated volume for this sounds
  41706. * @param newVolume Define the new volume of the sound
  41707. * @param time Define time for gradual change to new volume
  41708. */
  41709. setVolume(newVolume: number, time?: number): void;
  41710. /**
  41711. * Set the sound play back rate
  41712. * @param newPlaybackRate Define the playback rate the sound should be played at
  41713. */
  41714. setPlaybackRate(newPlaybackRate: number): void;
  41715. /**
  41716. * Gets the volume of the sound.
  41717. * @returns the volume of the sound
  41718. */
  41719. getVolume(): number;
  41720. /**
  41721. * Attach the sound to a dedicated mesh
  41722. * @param transformNode The transform node to connect the sound with
  41723. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41724. */
  41725. attachToMesh(transformNode: TransformNode): void;
  41726. /**
  41727. * Detach the sound from the previously attached mesh
  41728. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41729. */
  41730. detachFromMesh(): void;
  41731. private _onRegisterAfterWorldMatrixUpdate;
  41732. /**
  41733. * Clone the current sound in the scene.
  41734. * @returns the new sound clone
  41735. */
  41736. clone(): Nullable<Sound>;
  41737. /**
  41738. * Gets the current underlying audio buffer containing the data
  41739. * @returns the audio buffer
  41740. */
  41741. getAudioBuffer(): Nullable<AudioBuffer>;
  41742. /**
  41743. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41744. * @returns the source node
  41745. */
  41746. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41747. /**
  41748. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41749. * @returns the gain node
  41750. */
  41751. getSoundGain(): Nullable<GainNode>;
  41752. /**
  41753. * Serializes the Sound in a JSON representation
  41754. * @returns the JSON representation of the sound
  41755. */
  41756. serialize(): any;
  41757. /**
  41758. * Parse a JSON representation of a sound to innstantiate in a given scene
  41759. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41760. * @param scene Define the scene the new parsed sound should be created in
  41761. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41762. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41763. * @returns the newly parsed sound
  41764. */
  41765. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41766. }
  41767. }
  41768. declare module BABYLON {
  41769. /**
  41770. * This defines an action helpful to play a defined sound on a triggered action.
  41771. */
  41772. export class PlaySoundAction extends Action {
  41773. private _sound;
  41774. /**
  41775. * Instantiate the action
  41776. * @param triggerOptions defines the trigger options
  41777. * @param sound defines the sound to play
  41778. * @param condition defines the trigger related conditions
  41779. */
  41780. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41781. /** @hidden */
  41782. _prepare(): void;
  41783. /**
  41784. * Execute the action and play the sound.
  41785. */
  41786. execute(): void;
  41787. /**
  41788. * Serializes the actions and its related information.
  41789. * @param parent defines the object to serialize in
  41790. * @returns the serialized object
  41791. */
  41792. serialize(parent: any): any;
  41793. }
  41794. /**
  41795. * This defines an action helpful to stop a defined sound on a triggered action.
  41796. */
  41797. export class StopSoundAction extends Action {
  41798. private _sound;
  41799. /**
  41800. * Instantiate the action
  41801. * @param triggerOptions defines the trigger options
  41802. * @param sound defines the sound to stop
  41803. * @param condition defines the trigger related conditions
  41804. */
  41805. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41806. /** @hidden */
  41807. _prepare(): void;
  41808. /**
  41809. * Execute the action and stop the sound.
  41810. */
  41811. execute(): void;
  41812. /**
  41813. * Serializes the actions and its related information.
  41814. * @param parent defines the object to serialize in
  41815. * @returns the serialized object
  41816. */
  41817. serialize(parent: any): any;
  41818. }
  41819. }
  41820. declare module BABYLON {
  41821. /**
  41822. * This defines an action responsible to change the value of a property
  41823. * by interpolating between its current value and the newly set one once triggered.
  41824. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41825. */
  41826. export class InterpolateValueAction extends Action {
  41827. /**
  41828. * Defines the path of the property where the value should be interpolated
  41829. */
  41830. propertyPath: string;
  41831. /**
  41832. * Defines the target value at the end of the interpolation.
  41833. */
  41834. value: any;
  41835. /**
  41836. * Defines the time it will take for the property to interpolate to the value.
  41837. */
  41838. duration: number;
  41839. /**
  41840. * Defines if the other scene animations should be stopped when the action has been triggered
  41841. */
  41842. stopOtherAnimations?: boolean;
  41843. /**
  41844. * Defines a callback raised once the interpolation animation has been done.
  41845. */
  41846. onInterpolationDone?: () => void;
  41847. /**
  41848. * Observable triggered once the interpolation animation has been done.
  41849. */
  41850. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41851. private _target;
  41852. private _effectiveTarget;
  41853. private _property;
  41854. /**
  41855. * Instantiate the action
  41856. * @param triggerOptions defines the trigger options
  41857. * @param target defines the object containing the value to interpolate
  41858. * @param propertyPath defines the path to the property in the target object
  41859. * @param value defines the target value at the end of the interpolation
  41860. * @param duration deines the time it will take for the property to interpolate to the value.
  41861. * @param condition defines the trigger related conditions
  41862. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41863. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41864. */
  41865. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41866. /** @hidden */
  41867. _prepare(): void;
  41868. /**
  41869. * Execute the action starts the value interpolation.
  41870. */
  41871. execute(): void;
  41872. /**
  41873. * Serializes the actions and its related information.
  41874. * @param parent defines the object to serialize in
  41875. * @returns the serialized object
  41876. */
  41877. serialize(parent: any): any;
  41878. }
  41879. }
  41880. declare module BABYLON {
  41881. /**
  41882. * Options allowed during the creation of a sound track.
  41883. */
  41884. export interface ISoundTrackOptions {
  41885. /**
  41886. * The volume the sound track should take during creation
  41887. */
  41888. volume?: number;
  41889. /**
  41890. * Define if the sound track is the main sound track of the scene
  41891. */
  41892. mainTrack?: boolean;
  41893. }
  41894. /**
  41895. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41896. * It will be also used in a future release to apply effects on a specific track.
  41897. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41898. */
  41899. export class SoundTrack {
  41900. /**
  41901. * The unique identifier of the sound track in the scene.
  41902. */
  41903. id: number;
  41904. /**
  41905. * The list of sounds included in the sound track.
  41906. */
  41907. soundCollection: Array<Sound>;
  41908. private _outputAudioNode;
  41909. private _scene;
  41910. private _connectedAnalyser;
  41911. private _options;
  41912. private _isInitialized;
  41913. /**
  41914. * Creates a new sound track.
  41915. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41916. * @param scene Define the scene the sound track belongs to
  41917. * @param options
  41918. */
  41919. constructor(scene: Scene, options?: ISoundTrackOptions);
  41920. private _initializeSoundTrackAudioGraph;
  41921. /**
  41922. * Release the sound track and its associated resources
  41923. */
  41924. dispose(): void;
  41925. /**
  41926. * Adds a sound to this sound track
  41927. * @param sound define the cound to add
  41928. * @ignoreNaming
  41929. */
  41930. AddSound(sound: Sound): void;
  41931. /**
  41932. * Removes a sound to this sound track
  41933. * @param sound define the cound to remove
  41934. * @ignoreNaming
  41935. */
  41936. RemoveSound(sound: Sound): void;
  41937. /**
  41938. * Set a global volume for the full sound track.
  41939. * @param newVolume Define the new volume of the sound track
  41940. */
  41941. setVolume(newVolume: number): void;
  41942. /**
  41943. * Switch the panning model to HRTF:
  41944. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41945. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41946. */
  41947. switchPanningModelToHRTF(): void;
  41948. /**
  41949. * Switch the panning model to Equal Power:
  41950. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41951. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41952. */
  41953. switchPanningModelToEqualPower(): void;
  41954. /**
  41955. * Connect the sound track to an audio analyser allowing some amazing
  41956. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41957. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41958. * @param analyser The analyser to connect to the engine
  41959. */
  41960. connectToAnalyser(analyser: Analyser): void;
  41961. }
  41962. }
  41963. declare module BABYLON {
  41964. interface AbstractScene {
  41965. /**
  41966. * The list of sounds used in the scene.
  41967. */
  41968. sounds: Nullable<Array<Sound>>;
  41969. }
  41970. interface Scene {
  41971. /**
  41972. * @hidden
  41973. * Backing field
  41974. */
  41975. _mainSoundTrack: SoundTrack;
  41976. /**
  41977. * The main sound track played by the scene.
  41978. * It cotains your primary collection of sounds.
  41979. */
  41980. mainSoundTrack: SoundTrack;
  41981. /**
  41982. * The list of sound tracks added to the scene
  41983. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41984. */
  41985. soundTracks: Nullable<Array<SoundTrack>>;
  41986. /**
  41987. * Gets a sound using a given name
  41988. * @param name defines the name to search for
  41989. * @return the found sound or null if not found at all.
  41990. */
  41991. getSoundByName(name: string): Nullable<Sound>;
  41992. /**
  41993. * Gets or sets if audio support is enabled
  41994. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41995. */
  41996. audioEnabled: boolean;
  41997. /**
  41998. * Gets or sets if audio will be output to headphones
  41999. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42000. */
  42001. headphone: boolean;
  42002. /**
  42003. * Gets or sets custom audio listener position provider
  42004. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42005. */
  42006. audioListenerPositionProvider: Nullable<() => Vector3>;
  42007. /**
  42008. * Gets or sets a refresh rate when using 3D audio positioning
  42009. */
  42010. audioPositioningRefreshRate: number;
  42011. }
  42012. /**
  42013. * Defines the sound scene component responsible to manage any sounds
  42014. * in a given scene.
  42015. */
  42016. export class AudioSceneComponent implements ISceneSerializableComponent {
  42017. /**
  42018. * The component name helpfull to identify the component in the list of scene components.
  42019. */
  42020. readonly name: string;
  42021. /**
  42022. * The scene the component belongs to.
  42023. */
  42024. scene: Scene;
  42025. private _audioEnabled;
  42026. /**
  42027. * Gets whether audio is enabled or not.
  42028. * Please use related enable/disable method to switch state.
  42029. */
  42030. get audioEnabled(): boolean;
  42031. private _headphone;
  42032. /**
  42033. * Gets whether audio is outputing to headphone or not.
  42034. * Please use the according Switch methods to change output.
  42035. */
  42036. get headphone(): boolean;
  42037. /**
  42038. * Gets or sets a refresh rate when using 3D audio positioning
  42039. */
  42040. audioPositioningRefreshRate: number;
  42041. private _audioListenerPositionProvider;
  42042. /**
  42043. * Gets the current audio listener position provider
  42044. */
  42045. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42046. /**
  42047. * Sets a custom listener position for all sounds in the scene
  42048. * By default, this is the position of the first active camera
  42049. */
  42050. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42051. /**
  42052. * Creates a new instance of the component for the given scene
  42053. * @param scene Defines the scene to register the component in
  42054. */
  42055. constructor(scene: Scene);
  42056. /**
  42057. * Registers the component in a given scene
  42058. */
  42059. register(): void;
  42060. /**
  42061. * Rebuilds the elements related to this component in case of
  42062. * context lost for instance.
  42063. */
  42064. rebuild(): void;
  42065. /**
  42066. * Serializes the component data to the specified json object
  42067. * @param serializationObject The object to serialize to
  42068. */
  42069. serialize(serializationObject: any): void;
  42070. /**
  42071. * Adds all the elements from the container to the scene
  42072. * @param container the container holding the elements
  42073. */
  42074. addFromContainer(container: AbstractScene): void;
  42075. /**
  42076. * Removes all the elements in the container from the scene
  42077. * @param container contains the elements to remove
  42078. * @param dispose if the removed element should be disposed (default: false)
  42079. */
  42080. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42081. /**
  42082. * Disposes the component and the associated ressources.
  42083. */
  42084. dispose(): void;
  42085. /**
  42086. * Disables audio in the associated scene.
  42087. */
  42088. disableAudio(): void;
  42089. /**
  42090. * Enables audio in the associated scene.
  42091. */
  42092. enableAudio(): void;
  42093. /**
  42094. * Switch audio to headphone output.
  42095. */
  42096. switchAudioModeForHeadphones(): void;
  42097. /**
  42098. * Switch audio to normal speakers.
  42099. */
  42100. switchAudioModeForNormalSpeakers(): void;
  42101. private _cachedCameraDirection;
  42102. private _cachedCameraPosition;
  42103. private _lastCheck;
  42104. private _afterRender;
  42105. }
  42106. }
  42107. declare module BABYLON {
  42108. /**
  42109. * Wraps one or more Sound objects and selects one with random weight for playback.
  42110. */
  42111. export class WeightedSound {
  42112. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42113. loop: boolean;
  42114. private _coneInnerAngle;
  42115. private _coneOuterAngle;
  42116. private _volume;
  42117. /** A Sound is currently playing. */
  42118. isPlaying: boolean;
  42119. /** A Sound is currently paused. */
  42120. isPaused: boolean;
  42121. private _sounds;
  42122. private _weights;
  42123. private _currentIndex?;
  42124. /**
  42125. * Creates a new WeightedSound from the list of sounds given.
  42126. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42127. * @param sounds Array of Sounds that will be selected from.
  42128. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42129. */
  42130. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42131. /**
  42132. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42133. */
  42134. get directionalConeInnerAngle(): number;
  42135. /**
  42136. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42137. */
  42138. set directionalConeInnerAngle(value: number);
  42139. /**
  42140. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42141. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42142. */
  42143. get directionalConeOuterAngle(): number;
  42144. /**
  42145. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42146. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42147. */
  42148. set directionalConeOuterAngle(value: number);
  42149. /**
  42150. * Playback volume.
  42151. */
  42152. get volume(): number;
  42153. /**
  42154. * Playback volume.
  42155. */
  42156. set volume(value: number);
  42157. private _onended;
  42158. /**
  42159. * Suspend playback
  42160. */
  42161. pause(): void;
  42162. /**
  42163. * Stop playback
  42164. */
  42165. stop(): void;
  42166. /**
  42167. * Start playback.
  42168. * @param startOffset Position the clip head at a specific time in seconds.
  42169. */
  42170. play(startOffset?: number): void;
  42171. }
  42172. }
  42173. declare module BABYLON {
  42174. /**
  42175. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42176. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42177. */
  42178. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42179. /**
  42180. * Gets the name of the behavior.
  42181. */
  42182. get name(): string;
  42183. /**
  42184. * The easing function used by animations
  42185. */
  42186. static EasingFunction: BackEase;
  42187. /**
  42188. * The easing mode used by animations
  42189. */
  42190. static EasingMode: number;
  42191. /**
  42192. * The duration of the animation, in milliseconds
  42193. */
  42194. transitionDuration: number;
  42195. /**
  42196. * Length of the distance animated by the transition when lower radius is reached
  42197. */
  42198. lowerRadiusTransitionRange: number;
  42199. /**
  42200. * Length of the distance animated by the transition when upper radius is reached
  42201. */
  42202. upperRadiusTransitionRange: number;
  42203. private _autoTransitionRange;
  42204. /**
  42205. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42206. */
  42207. get autoTransitionRange(): boolean;
  42208. /**
  42209. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42210. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42211. */
  42212. set autoTransitionRange(value: boolean);
  42213. private _attachedCamera;
  42214. private _onAfterCheckInputsObserver;
  42215. private _onMeshTargetChangedObserver;
  42216. /**
  42217. * Initializes the behavior.
  42218. */
  42219. init(): void;
  42220. /**
  42221. * Attaches the behavior to its arc rotate camera.
  42222. * @param camera Defines the camera to attach the behavior to
  42223. */
  42224. attach(camera: ArcRotateCamera): void;
  42225. /**
  42226. * Detaches the behavior from its current arc rotate camera.
  42227. */
  42228. detach(): void;
  42229. private _radiusIsAnimating;
  42230. private _radiusBounceTransition;
  42231. private _animatables;
  42232. private _cachedWheelPrecision;
  42233. /**
  42234. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42235. * @param radiusLimit The limit to check against.
  42236. * @return Bool to indicate if at limit.
  42237. */
  42238. private _isRadiusAtLimit;
  42239. /**
  42240. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42241. * @param radiusDelta The delta by which to animate to. Can be negative.
  42242. */
  42243. private _applyBoundRadiusAnimation;
  42244. /**
  42245. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42246. */
  42247. protected _clearAnimationLocks(): void;
  42248. /**
  42249. * Stops and removes all animations that have been applied to the camera
  42250. */
  42251. stopAllAnimations(): void;
  42252. }
  42253. }
  42254. declare module BABYLON {
  42255. /**
  42256. * 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.
  42257. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42258. */
  42259. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42260. /**
  42261. * Gets the name of the behavior.
  42262. */
  42263. get name(): string;
  42264. private _mode;
  42265. private _radiusScale;
  42266. private _positionScale;
  42267. private _defaultElevation;
  42268. private _elevationReturnTime;
  42269. private _elevationReturnWaitTime;
  42270. private _zoomStopsAnimation;
  42271. private _framingTime;
  42272. /**
  42273. * The easing function used by animations
  42274. */
  42275. static EasingFunction: ExponentialEase;
  42276. /**
  42277. * The easing mode used by animations
  42278. */
  42279. static EasingMode: number;
  42280. /**
  42281. * Sets the current mode used by the behavior
  42282. */
  42283. set mode(mode: number);
  42284. /**
  42285. * Gets current mode used by the behavior.
  42286. */
  42287. get mode(): number;
  42288. /**
  42289. * Sets the scale applied to the radius (1 by default)
  42290. */
  42291. set radiusScale(radius: number);
  42292. /**
  42293. * Gets the scale applied to the radius
  42294. */
  42295. get radiusScale(): number;
  42296. /**
  42297. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42298. */
  42299. set positionScale(scale: number);
  42300. /**
  42301. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42302. */
  42303. get positionScale(): number;
  42304. /**
  42305. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42306. * behaviour is triggered, in radians.
  42307. */
  42308. set defaultElevation(elevation: number);
  42309. /**
  42310. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42311. * behaviour is triggered, in radians.
  42312. */
  42313. get defaultElevation(): number;
  42314. /**
  42315. * Sets the time (in milliseconds) taken to return to the default beta position.
  42316. * Negative value indicates camera should not return to default.
  42317. */
  42318. set elevationReturnTime(speed: number);
  42319. /**
  42320. * Gets the time (in milliseconds) taken to return to the default beta position.
  42321. * Negative value indicates camera should not return to default.
  42322. */
  42323. get elevationReturnTime(): number;
  42324. /**
  42325. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42326. */
  42327. set elevationReturnWaitTime(time: number);
  42328. /**
  42329. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42330. */
  42331. get elevationReturnWaitTime(): number;
  42332. /**
  42333. * Sets the flag that indicates if user zooming should stop animation.
  42334. */
  42335. set zoomStopsAnimation(flag: boolean);
  42336. /**
  42337. * Gets the flag that indicates if user zooming should stop animation.
  42338. */
  42339. get zoomStopsAnimation(): boolean;
  42340. /**
  42341. * Sets the transition time when framing the mesh, in milliseconds
  42342. */
  42343. set framingTime(time: number);
  42344. /**
  42345. * Gets the transition time when framing the mesh, in milliseconds
  42346. */
  42347. get framingTime(): number;
  42348. /**
  42349. * Define if the behavior should automatically change the configured
  42350. * camera limits and sensibilities.
  42351. */
  42352. autoCorrectCameraLimitsAndSensibility: boolean;
  42353. private _onPrePointerObservableObserver;
  42354. private _onAfterCheckInputsObserver;
  42355. private _onMeshTargetChangedObserver;
  42356. private _attachedCamera;
  42357. private _isPointerDown;
  42358. private _lastInteractionTime;
  42359. /**
  42360. * Initializes the behavior.
  42361. */
  42362. init(): void;
  42363. /**
  42364. * Attaches the behavior to its arc rotate camera.
  42365. * @param camera Defines the camera to attach the behavior to
  42366. */
  42367. attach(camera: ArcRotateCamera): void;
  42368. /**
  42369. * Detaches the behavior from its current arc rotate camera.
  42370. */
  42371. detach(): void;
  42372. private _animatables;
  42373. private _betaIsAnimating;
  42374. private _betaTransition;
  42375. private _radiusTransition;
  42376. private _vectorTransition;
  42377. /**
  42378. * Targets the given mesh and updates zoom level accordingly.
  42379. * @param mesh The mesh to target.
  42380. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42381. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42382. */
  42383. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42384. /**
  42385. * Targets the given mesh with its children and updates zoom level accordingly.
  42386. * @param mesh The mesh to target.
  42387. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42388. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42389. */
  42390. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42391. /**
  42392. * Targets the given meshes with their children and updates zoom level accordingly.
  42393. * @param meshes The mesh to target.
  42394. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42395. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42396. */
  42397. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42398. /**
  42399. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42400. * @param minimumWorld Determines the smaller position of the bounding box extend
  42401. * @param maximumWorld Determines the bigger position of the bounding box extend
  42402. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42403. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42404. */
  42405. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42406. /**
  42407. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42408. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42409. * frustum width.
  42410. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42411. * to fully enclose the mesh in the viewing frustum.
  42412. */
  42413. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42414. /**
  42415. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42416. * is automatically returned to its default position (expected to be above ground plane).
  42417. */
  42418. private _maintainCameraAboveGround;
  42419. /**
  42420. * Returns the frustum slope based on the canvas ratio and camera FOV
  42421. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42422. */
  42423. private _getFrustumSlope;
  42424. /**
  42425. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42426. */
  42427. private _clearAnimationLocks;
  42428. /**
  42429. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42430. */
  42431. private _applyUserInteraction;
  42432. /**
  42433. * Stops and removes all animations that have been applied to the camera
  42434. */
  42435. stopAllAnimations(): void;
  42436. /**
  42437. * Gets a value indicating if the user is moving the camera
  42438. */
  42439. get isUserIsMoving(): boolean;
  42440. /**
  42441. * The camera can move all the way towards the mesh.
  42442. */
  42443. static IgnoreBoundsSizeMode: number;
  42444. /**
  42445. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42446. */
  42447. static FitFrustumSidesMode: number;
  42448. }
  42449. }
  42450. declare module BABYLON {
  42451. /**
  42452. * Base class for Camera Pointer Inputs.
  42453. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42454. * for example usage.
  42455. */
  42456. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42457. /**
  42458. * Defines the camera the input is attached to.
  42459. */
  42460. abstract camera: Camera;
  42461. /**
  42462. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42463. */
  42464. protected _altKey: boolean;
  42465. protected _ctrlKey: boolean;
  42466. protected _metaKey: boolean;
  42467. protected _shiftKey: boolean;
  42468. /**
  42469. * Which mouse buttons were pressed at time of last mouse event.
  42470. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42471. */
  42472. protected _buttonsPressed: number;
  42473. /**
  42474. * Defines the buttons associated with the input to handle camera move.
  42475. */
  42476. buttons: number[];
  42477. /**
  42478. * Attach the input controls to a specific dom element to get the input from.
  42479. * @param element Defines the element the controls should be listened from
  42480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42481. */
  42482. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42483. /**
  42484. * Detach the current controls from the specified dom element.
  42485. * @param element Defines the element to stop listening the inputs from
  42486. */
  42487. detachControl(element: Nullable<HTMLElement>): void;
  42488. /**
  42489. * Gets the class name of the current input.
  42490. * @returns the class name
  42491. */
  42492. getClassName(): string;
  42493. /**
  42494. * Get the friendly name associated with the input class.
  42495. * @returns the input friendly name
  42496. */
  42497. getSimpleName(): string;
  42498. /**
  42499. * Called on pointer POINTERDOUBLETAP event.
  42500. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42501. */
  42502. protected onDoubleTap(type: string): void;
  42503. /**
  42504. * Called on pointer POINTERMOVE event if only a single touch is active.
  42505. * Override this method to provide functionality.
  42506. */
  42507. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42508. /**
  42509. * Called on pointer POINTERMOVE event if multiple touches are active.
  42510. * Override this method to provide functionality.
  42511. */
  42512. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42513. /**
  42514. * Called on JS contextmenu event.
  42515. * Override this method to provide functionality.
  42516. */
  42517. protected onContextMenu(evt: PointerEvent): void;
  42518. /**
  42519. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42520. * press.
  42521. * Override this method to provide functionality.
  42522. */
  42523. protected onButtonDown(evt: PointerEvent): void;
  42524. /**
  42525. * Called each time a new POINTERUP event occurs. Ie, for each button
  42526. * release.
  42527. * Override this method to provide functionality.
  42528. */
  42529. protected onButtonUp(evt: PointerEvent): void;
  42530. /**
  42531. * Called when window becomes inactive.
  42532. * Override this method to provide functionality.
  42533. */
  42534. protected onLostFocus(): void;
  42535. private _pointerInput;
  42536. private _observer;
  42537. private _onLostFocus;
  42538. private pointA;
  42539. private pointB;
  42540. }
  42541. }
  42542. declare module BABYLON {
  42543. /**
  42544. * Manage the pointers inputs to control an arc rotate camera.
  42545. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42546. */
  42547. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42548. /**
  42549. * Defines the camera the input is attached to.
  42550. */
  42551. camera: ArcRotateCamera;
  42552. /**
  42553. * Gets the class name of the current input.
  42554. * @returns the class name
  42555. */
  42556. getClassName(): string;
  42557. /**
  42558. * Defines the buttons associated with the input to handle camera move.
  42559. */
  42560. buttons: number[];
  42561. /**
  42562. * Defines the pointer angular sensibility along the X axis or how fast is
  42563. * the camera rotating.
  42564. */
  42565. angularSensibilityX: number;
  42566. /**
  42567. * Defines the pointer angular sensibility along the Y axis or how fast is
  42568. * the camera rotating.
  42569. */
  42570. angularSensibilityY: number;
  42571. /**
  42572. * Defines the pointer pinch precision or how fast is the camera zooming.
  42573. */
  42574. pinchPrecision: number;
  42575. /**
  42576. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42577. * from 0.
  42578. * It defines the percentage of current camera.radius to use as delta when
  42579. * pinch zoom is used.
  42580. */
  42581. pinchDeltaPercentage: number;
  42582. /**
  42583. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42584. * that any object in the plane at the camera's target point will scale
  42585. * perfectly with finger motion.
  42586. * Overrides pinchDeltaPercentage and pinchPrecision.
  42587. */
  42588. useNaturalPinchZoom: boolean;
  42589. /**
  42590. * Defines the pointer panning sensibility or how fast is the camera moving.
  42591. */
  42592. panningSensibility: number;
  42593. /**
  42594. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42595. */
  42596. multiTouchPanning: boolean;
  42597. /**
  42598. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42599. * zoom (pinch) through multitouch.
  42600. */
  42601. multiTouchPanAndZoom: boolean;
  42602. /**
  42603. * Revers pinch action direction.
  42604. */
  42605. pinchInwards: boolean;
  42606. private _isPanClick;
  42607. private _twoFingerActivityCount;
  42608. private _isPinching;
  42609. /**
  42610. * Called on pointer POINTERMOVE event if only a single touch is active.
  42611. */
  42612. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42613. /**
  42614. * Called on pointer POINTERDOUBLETAP event.
  42615. */
  42616. protected onDoubleTap(type: string): void;
  42617. /**
  42618. * Called on pointer POINTERMOVE event if multiple touches are active.
  42619. */
  42620. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42621. /**
  42622. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42623. * press.
  42624. */
  42625. protected onButtonDown(evt: PointerEvent): void;
  42626. /**
  42627. * Called each time a new POINTERUP event occurs. Ie, for each button
  42628. * release.
  42629. */
  42630. protected onButtonUp(evt: PointerEvent): void;
  42631. /**
  42632. * Called when window becomes inactive.
  42633. */
  42634. protected onLostFocus(): void;
  42635. }
  42636. }
  42637. declare module BABYLON {
  42638. /**
  42639. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42640. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42641. */
  42642. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42643. /**
  42644. * Defines the camera the input is attached to.
  42645. */
  42646. camera: ArcRotateCamera;
  42647. /**
  42648. * Defines the list of key codes associated with the up action (increase alpha)
  42649. */
  42650. keysUp: number[];
  42651. /**
  42652. * Defines the list of key codes associated with the down action (decrease alpha)
  42653. */
  42654. keysDown: number[];
  42655. /**
  42656. * Defines the list of key codes associated with the left action (increase beta)
  42657. */
  42658. keysLeft: number[];
  42659. /**
  42660. * Defines the list of key codes associated with the right action (decrease beta)
  42661. */
  42662. keysRight: number[];
  42663. /**
  42664. * Defines the list of key codes associated with the reset action.
  42665. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42666. */
  42667. keysReset: number[];
  42668. /**
  42669. * Defines the panning sensibility of the inputs.
  42670. * (How fast is the camera panning)
  42671. */
  42672. panningSensibility: number;
  42673. /**
  42674. * Defines the zooming sensibility of the inputs.
  42675. * (How fast is the camera zooming)
  42676. */
  42677. zoomingSensibility: number;
  42678. /**
  42679. * Defines whether maintaining the alt key down switch the movement mode from
  42680. * orientation to zoom.
  42681. */
  42682. useAltToZoom: boolean;
  42683. /**
  42684. * Rotation speed of the camera
  42685. */
  42686. angularSpeed: number;
  42687. private _keys;
  42688. private _ctrlPressed;
  42689. private _altPressed;
  42690. private _onCanvasBlurObserver;
  42691. private _onKeyboardObserver;
  42692. private _engine;
  42693. private _scene;
  42694. /**
  42695. * Attach the input controls to a specific dom element to get the input from.
  42696. * @param element Defines the element the controls should be listened from
  42697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42698. */
  42699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42700. /**
  42701. * Detach the current controls from the specified dom element.
  42702. * @param element Defines the element to stop listening the inputs from
  42703. */
  42704. detachControl(element: Nullable<HTMLElement>): void;
  42705. /**
  42706. * Update the current camera state depending on the inputs that have been used this frame.
  42707. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42708. */
  42709. checkInputs(): void;
  42710. /**
  42711. * Gets the class name of the current intput.
  42712. * @returns the class name
  42713. */
  42714. getClassName(): string;
  42715. /**
  42716. * Get the friendly name associated with the input class.
  42717. * @returns the input friendly name
  42718. */
  42719. getSimpleName(): string;
  42720. }
  42721. }
  42722. declare module BABYLON {
  42723. /**
  42724. * Manage the mouse wheel inputs to control an arc rotate camera.
  42725. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42726. */
  42727. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42728. /**
  42729. * Defines the camera the input is attached to.
  42730. */
  42731. camera: ArcRotateCamera;
  42732. /**
  42733. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42734. */
  42735. wheelPrecision: number;
  42736. /**
  42737. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42738. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42739. */
  42740. wheelDeltaPercentage: number;
  42741. private _wheel;
  42742. private _observer;
  42743. private computeDeltaFromMouseWheelLegacyEvent;
  42744. /**
  42745. * Attach the input controls to a specific dom element to get the input from.
  42746. * @param element Defines the element the controls should be listened from
  42747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42748. */
  42749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42750. /**
  42751. * Detach the current controls from the specified dom element.
  42752. * @param element Defines the element to stop listening the inputs from
  42753. */
  42754. detachControl(element: Nullable<HTMLElement>): void;
  42755. /**
  42756. * Gets the class name of the current intput.
  42757. * @returns the class name
  42758. */
  42759. getClassName(): string;
  42760. /**
  42761. * Get the friendly name associated with the input class.
  42762. * @returns the input friendly name
  42763. */
  42764. getSimpleName(): string;
  42765. }
  42766. }
  42767. declare module BABYLON {
  42768. /**
  42769. * Default Inputs manager for the ArcRotateCamera.
  42770. * It groups all the default supported inputs for ease of use.
  42771. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42772. */
  42773. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42774. /**
  42775. * Instantiates a new ArcRotateCameraInputsManager.
  42776. * @param camera Defines the camera the inputs belong to
  42777. */
  42778. constructor(camera: ArcRotateCamera);
  42779. /**
  42780. * Add mouse wheel input support to the input manager.
  42781. * @returns the current input manager
  42782. */
  42783. addMouseWheel(): ArcRotateCameraInputsManager;
  42784. /**
  42785. * Add pointers input support to the input manager.
  42786. * @returns the current input manager
  42787. */
  42788. addPointers(): ArcRotateCameraInputsManager;
  42789. /**
  42790. * Add keyboard input support to the input manager.
  42791. * @returns the current input manager
  42792. */
  42793. addKeyboard(): ArcRotateCameraInputsManager;
  42794. }
  42795. }
  42796. declare module BABYLON {
  42797. /**
  42798. * This represents an orbital type of camera.
  42799. *
  42800. * 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.
  42801. * 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.
  42802. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42803. */
  42804. export class ArcRotateCamera extends TargetCamera {
  42805. /**
  42806. * Defines the rotation angle of the camera along the longitudinal axis.
  42807. */
  42808. alpha: number;
  42809. /**
  42810. * Defines the rotation angle of the camera along the latitudinal axis.
  42811. */
  42812. beta: number;
  42813. /**
  42814. * Defines the radius of the camera from it s target point.
  42815. */
  42816. radius: number;
  42817. protected _target: Vector3;
  42818. protected _targetHost: Nullable<AbstractMesh>;
  42819. /**
  42820. * Defines the target point of the camera.
  42821. * The camera looks towards it form the radius distance.
  42822. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42823. */
  42824. get target(): Vector3;
  42825. set target(value: Vector3);
  42826. /**
  42827. * Define the current local position of the camera in the scene
  42828. */
  42829. get position(): Vector3;
  42830. set position(newPosition: Vector3);
  42831. protected _upToYMatrix: Matrix;
  42832. protected _YToUpMatrix: Matrix;
  42833. /**
  42834. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42835. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42836. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42837. */
  42838. set upVector(vec: Vector3);
  42839. get upVector(): Vector3;
  42840. /**
  42841. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42842. */
  42843. setMatUp(): void;
  42844. /**
  42845. * Current inertia value on the longitudinal axis.
  42846. * The bigger this number the longer it will take for the camera to stop.
  42847. */
  42848. inertialAlphaOffset: number;
  42849. /**
  42850. * Current inertia value on the latitudinal axis.
  42851. * The bigger this number the longer it will take for the camera to stop.
  42852. */
  42853. inertialBetaOffset: number;
  42854. /**
  42855. * Current inertia value on the radius axis.
  42856. * The bigger this number the longer it will take for the camera to stop.
  42857. */
  42858. inertialRadiusOffset: number;
  42859. /**
  42860. * Minimum allowed angle on the longitudinal axis.
  42861. * This can help limiting how the Camera is able to move in the scene.
  42862. */
  42863. lowerAlphaLimit: Nullable<number>;
  42864. /**
  42865. * Maximum allowed angle on the longitudinal axis.
  42866. * This can help limiting how the Camera is able to move in the scene.
  42867. */
  42868. upperAlphaLimit: Nullable<number>;
  42869. /**
  42870. * Minimum allowed angle on the latitudinal axis.
  42871. * This can help limiting how the Camera is able to move in the scene.
  42872. */
  42873. lowerBetaLimit: number;
  42874. /**
  42875. * Maximum allowed angle on the latitudinal axis.
  42876. * This can help limiting how the Camera is able to move in the scene.
  42877. */
  42878. upperBetaLimit: number;
  42879. /**
  42880. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42881. * This can help limiting how the Camera is able to move in the scene.
  42882. */
  42883. lowerRadiusLimit: Nullable<number>;
  42884. /**
  42885. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42886. * This can help limiting how the Camera is able to move in the scene.
  42887. */
  42888. upperRadiusLimit: Nullable<number>;
  42889. /**
  42890. * Defines the current inertia value used during panning of the camera along the X axis.
  42891. */
  42892. inertialPanningX: number;
  42893. /**
  42894. * Defines the current inertia value used during panning of the camera along the Y axis.
  42895. */
  42896. inertialPanningY: number;
  42897. /**
  42898. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42899. * Basically if your fingers moves away from more than this distance you will be considered
  42900. * in pinch mode.
  42901. */
  42902. pinchToPanMaxDistance: number;
  42903. /**
  42904. * Defines the maximum distance the camera can pan.
  42905. * This could help keeping the cammera always in your scene.
  42906. */
  42907. panningDistanceLimit: Nullable<number>;
  42908. /**
  42909. * Defines the target of the camera before paning.
  42910. */
  42911. panningOriginTarget: Vector3;
  42912. /**
  42913. * Defines the value of the inertia used during panning.
  42914. * 0 would mean stop inertia and one would mean no decelleration at all.
  42915. */
  42916. panningInertia: number;
  42917. /**
  42918. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42919. */
  42920. get angularSensibilityX(): number;
  42921. set angularSensibilityX(value: number);
  42922. /**
  42923. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42924. */
  42925. get angularSensibilityY(): number;
  42926. set angularSensibilityY(value: number);
  42927. /**
  42928. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42929. */
  42930. get pinchPrecision(): number;
  42931. set pinchPrecision(value: number);
  42932. /**
  42933. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42934. * It will be used instead of pinchDeltaPrecision if different from 0.
  42935. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42936. */
  42937. get pinchDeltaPercentage(): number;
  42938. set pinchDeltaPercentage(value: number);
  42939. /**
  42940. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42941. * and pinch delta percentage.
  42942. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42943. * that any object in the plane at the camera's target point will scale
  42944. * perfectly with finger motion.
  42945. */
  42946. get useNaturalPinchZoom(): boolean;
  42947. set useNaturalPinchZoom(value: boolean);
  42948. /**
  42949. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42950. */
  42951. get panningSensibility(): number;
  42952. set panningSensibility(value: number);
  42953. /**
  42954. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42955. */
  42956. get keysUp(): number[];
  42957. set keysUp(value: number[]);
  42958. /**
  42959. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42960. */
  42961. get keysDown(): number[];
  42962. set keysDown(value: number[]);
  42963. /**
  42964. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42965. */
  42966. get keysLeft(): number[];
  42967. set keysLeft(value: number[]);
  42968. /**
  42969. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42970. */
  42971. get keysRight(): number[];
  42972. set keysRight(value: number[]);
  42973. /**
  42974. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42975. */
  42976. get wheelPrecision(): number;
  42977. set wheelPrecision(value: number);
  42978. /**
  42979. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42980. * It will be used instead of pinchDeltaPrecision if different from 0.
  42981. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42982. */
  42983. get wheelDeltaPercentage(): number;
  42984. set wheelDeltaPercentage(value: number);
  42985. /**
  42986. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42987. */
  42988. zoomOnFactor: number;
  42989. /**
  42990. * Defines a screen offset for the camera position.
  42991. */
  42992. targetScreenOffset: Vector2;
  42993. /**
  42994. * Allows the camera to be completely reversed.
  42995. * If false the camera can not arrive upside down.
  42996. */
  42997. allowUpsideDown: boolean;
  42998. /**
  42999. * Define if double tap/click is used to restore the previously saved state of the camera.
  43000. */
  43001. useInputToRestoreState: boolean;
  43002. /** @hidden */
  43003. _viewMatrix: Matrix;
  43004. /** @hidden */
  43005. _useCtrlForPanning: boolean;
  43006. /** @hidden */
  43007. _panningMouseButton: number;
  43008. /**
  43009. * Defines the input associated to the camera.
  43010. */
  43011. inputs: ArcRotateCameraInputsManager;
  43012. /** @hidden */
  43013. _reset: () => void;
  43014. /**
  43015. * Defines the allowed panning axis.
  43016. */
  43017. panningAxis: Vector3;
  43018. protected _localDirection: Vector3;
  43019. protected _transformedDirection: Vector3;
  43020. private _bouncingBehavior;
  43021. /**
  43022. * Gets the bouncing behavior of the camera if it has been enabled.
  43023. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43024. */
  43025. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43026. /**
  43027. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43028. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43029. */
  43030. get useBouncingBehavior(): boolean;
  43031. set useBouncingBehavior(value: boolean);
  43032. private _framingBehavior;
  43033. /**
  43034. * Gets the framing behavior of the camera if it has been enabled.
  43035. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43036. */
  43037. get framingBehavior(): Nullable<FramingBehavior>;
  43038. /**
  43039. * Defines if the framing behavior of the camera is enabled on the camera.
  43040. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43041. */
  43042. get useFramingBehavior(): boolean;
  43043. set useFramingBehavior(value: boolean);
  43044. private _autoRotationBehavior;
  43045. /**
  43046. * Gets the auto rotation behavior of the camera if it has been enabled.
  43047. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43048. */
  43049. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43050. /**
  43051. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43052. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43053. */
  43054. get useAutoRotationBehavior(): boolean;
  43055. set useAutoRotationBehavior(value: boolean);
  43056. /**
  43057. * Observable triggered when the mesh target has been changed on the camera.
  43058. */
  43059. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43060. /**
  43061. * Event raised when the camera is colliding with a mesh.
  43062. */
  43063. onCollide: (collidedMesh: AbstractMesh) => void;
  43064. /**
  43065. * Defines whether the camera should check collision with the objects oh the scene.
  43066. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43067. */
  43068. checkCollisions: boolean;
  43069. /**
  43070. * Defines the collision radius of the camera.
  43071. * This simulates a sphere around the camera.
  43072. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43073. */
  43074. collisionRadius: Vector3;
  43075. protected _collider: Collider;
  43076. protected _previousPosition: Vector3;
  43077. protected _collisionVelocity: Vector3;
  43078. protected _newPosition: Vector3;
  43079. protected _previousAlpha: number;
  43080. protected _previousBeta: number;
  43081. protected _previousRadius: number;
  43082. protected _collisionTriggered: boolean;
  43083. protected _targetBoundingCenter: Nullable<Vector3>;
  43084. private _computationVector;
  43085. /**
  43086. * Instantiates a new ArcRotateCamera in a given scene
  43087. * @param name Defines the name of the camera
  43088. * @param alpha Defines the camera rotation along the logitudinal axis
  43089. * @param beta Defines the camera rotation along the latitudinal axis
  43090. * @param radius Defines the camera distance from its target
  43091. * @param target Defines the camera target
  43092. * @param scene Defines the scene the camera belongs to
  43093. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43094. */
  43095. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43096. /** @hidden */
  43097. _initCache(): void;
  43098. /** @hidden */
  43099. _updateCache(ignoreParentClass?: boolean): void;
  43100. protected _getTargetPosition(): Vector3;
  43101. private _storedAlpha;
  43102. private _storedBeta;
  43103. private _storedRadius;
  43104. private _storedTarget;
  43105. private _storedTargetScreenOffset;
  43106. /**
  43107. * Stores the current state of the camera (alpha, beta, radius and target)
  43108. * @returns the camera itself
  43109. */
  43110. storeState(): Camera;
  43111. /**
  43112. * @hidden
  43113. * Restored camera state. You must call storeState() first
  43114. */
  43115. _restoreStateValues(): boolean;
  43116. /** @hidden */
  43117. _isSynchronizedViewMatrix(): boolean;
  43118. /**
  43119. * Attached controls to the current camera.
  43120. * @param element Defines the element the controls should be listened from
  43121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43122. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43123. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43124. */
  43125. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43126. /**
  43127. * Detach the current controls from the camera.
  43128. * The camera will stop reacting to inputs.
  43129. * @param element Defines the element to stop listening the inputs from
  43130. */
  43131. detachControl(element: HTMLElement): void;
  43132. /** @hidden */
  43133. _checkInputs(): void;
  43134. protected _checkLimits(): void;
  43135. /**
  43136. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43137. */
  43138. rebuildAnglesAndRadius(): void;
  43139. /**
  43140. * Use a position to define the current camera related information like alpha, beta and radius
  43141. * @param position Defines the position to set the camera at
  43142. */
  43143. setPosition(position: Vector3): void;
  43144. /**
  43145. * Defines the target the camera should look at.
  43146. * This will automatically adapt alpha beta and radius to fit within the new target.
  43147. * @param target Defines the new target as a Vector or a mesh
  43148. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43149. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43150. */
  43151. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43152. /** @hidden */
  43153. _getViewMatrix(): Matrix;
  43154. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43155. /**
  43156. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43157. * @param meshes Defines the mesh to zoom on
  43158. * @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)
  43159. */
  43160. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43161. /**
  43162. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43163. * The target will be changed but the radius
  43164. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43165. * @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)
  43166. */
  43167. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43168. min: Vector3;
  43169. max: Vector3;
  43170. distance: number;
  43171. }, doNotUpdateMaxZ?: boolean): void;
  43172. /**
  43173. * @override
  43174. * Override Camera.createRigCamera
  43175. */
  43176. createRigCamera(name: string, cameraIndex: number): Camera;
  43177. /**
  43178. * @hidden
  43179. * @override
  43180. * Override Camera._updateRigCameras
  43181. */
  43182. _updateRigCameras(): void;
  43183. /**
  43184. * Destroy the camera and release the current resources hold by it.
  43185. */
  43186. dispose(): void;
  43187. /**
  43188. * Gets the current object class name.
  43189. * @return the class name
  43190. */
  43191. getClassName(): string;
  43192. }
  43193. }
  43194. declare module BABYLON {
  43195. /**
  43196. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43197. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43198. */
  43199. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43200. /**
  43201. * Gets the name of the behavior.
  43202. */
  43203. get name(): string;
  43204. private _zoomStopsAnimation;
  43205. private _idleRotationSpeed;
  43206. private _idleRotationWaitTime;
  43207. private _idleRotationSpinupTime;
  43208. /**
  43209. * Sets the flag that indicates if user zooming should stop animation.
  43210. */
  43211. set zoomStopsAnimation(flag: boolean);
  43212. /**
  43213. * Gets the flag that indicates if user zooming should stop animation.
  43214. */
  43215. get zoomStopsAnimation(): boolean;
  43216. /**
  43217. * Sets the default speed at which the camera rotates around the model.
  43218. */
  43219. set idleRotationSpeed(speed: number);
  43220. /**
  43221. * Gets the default speed at which the camera rotates around the model.
  43222. */
  43223. get idleRotationSpeed(): number;
  43224. /**
  43225. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43226. */
  43227. set idleRotationWaitTime(time: number);
  43228. /**
  43229. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43230. */
  43231. get idleRotationWaitTime(): number;
  43232. /**
  43233. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43234. */
  43235. set idleRotationSpinupTime(time: number);
  43236. /**
  43237. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43238. */
  43239. get idleRotationSpinupTime(): number;
  43240. /**
  43241. * Gets a value indicating if the camera is currently rotating because of this behavior
  43242. */
  43243. get rotationInProgress(): boolean;
  43244. private _onPrePointerObservableObserver;
  43245. private _onAfterCheckInputsObserver;
  43246. private _attachedCamera;
  43247. private _isPointerDown;
  43248. private _lastFrameTime;
  43249. private _lastInteractionTime;
  43250. private _cameraRotationSpeed;
  43251. /**
  43252. * Initializes the behavior.
  43253. */
  43254. init(): void;
  43255. /**
  43256. * Attaches the behavior to its arc rotate camera.
  43257. * @param camera Defines the camera to attach the behavior to
  43258. */
  43259. attach(camera: ArcRotateCamera): void;
  43260. /**
  43261. * Detaches the behavior from its current arc rotate camera.
  43262. */
  43263. detach(): void;
  43264. /**
  43265. * Returns true if user is scrolling.
  43266. * @return true if user is scrolling.
  43267. */
  43268. private _userIsZooming;
  43269. private _lastFrameRadius;
  43270. private _shouldAnimationStopForInteraction;
  43271. /**
  43272. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43273. */
  43274. private _applyUserInteraction;
  43275. private _userIsMoving;
  43276. }
  43277. }
  43278. declare module BABYLON {
  43279. /**
  43280. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43281. */
  43282. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43283. private ui;
  43284. /**
  43285. * The name of the behavior
  43286. */
  43287. name: string;
  43288. /**
  43289. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43290. */
  43291. distanceAwayFromFace: number;
  43292. /**
  43293. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43294. */
  43295. distanceAwayFromBottomOfFace: number;
  43296. private _faceVectors;
  43297. private _target;
  43298. private _scene;
  43299. private _onRenderObserver;
  43300. private _tmpMatrix;
  43301. private _tmpVector;
  43302. /**
  43303. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43304. * @param ui The transform node that should be attched to the mesh
  43305. */
  43306. constructor(ui: TransformNode);
  43307. /**
  43308. * Initializes the behavior
  43309. */
  43310. init(): void;
  43311. private _closestFace;
  43312. private _zeroVector;
  43313. private _lookAtTmpMatrix;
  43314. private _lookAtToRef;
  43315. /**
  43316. * Attaches the AttachToBoxBehavior to the passed in mesh
  43317. * @param target The mesh that the specified node will be attached to
  43318. */
  43319. attach(target: Mesh): void;
  43320. /**
  43321. * Detaches the behavior from the mesh
  43322. */
  43323. detach(): void;
  43324. }
  43325. }
  43326. declare module BABYLON {
  43327. /**
  43328. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43329. */
  43330. export class FadeInOutBehavior implements Behavior<Mesh> {
  43331. /**
  43332. * Time in milliseconds to delay before fading in (Default: 0)
  43333. */
  43334. delay: number;
  43335. /**
  43336. * Time in milliseconds for the mesh to fade in (Default: 300)
  43337. */
  43338. fadeInTime: number;
  43339. private _millisecondsPerFrame;
  43340. private _hovered;
  43341. private _hoverValue;
  43342. private _ownerNode;
  43343. /**
  43344. * Instatiates the FadeInOutBehavior
  43345. */
  43346. constructor();
  43347. /**
  43348. * The name of the behavior
  43349. */
  43350. get name(): string;
  43351. /**
  43352. * Initializes the behavior
  43353. */
  43354. init(): void;
  43355. /**
  43356. * Attaches the fade behavior on the passed in mesh
  43357. * @param ownerNode The mesh that will be faded in/out once attached
  43358. */
  43359. attach(ownerNode: Mesh): void;
  43360. /**
  43361. * Detaches the behavior from the mesh
  43362. */
  43363. detach(): void;
  43364. /**
  43365. * Triggers the mesh to begin fading in or out
  43366. * @param value if the object should fade in or out (true to fade in)
  43367. */
  43368. fadeIn(value: boolean): void;
  43369. private _update;
  43370. private _setAllVisibility;
  43371. }
  43372. }
  43373. declare module BABYLON {
  43374. /**
  43375. * Class containing a set of static utilities functions for managing Pivots
  43376. * @hidden
  43377. */
  43378. export class PivotTools {
  43379. private static _PivotCached;
  43380. private static _OldPivotPoint;
  43381. private static _PivotTranslation;
  43382. private static _PivotTmpVector;
  43383. /** @hidden */
  43384. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43385. /** @hidden */
  43386. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43387. }
  43388. }
  43389. declare module BABYLON {
  43390. /**
  43391. * Class containing static functions to help procedurally build meshes
  43392. */
  43393. export class PlaneBuilder {
  43394. /**
  43395. * Creates a plane mesh
  43396. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43397. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43398. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43400. * * 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
  43401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43402. * @param name defines the name of the mesh
  43403. * @param options defines the options used to create the mesh
  43404. * @param scene defines the hosting scene
  43405. * @returns the plane mesh
  43406. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43407. */
  43408. static CreatePlane(name: string, options: {
  43409. size?: number;
  43410. width?: number;
  43411. height?: number;
  43412. sideOrientation?: number;
  43413. frontUVs?: Vector4;
  43414. backUVs?: Vector4;
  43415. updatable?: boolean;
  43416. sourcePlane?: Plane;
  43417. }, scene?: Nullable<Scene>): Mesh;
  43418. }
  43419. }
  43420. declare module BABYLON {
  43421. /**
  43422. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43423. */
  43424. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43425. private static _AnyMouseID;
  43426. /**
  43427. * Abstract mesh the behavior is set on
  43428. */
  43429. attachedNode: AbstractMesh;
  43430. private _dragPlane;
  43431. private _scene;
  43432. private _pointerObserver;
  43433. private _beforeRenderObserver;
  43434. private static _planeScene;
  43435. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43436. /**
  43437. * 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)
  43438. */
  43439. maxDragAngle: number;
  43440. /**
  43441. * @hidden
  43442. */
  43443. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43444. /**
  43445. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43446. */
  43447. currentDraggingPointerID: number;
  43448. /**
  43449. * The last position where the pointer hit the drag plane in world space
  43450. */
  43451. lastDragPosition: Vector3;
  43452. /**
  43453. * If the behavior is currently in a dragging state
  43454. */
  43455. dragging: boolean;
  43456. /**
  43457. * 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)
  43458. */
  43459. dragDeltaRatio: number;
  43460. /**
  43461. * If the drag plane orientation should be updated during the dragging (Default: true)
  43462. */
  43463. updateDragPlane: boolean;
  43464. private _debugMode;
  43465. private _moving;
  43466. /**
  43467. * Fires each time the attached mesh is dragged with the pointer
  43468. * * delta between last drag position and current drag position in world space
  43469. * * dragDistance along the drag axis
  43470. * * dragPlaneNormal normal of the current drag plane used during the drag
  43471. * * dragPlanePoint in world space where the drag intersects the drag plane
  43472. */
  43473. onDragObservable: Observable<{
  43474. delta: Vector3;
  43475. dragPlanePoint: Vector3;
  43476. dragPlaneNormal: Vector3;
  43477. dragDistance: number;
  43478. pointerId: number;
  43479. }>;
  43480. /**
  43481. * Fires each time a drag begins (eg. mouse down on mesh)
  43482. */
  43483. onDragStartObservable: Observable<{
  43484. dragPlanePoint: Vector3;
  43485. pointerId: number;
  43486. }>;
  43487. /**
  43488. * Fires each time a drag ends (eg. mouse release after drag)
  43489. */
  43490. onDragEndObservable: Observable<{
  43491. dragPlanePoint: Vector3;
  43492. pointerId: number;
  43493. }>;
  43494. /**
  43495. * If the attached mesh should be moved when dragged
  43496. */
  43497. moveAttached: boolean;
  43498. /**
  43499. * If the drag behavior will react to drag events (Default: true)
  43500. */
  43501. enabled: boolean;
  43502. /**
  43503. * If pointer events should start and release the drag (Default: true)
  43504. */
  43505. startAndReleaseDragOnPointerEvents: boolean;
  43506. /**
  43507. * If camera controls should be detached during the drag
  43508. */
  43509. detachCameraControls: boolean;
  43510. /**
  43511. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43512. */
  43513. useObjectOrientationForDragging: boolean;
  43514. private _options;
  43515. /**
  43516. * Gets the options used by the behavior
  43517. */
  43518. get options(): {
  43519. dragAxis?: Vector3;
  43520. dragPlaneNormal?: Vector3;
  43521. };
  43522. /**
  43523. * Sets the options used by the behavior
  43524. */
  43525. set options(options: {
  43526. dragAxis?: Vector3;
  43527. dragPlaneNormal?: Vector3;
  43528. });
  43529. /**
  43530. * Creates a pointer drag behavior that can be attached to a mesh
  43531. * @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)
  43532. */
  43533. constructor(options?: {
  43534. dragAxis?: Vector3;
  43535. dragPlaneNormal?: Vector3;
  43536. });
  43537. /**
  43538. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43539. */
  43540. validateDrag: (targetPosition: Vector3) => boolean;
  43541. /**
  43542. * The name of the behavior
  43543. */
  43544. get name(): string;
  43545. /**
  43546. * Initializes the behavior
  43547. */
  43548. init(): void;
  43549. private _tmpVector;
  43550. private _alternatePickedPoint;
  43551. private _worldDragAxis;
  43552. private _targetPosition;
  43553. private _attachedElement;
  43554. /**
  43555. * Attaches the drag behavior the passed in mesh
  43556. * @param ownerNode The mesh that will be dragged around once attached
  43557. * @param predicate Predicate to use for pick filtering
  43558. */
  43559. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43560. /**
  43561. * Force relase the drag action by code.
  43562. */
  43563. releaseDrag(): void;
  43564. private _startDragRay;
  43565. private _lastPointerRay;
  43566. /**
  43567. * Simulates the start of a pointer drag event on the behavior
  43568. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43569. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43570. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43571. */
  43572. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43573. private _startDrag;
  43574. private _dragDelta;
  43575. private _moveDrag;
  43576. private _pickWithRayOnDragPlane;
  43577. private _pointA;
  43578. private _pointC;
  43579. private _localAxis;
  43580. private _lookAt;
  43581. private _updateDragPlanePosition;
  43582. /**
  43583. * Detaches the behavior from the mesh
  43584. */
  43585. detach(): void;
  43586. }
  43587. }
  43588. declare module BABYLON {
  43589. /**
  43590. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43591. */
  43592. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43593. private _dragBehaviorA;
  43594. private _dragBehaviorB;
  43595. private _startDistance;
  43596. private _initialScale;
  43597. private _targetScale;
  43598. private _ownerNode;
  43599. private _sceneRenderObserver;
  43600. /**
  43601. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43602. */
  43603. constructor();
  43604. /**
  43605. * The name of the behavior
  43606. */
  43607. get name(): string;
  43608. /**
  43609. * Initializes the behavior
  43610. */
  43611. init(): void;
  43612. private _getCurrentDistance;
  43613. /**
  43614. * Attaches the scale behavior the passed in mesh
  43615. * @param ownerNode The mesh that will be scaled around once attached
  43616. */
  43617. attach(ownerNode: Mesh): void;
  43618. /**
  43619. * Detaches the behavior from the mesh
  43620. */
  43621. detach(): void;
  43622. }
  43623. }
  43624. declare module BABYLON {
  43625. /**
  43626. * 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
  43627. */
  43628. export class SixDofDragBehavior implements Behavior<Mesh> {
  43629. private static _virtualScene;
  43630. private _ownerNode;
  43631. private _sceneRenderObserver;
  43632. private _scene;
  43633. private _targetPosition;
  43634. private _virtualOriginMesh;
  43635. private _virtualDragMesh;
  43636. private _pointerObserver;
  43637. private _moving;
  43638. private _startingOrientation;
  43639. private _attachedElement;
  43640. /**
  43641. * 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)
  43642. */
  43643. private zDragFactor;
  43644. /**
  43645. * If the object should rotate to face the drag origin
  43646. */
  43647. rotateDraggedObject: boolean;
  43648. /**
  43649. * If the behavior is currently in a dragging state
  43650. */
  43651. dragging: boolean;
  43652. /**
  43653. * 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)
  43654. */
  43655. dragDeltaRatio: number;
  43656. /**
  43657. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43658. */
  43659. currentDraggingPointerID: number;
  43660. /**
  43661. * If camera controls should be detached during the drag
  43662. */
  43663. detachCameraControls: boolean;
  43664. /**
  43665. * Fires each time a drag starts
  43666. */
  43667. onDragStartObservable: Observable<{}>;
  43668. /**
  43669. * Fires each time a drag ends (eg. mouse release after drag)
  43670. */
  43671. onDragEndObservable: Observable<{}>;
  43672. /**
  43673. * 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
  43674. */
  43675. constructor();
  43676. /**
  43677. * The name of the behavior
  43678. */
  43679. get name(): string;
  43680. /**
  43681. * Initializes the behavior
  43682. */
  43683. init(): void;
  43684. /**
  43685. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43686. */
  43687. private get _pointerCamera();
  43688. /**
  43689. * Attaches the scale behavior the passed in mesh
  43690. * @param ownerNode The mesh that will be scaled around once attached
  43691. */
  43692. attach(ownerNode: Mesh): void;
  43693. /**
  43694. * Detaches the behavior from the mesh
  43695. */
  43696. detach(): void;
  43697. }
  43698. }
  43699. declare module BABYLON {
  43700. /**
  43701. * Class used to apply inverse kinematics to bones
  43702. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43703. */
  43704. export class BoneIKController {
  43705. private static _tmpVecs;
  43706. private static _tmpQuat;
  43707. private static _tmpMats;
  43708. /**
  43709. * Gets or sets the target mesh
  43710. */
  43711. targetMesh: AbstractMesh;
  43712. /** Gets or sets the mesh used as pole */
  43713. poleTargetMesh: AbstractMesh;
  43714. /**
  43715. * Gets or sets the bone used as pole
  43716. */
  43717. poleTargetBone: Nullable<Bone>;
  43718. /**
  43719. * Gets or sets the target position
  43720. */
  43721. targetPosition: Vector3;
  43722. /**
  43723. * Gets or sets the pole target position
  43724. */
  43725. poleTargetPosition: Vector3;
  43726. /**
  43727. * Gets or sets the pole target local offset
  43728. */
  43729. poleTargetLocalOffset: Vector3;
  43730. /**
  43731. * Gets or sets the pole angle
  43732. */
  43733. poleAngle: number;
  43734. /**
  43735. * Gets or sets the mesh associated with the controller
  43736. */
  43737. mesh: AbstractMesh;
  43738. /**
  43739. * 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)
  43740. */
  43741. slerpAmount: number;
  43742. private _bone1Quat;
  43743. private _bone1Mat;
  43744. private _bone2Ang;
  43745. private _bone1;
  43746. private _bone2;
  43747. private _bone1Length;
  43748. private _bone2Length;
  43749. private _maxAngle;
  43750. private _maxReach;
  43751. private _rightHandedSystem;
  43752. private _bendAxis;
  43753. private _slerping;
  43754. private _adjustRoll;
  43755. /**
  43756. * Gets or sets maximum allowed angle
  43757. */
  43758. get maxAngle(): number;
  43759. set maxAngle(value: number);
  43760. /**
  43761. * Creates a new BoneIKController
  43762. * @param mesh defines the mesh to control
  43763. * @param bone defines the bone to control
  43764. * @param options defines options to set up the controller
  43765. */
  43766. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43767. targetMesh?: AbstractMesh;
  43768. poleTargetMesh?: AbstractMesh;
  43769. poleTargetBone?: Bone;
  43770. poleTargetLocalOffset?: Vector3;
  43771. poleAngle?: number;
  43772. bendAxis?: Vector3;
  43773. maxAngle?: number;
  43774. slerpAmount?: number;
  43775. });
  43776. private _setMaxAngle;
  43777. /**
  43778. * Force the controller to update the bones
  43779. */
  43780. update(): void;
  43781. }
  43782. }
  43783. declare module BABYLON {
  43784. /**
  43785. * Class used to make a bone look toward a point in space
  43786. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43787. */
  43788. export class BoneLookController {
  43789. private static _tmpVecs;
  43790. private static _tmpQuat;
  43791. private static _tmpMats;
  43792. /**
  43793. * The target Vector3 that the bone will look at
  43794. */
  43795. target: Vector3;
  43796. /**
  43797. * The mesh that the bone is attached to
  43798. */
  43799. mesh: AbstractMesh;
  43800. /**
  43801. * The bone that will be looking to the target
  43802. */
  43803. bone: Bone;
  43804. /**
  43805. * The up axis of the coordinate system that is used when the bone is rotated
  43806. */
  43807. upAxis: Vector3;
  43808. /**
  43809. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43810. */
  43811. upAxisSpace: Space;
  43812. /**
  43813. * Used to make an adjustment to the yaw of the bone
  43814. */
  43815. adjustYaw: number;
  43816. /**
  43817. * Used to make an adjustment to the pitch of the bone
  43818. */
  43819. adjustPitch: number;
  43820. /**
  43821. * Used to make an adjustment to the roll of the bone
  43822. */
  43823. adjustRoll: number;
  43824. /**
  43825. * 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)
  43826. */
  43827. slerpAmount: number;
  43828. private _minYaw;
  43829. private _maxYaw;
  43830. private _minPitch;
  43831. private _maxPitch;
  43832. private _minYawSin;
  43833. private _minYawCos;
  43834. private _maxYawSin;
  43835. private _maxYawCos;
  43836. private _midYawConstraint;
  43837. private _minPitchTan;
  43838. private _maxPitchTan;
  43839. private _boneQuat;
  43840. private _slerping;
  43841. private _transformYawPitch;
  43842. private _transformYawPitchInv;
  43843. private _firstFrameSkipped;
  43844. private _yawRange;
  43845. private _fowardAxis;
  43846. /**
  43847. * Gets or sets the minimum yaw angle that the bone can look to
  43848. */
  43849. get minYaw(): number;
  43850. set minYaw(value: number);
  43851. /**
  43852. * Gets or sets the maximum yaw angle that the bone can look to
  43853. */
  43854. get maxYaw(): number;
  43855. set maxYaw(value: number);
  43856. /**
  43857. * Gets or sets the minimum pitch angle that the bone can look to
  43858. */
  43859. get minPitch(): number;
  43860. set minPitch(value: number);
  43861. /**
  43862. * Gets or sets the maximum pitch angle that the bone can look to
  43863. */
  43864. get maxPitch(): number;
  43865. set maxPitch(value: number);
  43866. /**
  43867. * Create a BoneLookController
  43868. * @param mesh the mesh that the bone belongs to
  43869. * @param bone the bone that will be looking to the target
  43870. * @param target the target Vector3 to look at
  43871. * @param options optional settings:
  43872. * * maxYaw: the maximum angle the bone will yaw to
  43873. * * minYaw: the minimum angle the bone will yaw to
  43874. * * maxPitch: the maximum angle the bone will pitch to
  43875. * * minPitch: the minimum angle the bone will yaw to
  43876. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43877. * * upAxis: the up axis of the coordinate system
  43878. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43879. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43880. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43881. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43882. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43883. * * adjustRoll: used to make an adjustment to the roll of the bone
  43884. **/
  43885. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43886. maxYaw?: number;
  43887. minYaw?: number;
  43888. maxPitch?: number;
  43889. minPitch?: number;
  43890. slerpAmount?: number;
  43891. upAxis?: Vector3;
  43892. upAxisSpace?: Space;
  43893. yawAxis?: Vector3;
  43894. pitchAxis?: Vector3;
  43895. adjustYaw?: number;
  43896. adjustPitch?: number;
  43897. adjustRoll?: number;
  43898. });
  43899. /**
  43900. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43901. */
  43902. update(): void;
  43903. private _getAngleDiff;
  43904. private _getAngleBetween;
  43905. private _isAngleBetween;
  43906. }
  43907. }
  43908. declare module BABYLON {
  43909. /**
  43910. * Manage the gamepad inputs to control an arc rotate camera.
  43911. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43912. */
  43913. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43914. /**
  43915. * Defines the camera the input is attached to.
  43916. */
  43917. camera: ArcRotateCamera;
  43918. /**
  43919. * Defines the gamepad the input is gathering event from.
  43920. */
  43921. gamepad: Nullable<Gamepad>;
  43922. /**
  43923. * Defines the gamepad rotation sensiblity.
  43924. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43925. */
  43926. gamepadRotationSensibility: number;
  43927. /**
  43928. * Defines the gamepad move sensiblity.
  43929. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43930. */
  43931. gamepadMoveSensibility: number;
  43932. private _yAxisScale;
  43933. /**
  43934. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43935. */
  43936. get invertYAxis(): boolean;
  43937. set invertYAxis(value: boolean);
  43938. private _onGamepadConnectedObserver;
  43939. private _onGamepadDisconnectedObserver;
  43940. /**
  43941. * Attach the input controls to a specific dom element to get the input from.
  43942. * @param element Defines the element the controls should be listened from
  43943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43944. */
  43945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43946. /**
  43947. * Detach the current controls from the specified dom element.
  43948. * @param element Defines the element to stop listening the inputs from
  43949. */
  43950. detachControl(element: Nullable<HTMLElement>): void;
  43951. /**
  43952. * Update the current camera state depending on the inputs that have been used this frame.
  43953. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43954. */
  43955. checkInputs(): void;
  43956. /**
  43957. * Gets the class name of the current intput.
  43958. * @returns the class name
  43959. */
  43960. getClassName(): string;
  43961. /**
  43962. * Get the friendly name associated with the input class.
  43963. * @returns the input friendly name
  43964. */
  43965. getSimpleName(): string;
  43966. }
  43967. }
  43968. declare module BABYLON {
  43969. interface ArcRotateCameraInputsManager {
  43970. /**
  43971. * Add orientation input support to the input manager.
  43972. * @returns the current input manager
  43973. */
  43974. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43975. }
  43976. /**
  43977. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43978. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43979. */
  43980. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43981. /**
  43982. * Defines the camera the input is attached to.
  43983. */
  43984. camera: ArcRotateCamera;
  43985. /**
  43986. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43987. */
  43988. alphaCorrection: number;
  43989. /**
  43990. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43991. */
  43992. gammaCorrection: number;
  43993. private _alpha;
  43994. private _gamma;
  43995. private _dirty;
  43996. private _deviceOrientationHandler;
  43997. /**
  43998. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43999. */
  44000. constructor();
  44001. /**
  44002. * Attach the input controls to a specific dom element to get the input from.
  44003. * @param element Defines the element the controls should be listened from
  44004. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44005. */
  44006. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44007. /** @hidden */
  44008. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44009. /**
  44010. * Update the current camera state depending on the inputs that have been used this frame.
  44011. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44012. */
  44013. checkInputs(): void;
  44014. /**
  44015. * Detach the current controls from the specified dom element.
  44016. * @param element Defines the element to stop listening the inputs from
  44017. */
  44018. detachControl(element: Nullable<HTMLElement>): void;
  44019. /**
  44020. * Gets the class name of the current intput.
  44021. * @returns the class name
  44022. */
  44023. getClassName(): string;
  44024. /**
  44025. * Get the friendly name associated with the input class.
  44026. * @returns the input friendly name
  44027. */
  44028. getSimpleName(): string;
  44029. }
  44030. }
  44031. declare module BABYLON {
  44032. /**
  44033. * Listen to mouse events to control the camera.
  44034. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44035. */
  44036. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44037. /**
  44038. * Defines the camera the input is attached to.
  44039. */
  44040. camera: FlyCamera;
  44041. /**
  44042. * Defines if touch is enabled. (Default is true.)
  44043. */
  44044. touchEnabled: boolean;
  44045. /**
  44046. * Defines the buttons associated with the input to handle camera rotation.
  44047. */
  44048. buttons: number[];
  44049. /**
  44050. * Assign buttons for Yaw control.
  44051. */
  44052. buttonsYaw: number[];
  44053. /**
  44054. * Assign buttons for Pitch control.
  44055. */
  44056. buttonsPitch: number[];
  44057. /**
  44058. * Assign buttons for Roll control.
  44059. */
  44060. buttonsRoll: number[];
  44061. /**
  44062. * Detect if any button is being pressed while mouse is moved.
  44063. * -1 = Mouse locked.
  44064. * 0 = Left button.
  44065. * 1 = Middle Button.
  44066. * 2 = Right Button.
  44067. */
  44068. activeButton: number;
  44069. /**
  44070. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44071. * Higher values reduce its sensitivity.
  44072. */
  44073. angularSensibility: number;
  44074. private _mousemoveCallback;
  44075. private _observer;
  44076. private _rollObserver;
  44077. private previousPosition;
  44078. private noPreventDefault;
  44079. private element;
  44080. /**
  44081. * Listen to mouse events to control the camera.
  44082. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44083. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44084. */
  44085. constructor(touchEnabled?: boolean);
  44086. /**
  44087. * Attach the mouse control to the HTML DOM element.
  44088. * @param element Defines the element that listens to the input events.
  44089. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44090. */
  44091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44092. /**
  44093. * Detach the current controls from the specified dom element.
  44094. * @param element Defines the element to stop listening the inputs from
  44095. */
  44096. detachControl(element: Nullable<HTMLElement>): void;
  44097. /**
  44098. * Gets the class name of the current input.
  44099. * @returns the class name.
  44100. */
  44101. getClassName(): string;
  44102. /**
  44103. * Get the friendly name associated with the input class.
  44104. * @returns the input's friendly name.
  44105. */
  44106. getSimpleName(): string;
  44107. private _pointerInput;
  44108. private _onMouseMove;
  44109. /**
  44110. * Rotate camera by mouse offset.
  44111. */
  44112. private rotateCamera;
  44113. }
  44114. }
  44115. declare module BABYLON {
  44116. /**
  44117. * Default Inputs manager for the FlyCamera.
  44118. * It groups all the default supported inputs for ease of use.
  44119. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44120. */
  44121. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44122. /**
  44123. * Instantiates a new FlyCameraInputsManager.
  44124. * @param camera Defines the camera the inputs belong to.
  44125. */
  44126. constructor(camera: FlyCamera);
  44127. /**
  44128. * Add keyboard input support to the input manager.
  44129. * @returns the new FlyCameraKeyboardMoveInput().
  44130. */
  44131. addKeyboard(): FlyCameraInputsManager;
  44132. /**
  44133. * Add mouse input support to the input manager.
  44134. * @param touchEnabled Enable touch screen support.
  44135. * @returns the new FlyCameraMouseInput().
  44136. */
  44137. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44138. }
  44139. }
  44140. declare module BABYLON {
  44141. /**
  44142. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44143. * such as in a 3D Space Shooter or a Flight Simulator.
  44144. */
  44145. export class FlyCamera extends TargetCamera {
  44146. /**
  44147. * Define the collision ellipsoid of the camera.
  44148. * This is helpful for simulating a camera body, like a player's body.
  44149. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44150. */
  44151. ellipsoid: Vector3;
  44152. /**
  44153. * Define an offset for the position of the ellipsoid around the camera.
  44154. * This can be helpful if the camera is attached away from the player's body center,
  44155. * such as at its head.
  44156. */
  44157. ellipsoidOffset: Vector3;
  44158. /**
  44159. * Enable or disable collisions of the camera with the rest of the scene objects.
  44160. */
  44161. checkCollisions: boolean;
  44162. /**
  44163. * Enable or disable gravity on the camera.
  44164. */
  44165. applyGravity: boolean;
  44166. /**
  44167. * Define the current direction the camera is moving to.
  44168. */
  44169. cameraDirection: Vector3;
  44170. /**
  44171. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44172. * This overrides and empties cameraRotation.
  44173. */
  44174. rotationQuaternion: Quaternion;
  44175. /**
  44176. * Track Roll to maintain the wanted Rolling when looking around.
  44177. */
  44178. _trackRoll: number;
  44179. /**
  44180. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44181. */
  44182. rollCorrect: number;
  44183. /**
  44184. * Mimic a banked turn, Rolling the camera when Yawing.
  44185. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44186. */
  44187. bankedTurn: boolean;
  44188. /**
  44189. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44190. */
  44191. bankedTurnLimit: number;
  44192. /**
  44193. * Value of 0 disables the banked Roll.
  44194. * Value of 1 is equal to the Yaw angle in radians.
  44195. */
  44196. bankedTurnMultiplier: number;
  44197. /**
  44198. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44199. */
  44200. inputs: FlyCameraInputsManager;
  44201. /**
  44202. * Gets the input sensibility for mouse input.
  44203. * Higher values reduce sensitivity.
  44204. */
  44205. get angularSensibility(): number;
  44206. /**
  44207. * Sets the input sensibility for a mouse input.
  44208. * Higher values reduce sensitivity.
  44209. */
  44210. set angularSensibility(value: number);
  44211. /**
  44212. * Get the keys for camera movement forward.
  44213. */
  44214. get keysForward(): number[];
  44215. /**
  44216. * Set the keys for camera movement forward.
  44217. */
  44218. set keysForward(value: number[]);
  44219. /**
  44220. * Get the keys for camera movement backward.
  44221. */
  44222. get keysBackward(): number[];
  44223. set keysBackward(value: number[]);
  44224. /**
  44225. * Get the keys for camera movement up.
  44226. */
  44227. get keysUp(): number[];
  44228. /**
  44229. * Set the keys for camera movement up.
  44230. */
  44231. set keysUp(value: number[]);
  44232. /**
  44233. * Get the keys for camera movement down.
  44234. */
  44235. get keysDown(): number[];
  44236. /**
  44237. * Set the keys for camera movement down.
  44238. */
  44239. set keysDown(value: number[]);
  44240. /**
  44241. * Get the keys for camera movement left.
  44242. */
  44243. get keysLeft(): number[];
  44244. /**
  44245. * Set the keys for camera movement left.
  44246. */
  44247. set keysLeft(value: number[]);
  44248. /**
  44249. * Set the keys for camera movement right.
  44250. */
  44251. get keysRight(): number[];
  44252. /**
  44253. * Set the keys for camera movement right.
  44254. */
  44255. set keysRight(value: number[]);
  44256. /**
  44257. * Event raised when the camera collides with a mesh in the scene.
  44258. */
  44259. onCollide: (collidedMesh: AbstractMesh) => void;
  44260. private _collider;
  44261. private _needMoveForGravity;
  44262. private _oldPosition;
  44263. private _diffPosition;
  44264. private _newPosition;
  44265. /** @hidden */
  44266. _localDirection: Vector3;
  44267. /** @hidden */
  44268. _transformedDirection: Vector3;
  44269. /**
  44270. * Instantiates a FlyCamera.
  44271. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44272. * such as in a 3D Space Shooter or a Flight Simulator.
  44273. * @param name Define the name of the camera in the scene.
  44274. * @param position Define the starting position of the camera in the scene.
  44275. * @param scene Define the scene the camera belongs to.
  44276. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44277. */
  44278. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44279. /**
  44280. * Attach a control to the HTML DOM element.
  44281. * @param element Defines the element that listens to the input events.
  44282. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44283. */
  44284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44285. /**
  44286. * Detach a control from the HTML DOM element.
  44287. * The camera will stop reacting to that input.
  44288. * @param element Defines the element that listens to the input events.
  44289. */
  44290. detachControl(element: HTMLElement): void;
  44291. private _collisionMask;
  44292. /**
  44293. * Get the mask that the camera ignores in collision events.
  44294. */
  44295. get collisionMask(): number;
  44296. /**
  44297. * Set the mask that the camera ignores in collision events.
  44298. */
  44299. set collisionMask(mask: number);
  44300. /** @hidden */
  44301. _collideWithWorld(displacement: Vector3): void;
  44302. /** @hidden */
  44303. private _onCollisionPositionChange;
  44304. /** @hidden */
  44305. _checkInputs(): void;
  44306. /** @hidden */
  44307. _decideIfNeedsToMove(): boolean;
  44308. /** @hidden */
  44309. _updatePosition(): void;
  44310. /**
  44311. * Restore the Roll to its target value at the rate specified.
  44312. * @param rate - Higher means slower restoring.
  44313. * @hidden
  44314. */
  44315. restoreRoll(rate: number): void;
  44316. /**
  44317. * Destroy the camera and release the current resources held by it.
  44318. */
  44319. dispose(): void;
  44320. /**
  44321. * Get the current object class name.
  44322. * @returns the class name.
  44323. */
  44324. getClassName(): string;
  44325. }
  44326. }
  44327. declare module BABYLON {
  44328. /**
  44329. * Listen to keyboard events to control the camera.
  44330. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44331. */
  44332. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44333. /**
  44334. * Defines the camera the input is attached to.
  44335. */
  44336. camera: FlyCamera;
  44337. /**
  44338. * The list of keyboard keys used to control the forward move of the camera.
  44339. */
  44340. keysForward: number[];
  44341. /**
  44342. * The list of keyboard keys used to control the backward move of the camera.
  44343. */
  44344. keysBackward: number[];
  44345. /**
  44346. * The list of keyboard keys used to control the forward move of the camera.
  44347. */
  44348. keysUp: number[];
  44349. /**
  44350. * The list of keyboard keys used to control the backward move of the camera.
  44351. */
  44352. keysDown: number[];
  44353. /**
  44354. * The list of keyboard keys used to control the right strafe move of the camera.
  44355. */
  44356. keysRight: number[];
  44357. /**
  44358. * The list of keyboard keys used to control the left strafe move of the camera.
  44359. */
  44360. keysLeft: number[];
  44361. private _keys;
  44362. private _onCanvasBlurObserver;
  44363. private _onKeyboardObserver;
  44364. private _engine;
  44365. private _scene;
  44366. /**
  44367. * Attach the input controls to a specific dom element to get the input from.
  44368. * @param element Defines the element the controls should be listened from
  44369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44370. */
  44371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44372. /**
  44373. * Detach the current controls from the specified dom element.
  44374. * @param element Defines the element to stop listening the inputs from
  44375. */
  44376. detachControl(element: Nullable<HTMLElement>): void;
  44377. /**
  44378. * Gets the class name of the current intput.
  44379. * @returns the class name
  44380. */
  44381. getClassName(): string;
  44382. /** @hidden */
  44383. _onLostFocus(e: FocusEvent): void;
  44384. /**
  44385. * Get the friendly name associated with the input class.
  44386. * @returns the input friendly name
  44387. */
  44388. getSimpleName(): string;
  44389. /**
  44390. * Update the current camera state depending on the inputs that have been used this frame.
  44391. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44392. */
  44393. checkInputs(): void;
  44394. }
  44395. }
  44396. declare module BABYLON {
  44397. /**
  44398. * Manage the mouse wheel inputs to control a follow camera.
  44399. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44400. */
  44401. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44402. /**
  44403. * Defines the camera the input is attached to.
  44404. */
  44405. camera: FollowCamera;
  44406. /**
  44407. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44408. */
  44409. axisControlRadius: boolean;
  44410. /**
  44411. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44412. */
  44413. axisControlHeight: boolean;
  44414. /**
  44415. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44416. */
  44417. axisControlRotation: boolean;
  44418. /**
  44419. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44420. * relation to mouseWheel events.
  44421. */
  44422. wheelPrecision: number;
  44423. /**
  44424. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44425. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44426. */
  44427. wheelDeltaPercentage: number;
  44428. private _wheel;
  44429. private _observer;
  44430. /**
  44431. * Attach the input controls to a specific dom element to get the input from.
  44432. * @param element Defines the element the controls should be listened from
  44433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44434. */
  44435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44436. /**
  44437. * Detach the current controls from the specified dom element.
  44438. * @param element Defines the element to stop listening the inputs from
  44439. */
  44440. detachControl(element: Nullable<HTMLElement>): void;
  44441. /**
  44442. * Gets the class name of the current intput.
  44443. * @returns the class name
  44444. */
  44445. getClassName(): string;
  44446. /**
  44447. * Get the friendly name associated with the input class.
  44448. * @returns the input friendly name
  44449. */
  44450. getSimpleName(): string;
  44451. }
  44452. }
  44453. declare module BABYLON {
  44454. /**
  44455. * Manage the pointers inputs to control an follow camera.
  44456. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44457. */
  44458. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44459. /**
  44460. * Defines the camera the input is attached to.
  44461. */
  44462. camera: FollowCamera;
  44463. /**
  44464. * Gets the class name of the current input.
  44465. * @returns the class name
  44466. */
  44467. getClassName(): string;
  44468. /**
  44469. * Defines the pointer angular sensibility along the X axis or how fast is
  44470. * the camera rotating.
  44471. * A negative number will reverse the axis direction.
  44472. */
  44473. angularSensibilityX: number;
  44474. /**
  44475. * Defines the pointer angular sensibility along the Y axis or how fast is
  44476. * the camera rotating.
  44477. * A negative number will reverse the axis direction.
  44478. */
  44479. angularSensibilityY: number;
  44480. /**
  44481. * Defines the pointer pinch precision or how fast is the camera zooming.
  44482. * A negative number will reverse the axis direction.
  44483. */
  44484. pinchPrecision: number;
  44485. /**
  44486. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44487. * from 0.
  44488. * It defines the percentage of current camera.radius to use as delta when
  44489. * pinch zoom is used.
  44490. */
  44491. pinchDeltaPercentage: number;
  44492. /**
  44493. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44494. */
  44495. axisXControlRadius: boolean;
  44496. /**
  44497. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44498. */
  44499. axisXControlHeight: boolean;
  44500. /**
  44501. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44502. */
  44503. axisXControlRotation: boolean;
  44504. /**
  44505. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44506. */
  44507. axisYControlRadius: boolean;
  44508. /**
  44509. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44510. */
  44511. axisYControlHeight: boolean;
  44512. /**
  44513. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44514. */
  44515. axisYControlRotation: boolean;
  44516. /**
  44517. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44518. */
  44519. axisPinchControlRadius: boolean;
  44520. /**
  44521. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44522. */
  44523. axisPinchControlHeight: boolean;
  44524. /**
  44525. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44526. */
  44527. axisPinchControlRotation: boolean;
  44528. /**
  44529. * Log error messages if basic misconfiguration has occurred.
  44530. */
  44531. warningEnable: boolean;
  44532. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44533. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44534. private _warningCounter;
  44535. private _warning;
  44536. }
  44537. }
  44538. declare module BABYLON {
  44539. /**
  44540. * Default Inputs manager for the FollowCamera.
  44541. * It groups all the default supported inputs for ease of use.
  44542. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44543. */
  44544. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44545. /**
  44546. * Instantiates a new FollowCameraInputsManager.
  44547. * @param camera Defines the camera the inputs belong to
  44548. */
  44549. constructor(camera: FollowCamera);
  44550. /**
  44551. * Add keyboard input support to the input manager.
  44552. * @returns the current input manager
  44553. */
  44554. addKeyboard(): FollowCameraInputsManager;
  44555. /**
  44556. * Add mouse wheel input support to the input manager.
  44557. * @returns the current input manager
  44558. */
  44559. addMouseWheel(): FollowCameraInputsManager;
  44560. /**
  44561. * Add pointers input support to the input manager.
  44562. * @returns the current input manager
  44563. */
  44564. addPointers(): FollowCameraInputsManager;
  44565. /**
  44566. * Add orientation input support to the input manager.
  44567. * @returns the current input manager
  44568. */
  44569. addVRDeviceOrientation(): FollowCameraInputsManager;
  44570. }
  44571. }
  44572. declare module BABYLON {
  44573. /**
  44574. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44575. * an arc rotate version arcFollowCamera are available.
  44576. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44577. */
  44578. export class FollowCamera extends TargetCamera {
  44579. /**
  44580. * Distance the follow camera should follow an object at
  44581. */
  44582. radius: number;
  44583. /**
  44584. * Minimum allowed distance of the camera to the axis of rotation
  44585. * (The camera can not get closer).
  44586. * This can help limiting how the Camera is able to move in the scene.
  44587. */
  44588. lowerRadiusLimit: Nullable<number>;
  44589. /**
  44590. * Maximum allowed distance of the camera to the axis of rotation
  44591. * (The camera can not get further).
  44592. * This can help limiting how the Camera is able to move in the scene.
  44593. */
  44594. upperRadiusLimit: Nullable<number>;
  44595. /**
  44596. * Define a rotation offset between the camera and the object it follows
  44597. */
  44598. rotationOffset: number;
  44599. /**
  44600. * Minimum allowed angle to camera position relative to target object.
  44601. * This can help limiting how the Camera is able to move in the scene.
  44602. */
  44603. lowerRotationOffsetLimit: Nullable<number>;
  44604. /**
  44605. * Maximum allowed angle to camera position relative to target object.
  44606. * This can help limiting how the Camera is able to move in the scene.
  44607. */
  44608. upperRotationOffsetLimit: Nullable<number>;
  44609. /**
  44610. * Define a height offset between the camera and the object it follows.
  44611. * It can help following an object from the top (like a car chaing a plane)
  44612. */
  44613. heightOffset: number;
  44614. /**
  44615. * Minimum allowed height of camera position relative to target object.
  44616. * This can help limiting how the Camera is able to move in the scene.
  44617. */
  44618. lowerHeightOffsetLimit: Nullable<number>;
  44619. /**
  44620. * Maximum allowed height of camera position relative to target object.
  44621. * This can help limiting how the Camera is able to move in the scene.
  44622. */
  44623. upperHeightOffsetLimit: Nullable<number>;
  44624. /**
  44625. * Define how fast the camera can accelerate to follow it s target.
  44626. */
  44627. cameraAcceleration: number;
  44628. /**
  44629. * Define the speed limit of the camera following an object.
  44630. */
  44631. maxCameraSpeed: number;
  44632. /**
  44633. * Define the target of the camera.
  44634. */
  44635. lockedTarget: Nullable<AbstractMesh>;
  44636. /**
  44637. * Defines the input associated with the camera.
  44638. */
  44639. inputs: FollowCameraInputsManager;
  44640. /**
  44641. * Instantiates the follow camera.
  44642. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44643. * @param name Define the name of the camera in the scene
  44644. * @param position Define the position of the camera
  44645. * @param scene Define the scene the camera belong to
  44646. * @param lockedTarget Define the target of the camera
  44647. */
  44648. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44649. private _follow;
  44650. /**
  44651. * Attached controls to the current camera.
  44652. * @param element Defines the element the controls should be listened from
  44653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44654. */
  44655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44656. /**
  44657. * Detach the current controls from the camera.
  44658. * The camera will stop reacting to inputs.
  44659. * @param element Defines the element to stop listening the inputs from
  44660. */
  44661. detachControl(element: HTMLElement): void;
  44662. /** @hidden */
  44663. _checkInputs(): void;
  44664. private _checkLimits;
  44665. /**
  44666. * Gets the camera class name.
  44667. * @returns the class name
  44668. */
  44669. getClassName(): string;
  44670. }
  44671. /**
  44672. * Arc Rotate version of the follow camera.
  44673. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44674. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44675. */
  44676. export class ArcFollowCamera extends TargetCamera {
  44677. /** The longitudinal angle of the camera */
  44678. alpha: number;
  44679. /** The latitudinal angle of the camera */
  44680. beta: number;
  44681. /** The radius of the camera from its target */
  44682. radius: number;
  44683. private _cartesianCoordinates;
  44684. /** Define the camera target (the mesh it should follow) */
  44685. private _meshTarget;
  44686. /**
  44687. * Instantiates a new ArcFollowCamera
  44688. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44689. * @param name Define the name of the camera
  44690. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44691. * @param beta Define the rotation angle of the camera around the elevation axis
  44692. * @param radius Define the radius of the camera from its target point
  44693. * @param target Define the target of the camera
  44694. * @param scene Define the scene the camera belongs to
  44695. */
  44696. constructor(name: string,
  44697. /** The longitudinal angle of the camera */
  44698. alpha: number,
  44699. /** The latitudinal angle of the camera */
  44700. beta: number,
  44701. /** The radius of the camera from its target */
  44702. radius: number,
  44703. /** Define the camera target (the mesh it should follow) */
  44704. target: Nullable<AbstractMesh>, scene: Scene);
  44705. private _follow;
  44706. /** @hidden */
  44707. _checkInputs(): void;
  44708. /**
  44709. * Returns the class name of the object.
  44710. * It is mostly used internally for serialization purposes.
  44711. */
  44712. getClassName(): string;
  44713. }
  44714. }
  44715. declare module BABYLON {
  44716. /**
  44717. * Manage the keyboard inputs to control the movement of a follow camera.
  44718. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44719. */
  44720. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44721. /**
  44722. * Defines the camera the input is attached to.
  44723. */
  44724. camera: FollowCamera;
  44725. /**
  44726. * Defines the list of key codes associated with the up action (increase heightOffset)
  44727. */
  44728. keysHeightOffsetIncr: number[];
  44729. /**
  44730. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44731. */
  44732. keysHeightOffsetDecr: number[];
  44733. /**
  44734. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44735. */
  44736. keysHeightOffsetModifierAlt: boolean;
  44737. /**
  44738. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44739. */
  44740. keysHeightOffsetModifierCtrl: boolean;
  44741. /**
  44742. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44743. */
  44744. keysHeightOffsetModifierShift: boolean;
  44745. /**
  44746. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44747. */
  44748. keysRotationOffsetIncr: number[];
  44749. /**
  44750. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44751. */
  44752. keysRotationOffsetDecr: number[];
  44753. /**
  44754. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44755. */
  44756. keysRotationOffsetModifierAlt: boolean;
  44757. /**
  44758. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44759. */
  44760. keysRotationOffsetModifierCtrl: boolean;
  44761. /**
  44762. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44763. */
  44764. keysRotationOffsetModifierShift: boolean;
  44765. /**
  44766. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44767. */
  44768. keysRadiusIncr: number[];
  44769. /**
  44770. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44771. */
  44772. keysRadiusDecr: number[];
  44773. /**
  44774. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44775. */
  44776. keysRadiusModifierAlt: boolean;
  44777. /**
  44778. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44779. */
  44780. keysRadiusModifierCtrl: boolean;
  44781. /**
  44782. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44783. */
  44784. keysRadiusModifierShift: boolean;
  44785. /**
  44786. * Defines the rate of change of heightOffset.
  44787. */
  44788. heightSensibility: number;
  44789. /**
  44790. * Defines the rate of change of rotationOffset.
  44791. */
  44792. rotationSensibility: number;
  44793. /**
  44794. * Defines the rate of change of radius.
  44795. */
  44796. radiusSensibility: number;
  44797. private _keys;
  44798. private _ctrlPressed;
  44799. private _altPressed;
  44800. private _shiftPressed;
  44801. private _onCanvasBlurObserver;
  44802. private _onKeyboardObserver;
  44803. private _engine;
  44804. private _scene;
  44805. /**
  44806. * Attach the input controls to a specific dom element to get the input from.
  44807. * @param element Defines the element the controls should be listened from
  44808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44809. */
  44810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44811. /**
  44812. * Detach the current controls from the specified dom element.
  44813. * @param element Defines the element to stop listening the inputs from
  44814. */
  44815. detachControl(element: Nullable<HTMLElement>): void;
  44816. /**
  44817. * Update the current camera state depending on the inputs that have been used this frame.
  44818. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44819. */
  44820. checkInputs(): void;
  44821. /**
  44822. * Gets the class name of the current input.
  44823. * @returns the class name
  44824. */
  44825. getClassName(): string;
  44826. /**
  44827. * Get the friendly name associated with the input class.
  44828. * @returns the input friendly name
  44829. */
  44830. getSimpleName(): string;
  44831. /**
  44832. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44833. * allow modification of the heightOffset value.
  44834. */
  44835. private _modifierHeightOffset;
  44836. /**
  44837. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44838. * allow modification of the rotationOffset value.
  44839. */
  44840. private _modifierRotationOffset;
  44841. /**
  44842. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44843. * allow modification of the radius value.
  44844. */
  44845. private _modifierRadius;
  44846. }
  44847. }
  44848. declare module BABYLON {
  44849. interface FreeCameraInputsManager {
  44850. /**
  44851. * @hidden
  44852. */
  44853. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44854. /**
  44855. * Add orientation input support to the input manager.
  44856. * @returns the current input manager
  44857. */
  44858. addDeviceOrientation(): FreeCameraInputsManager;
  44859. }
  44860. /**
  44861. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44862. * Screen rotation is taken into account.
  44863. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44864. */
  44865. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44866. private _camera;
  44867. private _screenOrientationAngle;
  44868. private _constantTranform;
  44869. private _screenQuaternion;
  44870. private _alpha;
  44871. private _beta;
  44872. private _gamma;
  44873. /**
  44874. * Can be used to detect if a device orientation sensor is available on a device
  44875. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44876. * @returns a promise that will resolve on orientation change
  44877. */
  44878. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44879. /**
  44880. * @hidden
  44881. */
  44882. _onDeviceOrientationChangedObservable: Observable<void>;
  44883. /**
  44884. * Instantiates a new input
  44885. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44886. */
  44887. constructor();
  44888. /**
  44889. * Define the camera controlled by the input.
  44890. */
  44891. get camera(): FreeCamera;
  44892. set camera(camera: FreeCamera);
  44893. /**
  44894. * Attach the input controls to a specific dom element to get the input from.
  44895. * @param element Defines the element the controls should be listened from
  44896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44897. */
  44898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44899. private _orientationChanged;
  44900. private _deviceOrientation;
  44901. /**
  44902. * Detach the current controls from the specified dom element.
  44903. * @param element Defines the element to stop listening the inputs from
  44904. */
  44905. detachControl(element: Nullable<HTMLElement>): void;
  44906. /**
  44907. * Update the current camera state depending on the inputs that have been used this frame.
  44908. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44909. */
  44910. checkInputs(): void;
  44911. /**
  44912. * Gets the class name of the current intput.
  44913. * @returns the class name
  44914. */
  44915. getClassName(): string;
  44916. /**
  44917. * Get the friendly name associated with the input class.
  44918. * @returns the input friendly name
  44919. */
  44920. getSimpleName(): string;
  44921. }
  44922. }
  44923. declare module BABYLON {
  44924. /**
  44925. * Manage the gamepad inputs to control a free camera.
  44926. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44927. */
  44928. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44929. /**
  44930. * Define the camera the input is attached to.
  44931. */
  44932. camera: FreeCamera;
  44933. /**
  44934. * Define the Gamepad controlling the input
  44935. */
  44936. gamepad: Nullable<Gamepad>;
  44937. /**
  44938. * Defines the gamepad rotation sensiblity.
  44939. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44940. */
  44941. gamepadAngularSensibility: number;
  44942. /**
  44943. * Defines the gamepad move sensiblity.
  44944. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44945. */
  44946. gamepadMoveSensibility: number;
  44947. private _yAxisScale;
  44948. /**
  44949. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44950. */
  44951. get invertYAxis(): boolean;
  44952. set invertYAxis(value: boolean);
  44953. private _onGamepadConnectedObserver;
  44954. private _onGamepadDisconnectedObserver;
  44955. private _cameraTransform;
  44956. private _deltaTransform;
  44957. private _vector3;
  44958. private _vector2;
  44959. /**
  44960. * Attach the input controls to a specific dom element to get the input from.
  44961. * @param element Defines the element the controls should be listened from
  44962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44963. */
  44964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44965. /**
  44966. * Detach the current controls from the specified dom element.
  44967. * @param element Defines the element to stop listening the inputs from
  44968. */
  44969. detachControl(element: Nullable<HTMLElement>): void;
  44970. /**
  44971. * Update the current camera state depending on the inputs that have been used this frame.
  44972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44973. */
  44974. checkInputs(): void;
  44975. /**
  44976. * Gets the class name of the current intput.
  44977. * @returns the class name
  44978. */
  44979. getClassName(): string;
  44980. /**
  44981. * Get the friendly name associated with the input class.
  44982. * @returns the input friendly name
  44983. */
  44984. getSimpleName(): string;
  44985. }
  44986. }
  44987. declare module BABYLON {
  44988. /**
  44989. * Defines the potential axis of a Joystick
  44990. */
  44991. export enum JoystickAxis {
  44992. /** X axis */
  44993. X = 0,
  44994. /** Y axis */
  44995. Y = 1,
  44996. /** Z axis */
  44997. Z = 2
  44998. }
  44999. /**
  45000. * Represents the different customization options available
  45001. * for VirtualJoystick
  45002. */
  45003. interface VirtualJoystickCustomizations {
  45004. /**
  45005. * Size of the joystick's puck
  45006. */
  45007. puckSize: number;
  45008. /**
  45009. * Size of the joystick's container
  45010. */
  45011. containerSize: number;
  45012. /**
  45013. * Color of the joystick && puck
  45014. */
  45015. color: string;
  45016. /**
  45017. * Image URL for the joystick's puck
  45018. */
  45019. puckImage?: string;
  45020. /**
  45021. * Image URL for the joystick's container
  45022. */
  45023. containerImage?: string;
  45024. /**
  45025. * Defines the unmoving position of the joystick container
  45026. */
  45027. position?: {
  45028. x: number;
  45029. y: number;
  45030. };
  45031. /**
  45032. * Defines whether or not the joystick container is always visible
  45033. */
  45034. alwaysVisible: boolean;
  45035. /**
  45036. * Defines whether or not to limit the movement of the puck to the joystick's container
  45037. */
  45038. limitToContainer: boolean;
  45039. }
  45040. /**
  45041. * Class used to define virtual joystick (used in touch mode)
  45042. */
  45043. export class VirtualJoystick {
  45044. /**
  45045. * Gets or sets a boolean indicating that left and right values must be inverted
  45046. */
  45047. reverseLeftRight: boolean;
  45048. /**
  45049. * Gets or sets a boolean indicating that up and down values must be inverted
  45050. */
  45051. reverseUpDown: boolean;
  45052. /**
  45053. * Gets the offset value for the position (ie. the change of the position value)
  45054. */
  45055. deltaPosition: Vector3;
  45056. /**
  45057. * Gets a boolean indicating if the virtual joystick was pressed
  45058. */
  45059. pressed: boolean;
  45060. /**
  45061. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45062. */
  45063. static Canvas: Nullable<HTMLCanvasElement>;
  45064. /**
  45065. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45066. */
  45067. limitToContainer: boolean;
  45068. private static _globalJoystickIndex;
  45069. private static _alwaysVisibleSticks;
  45070. private static vjCanvasContext;
  45071. private static vjCanvasWidth;
  45072. private static vjCanvasHeight;
  45073. private static halfWidth;
  45074. private static _GetDefaultOptions;
  45075. private _action;
  45076. private _axisTargetedByLeftAndRight;
  45077. private _axisTargetedByUpAndDown;
  45078. private _joystickSensibility;
  45079. private _inversedSensibility;
  45080. private _joystickPointerID;
  45081. private _joystickColor;
  45082. private _joystickPointerPos;
  45083. private _joystickPreviousPointerPos;
  45084. private _joystickPointerStartPos;
  45085. private _deltaJoystickVector;
  45086. private _leftJoystick;
  45087. private _touches;
  45088. private _joystickPosition;
  45089. private _alwaysVisible;
  45090. private _puckImage;
  45091. private _containerImage;
  45092. private _joystickPuckSize;
  45093. private _joystickContainerSize;
  45094. private _clearPuckSize;
  45095. private _clearContainerSize;
  45096. private _clearPuckSizeOffset;
  45097. private _clearContainerSizeOffset;
  45098. private _onPointerDownHandlerRef;
  45099. private _onPointerMoveHandlerRef;
  45100. private _onPointerUpHandlerRef;
  45101. private _onResize;
  45102. /**
  45103. * Creates a new virtual joystick
  45104. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45105. * @param customizations Defines the options we want to customize the VirtualJoystick
  45106. */
  45107. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45108. /**
  45109. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45110. * @param newJoystickSensibility defines the new sensibility
  45111. */
  45112. setJoystickSensibility(newJoystickSensibility: number): void;
  45113. private _onPointerDown;
  45114. private _onPointerMove;
  45115. private _onPointerUp;
  45116. /**
  45117. * Change the color of the virtual joystick
  45118. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45119. */
  45120. setJoystickColor(newColor: string): void;
  45121. /**
  45122. * Size of the joystick's container
  45123. */
  45124. set containerSize(newSize: number);
  45125. get containerSize(): number;
  45126. /**
  45127. * Size of the joystick's puck
  45128. */
  45129. set puckSize(newSize: number);
  45130. get puckSize(): number;
  45131. /**
  45132. * Clears the set position of the joystick
  45133. */
  45134. clearPosition(): void;
  45135. /**
  45136. * Defines whether or not the joystick container is always visible
  45137. */
  45138. set alwaysVisible(value: boolean);
  45139. get alwaysVisible(): boolean;
  45140. /**
  45141. * Sets the constant position of the Joystick container
  45142. * @param x X axis coordinate
  45143. * @param y Y axis coordinate
  45144. */
  45145. setPosition(x: number, y: number): void;
  45146. /**
  45147. * Defines a callback to call when the joystick is touched
  45148. * @param action defines the callback
  45149. */
  45150. setActionOnTouch(action: () => any): void;
  45151. /**
  45152. * Defines which axis you'd like to control for left & right
  45153. * @param axis defines the axis to use
  45154. */
  45155. setAxisForLeftRight(axis: JoystickAxis): void;
  45156. /**
  45157. * Defines which axis you'd like to control for up & down
  45158. * @param axis defines the axis to use
  45159. */
  45160. setAxisForUpDown(axis: JoystickAxis): void;
  45161. /**
  45162. * Clears the canvas from the previous puck / container draw
  45163. */
  45164. private _clearPreviousDraw;
  45165. /**
  45166. * Loads `urlPath` to be used for the container's image
  45167. * @param urlPath defines the urlPath of an image to use
  45168. */
  45169. setContainerImage(urlPath: string): void;
  45170. /**
  45171. * Loads `urlPath` to be used for the puck's image
  45172. * @param urlPath defines the urlPath of an image to use
  45173. */
  45174. setPuckImage(urlPath: string): void;
  45175. /**
  45176. * Draws the Virtual Joystick's container
  45177. */
  45178. private _drawContainer;
  45179. /**
  45180. * Draws the Virtual Joystick's puck
  45181. */
  45182. private _drawPuck;
  45183. private _drawVirtualJoystick;
  45184. /**
  45185. * Release internal HTML canvas
  45186. */
  45187. releaseCanvas(): void;
  45188. }
  45189. }
  45190. declare module BABYLON {
  45191. interface FreeCameraInputsManager {
  45192. /**
  45193. * Add virtual joystick input support to the input manager.
  45194. * @returns the current input manager
  45195. */
  45196. addVirtualJoystick(): FreeCameraInputsManager;
  45197. }
  45198. /**
  45199. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45200. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45201. */
  45202. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45203. /**
  45204. * Defines the camera the input is attached to.
  45205. */
  45206. camera: FreeCamera;
  45207. private _leftjoystick;
  45208. private _rightjoystick;
  45209. /**
  45210. * Gets the left stick of the virtual joystick.
  45211. * @returns The virtual Joystick
  45212. */
  45213. getLeftJoystick(): VirtualJoystick;
  45214. /**
  45215. * Gets the right stick of the virtual joystick.
  45216. * @returns The virtual Joystick
  45217. */
  45218. getRightJoystick(): VirtualJoystick;
  45219. /**
  45220. * Update the current camera state depending on the inputs that have been used this frame.
  45221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45222. */
  45223. checkInputs(): void;
  45224. /**
  45225. * Attach the input controls to a specific dom element to get the input from.
  45226. * @param element Defines the element the controls should be listened from
  45227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45228. */
  45229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45230. /**
  45231. * Detach the current controls from the specified dom element.
  45232. * @param element Defines the element to stop listening the inputs from
  45233. */
  45234. detachControl(element: Nullable<HTMLElement>): void;
  45235. /**
  45236. * Gets the class name of the current intput.
  45237. * @returns the class name
  45238. */
  45239. getClassName(): string;
  45240. /**
  45241. * Get the friendly name associated with the input class.
  45242. * @returns the input friendly name
  45243. */
  45244. getSimpleName(): string;
  45245. }
  45246. }
  45247. declare module BABYLON {
  45248. /**
  45249. * This represents a FPS type of camera controlled by touch.
  45250. * This is like a universal camera minus the Gamepad controls.
  45251. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45252. */
  45253. export class TouchCamera extends FreeCamera {
  45254. /**
  45255. * Defines the touch sensibility for rotation.
  45256. * The higher the faster.
  45257. */
  45258. get touchAngularSensibility(): number;
  45259. set touchAngularSensibility(value: number);
  45260. /**
  45261. * Defines the touch sensibility for move.
  45262. * The higher the faster.
  45263. */
  45264. get touchMoveSensibility(): number;
  45265. set touchMoveSensibility(value: number);
  45266. /**
  45267. * Instantiates a new touch camera.
  45268. * This represents a FPS type of camera controlled by touch.
  45269. * This is like a universal camera minus the Gamepad controls.
  45270. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45271. * @param name Define the name of the camera in the scene
  45272. * @param position Define the start position of the camera in the scene
  45273. * @param scene Define the scene the camera belongs to
  45274. */
  45275. constructor(name: string, position: Vector3, scene: Scene);
  45276. /**
  45277. * Gets the current object class name.
  45278. * @return the class name
  45279. */
  45280. getClassName(): string;
  45281. /** @hidden */
  45282. _setupInputs(): void;
  45283. }
  45284. }
  45285. declare module BABYLON {
  45286. /**
  45287. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45288. * being tilted forward or back and left or right.
  45289. */
  45290. export class DeviceOrientationCamera extends FreeCamera {
  45291. private _initialQuaternion;
  45292. private _quaternionCache;
  45293. private _tmpDragQuaternion;
  45294. private _disablePointerInputWhenUsingDeviceOrientation;
  45295. /**
  45296. * Creates a new device orientation camera
  45297. * @param name The name of the camera
  45298. * @param position The start position camera
  45299. * @param scene The scene the camera belongs to
  45300. */
  45301. constructor(name: string, position: Vector3, scene: Scene);
  45302. /**
  45303. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45304. */
  45305. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45306. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45307. private _dragFactor;
  45308. /**
  45309. * Enabled turning on the y axis when the orientation sensor is active
  45310. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45311. */
  45312. enableHorizontalDragging(dragFactor?: number): void;
  45313. /**
  45314. * Gets the current instance class name ("DeviceOrientationCamera").
  45315. * This helps avoiding instanceof at run time.
  45316. * @returns the class name
  45317. */
  45318. getClassName(): string;
  45319. /**
  45320. * @hidden
  45321. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45322. */
  45323. _checkInputs(): void;
  45324. /**
  45325. * Reset the camera to its default orientation on the specified axis only.
  45326. * @param axis The axis to reset
  45327. */
  45328. resetToCurrentRotation(axis?: Axis): void;
  45329. }
  45330. }
  45331. declare module BABYLON {
  45332. /**
  45333. * Defines supported buttons for XBox360 compatible gamepads
  45334. */
  45335. export enum Xbox360Button {
  45336. /** A */
  45337. A = 0,
  45338. /** B */
  45339. B = 1,
  45340. /** X */
  45341. X = 2,
  45342. /** Y */
  45343. Y = 3,
  45344. /** Left button */
  45345. LB = 4,
  45346. /** Right button */
  45347. RB = 5,
  45348. /** Back */
  45349. Back = 8,
  45350. /** Start */
  45351. Start = 9,
  45352. /** Left stick */
  45353. LeftStick = 10,
  45354. /** Right stick */
  45355. RightStick = 11
  45356. }
  45357. /** Defines values for XBox360 DPad */
  45358. export enum Xbox360Dpad {
  45359. /** Up */
  45360. Up = 12,
  45361. /** Down */
  45362. Down = 13,
  45363. /** Left */
  45364. Left = 14,
  45365. /** Right */
  45366. Right = 15
  45367. }
  45368. /**
  45369. * Defines a XBox360 gamepad
  45370. */
  45371. export class Xbox360Pad extends Gamepad {
  45372. private _leftTrigger;
  45373. private _rightTrigger;
  45374. private _onlefttriggerchanged;
  45375. private _onrighttriggerchanged;
  45376. private _onbuttondown;
  45377. private _onbuttonup;
  45378. private _ondpaddown;
  45379. private _ondpadup;
  45380. /** Observable raised when a button is pressed */
  45381. onButtonDownObservable: Observable<Xbox360Button>;
  45382. /** Observable raised when a button is released */
  45383. onButtonUpObservable: Observable<Xbox360Button>;
  45384. /** Observable raised when a pad is pressed */
  45385. onPadDownObservable: Observable<Xbox360Dpad>;
  45386. /** Observable raised when a pad is released */
  45387. onPadUpObservable: Observable<Xbox360Dpad>;
  45388. private _buttonA;
  45389. private _buttonB;
  45390. private _buttonX;
  45391. private _buttonY;
  45392. private _buttonBack;
  45393. private _buttonStart;
  45394. private _buttonLB;
  45395. private _buttonRB;
  45396. private _buttonLeftStick;
  45397. private _buttonRightStick;
  45398. private _dPadUp;
  45399. private _dPadDown;
  45400. private _dPadLeft;
  45401. private _dPadRight;
  45402. private _isXboxOnePad;
  45403. /**
  45404. * Creates a new XBox360 gamepad object
  45405. * @param id defines the id of this gamepad
  45406. * @param index defines its index
  45407. * @param gamepad defines the internal HTML gamepad object
  45408. * @param xboxOne defines if it is a XBox One gamepad
  45409. */
  45410. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45411. /**
  45412. * Defines the callback to call when left trigger is pressed
  45413. * @param callback defines the callback to use
  45414. */
  45415. onlefttriggerchanged(callback: (value: number) => void): void;
  45416. /**
  45417. * Defines the callback to call when right trigger is pressed
  45418. * @param callback defines the callback to use
  45419. */
  45420. onrighttriggerchanged(callback: (value: number) => void): void;
  45421. /**
  45422. * Gets the left trigger value
  45423. */
  45424. get leftTrigger(): number;
  45425. /**
  45426. * Sets the left trigger value
  45427. */
  45428. set leftTrigger(newValue: number);
  45429. /**
  45430. * Gets the right trigger value
  45431. */
  45432. get rightTrigger(): number;
  45433. /**
  45434. * Sets the right trigger value
  45435. */
  45436. set rightTrigger(newValue: number);
  45437. /**
  45438. * Defines the callback to call when a button is pressed
  45439. * @param callback defines the callback to use
  45440. */
  45441. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45442. /**
  45443. * Defines the callback to call when a button is released
  45444. * @param callback defines the callback to use
  45445. */
  45446. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45447. /**
  45448. * Defines the callback to call when a pad is pressed
  45449. * @param callback defines the callback to use
  45450. */
  45451. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45452. /**
  45453. * Defines the callback to call when a pad is released
  45454. * @param callback defines the callback to use
  45455. */
  45456. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45457. private _setButtonValue;
  45458. private _setDPadValue;
  45459. /**
  45460. * Gets the value of the `A` button
  45461. */
  45462. get buttonA(): number;
  45463. /**
  45464. * Sets the value of the `A` button
  45465. */
  45466. set buttonA(value: number);
  45467. /**
  45468. * Gets the value of the `B` button
  45469. */
  45470. get buttonB(): number;
  45471. /**
  45472. * Sets the value of the `B` button
  45473. */
  45474. set buttonB(value: number);
  45475. /**
  45476. * Gets the value of the `X` button
  45477. */
  45478. get buttonX(): number;
  45479. /**
  45480. * Sets the value of the `X` button
  45481. */
  45482. set buttonX(value: number);
  45483. /**
  45484. * Gets the value of the `Y` button
  45485. */
  45486. get buttonY(): number;
  45487. /**
  45488. * Sets the value of the `Y` button
  45489. */
  45490. set buttonY(value: number);
  45491. /**
  45492. * Gets the value of the `Start` button
  45493. */
  45494. get buttonStart(): number;
  45495. /**
  45496. * Sets the value of the `Start` button
  45497. */
  45498. set buttonStart(value: number);
  45499. /**
  45500. * Gets the value of the `Back` button
  45501. */
  45502. get buttonBack(): number;
  45503. /**
  45504. * Sets the value of the `Back` button
  45505. */
  45506. set buttonBack(value: number);
  45507. /**
  45508. * Gets the value of the `Left` button
  45509. */
  45510. get buttonLB(): number;
  45511. /**
  45512. * Sets the value of the `Left` button
  45513. */
  45514. set buttonLB(value: number);
  45515. /**
  45516. * Gets the value of the `Right` button
  45517. */
  45518. get buttonRB(): number;
  45519. /**
  45520. * Sets the value of the `Right` button
  45521. */
  45522. set buttonRB(value: number);
  45523. /**
  45524. * Gets the value of the Left joystick
  45525. */
  45526. get buttonLeftStick(): number;
  45527. /**
  45528. * Sets the value of the Left joystick
  45529. */
  45530. set buttonLeftStick(value: number);
  45531. /**
  45532. * Gets the value of the Right joystick
  45533. */
  45534. get buttonRightStick(): number;
  45535. /**
  45536. * Sets the value of the Right joystick
  45537. */
  45538. set buttonRightStick(value: number);
  45539. /**
  45540. * Gets the value of D-pad up
  45541. */
  45542. get dPadUp(): number;
  45543. /**
  45544. * Sets the value of D-pad up
  45545. */
  45546. set dPadUp(value: number);
  45547. /**
  45548. * Gets the value of D-pad down
  45549. */
  45550. get dPadDown(): number;
  45551. /**
  45552. * Sets the value of D-pad down
  45553. */
  45554. set dPadDown(value: number);
  45555. /**
  45556. * Gets the value of D-pad left
  45557. */
  45558. get dPadLeft(): number;
  45559. /**
  45560. * Sets the value of D-pad left
  45561. */
  45562. set dPadLeft(value: number);
  45563. /**
  45564. * Gets the value of D-pad right
  45565. */
  45566. get dPadRight(): number;
  45567. /**
  45568. * Sets the value of D-pad right
  45569. */
  45570. set dPadRight(value: number);
  45571. /**
  45572. * Force the gamepad to synchronize with device values
  45573. */
  45574. update(): void;
  45575. /**
  45576. * Disposes the gamepad
  45577. */
  45578. dispose(): void;
  45579. }
  45580. }
  45581. declare module BABYLON {
  45582. /**
  45583. * Defines supported buttons for DualShock compatible gamepads
  45584. */
  45585. export enum DualShockButton {
  45586. /** Cross */
  45587. Cross = 0,
  45588. /** Circle */
  45589. Circle = 1,
  45590. /** Square */
  45591. Square = 2,
  45592. /** Triangle */
  45593. Triangle = 3,
  45594. /** L1 */
  45595. L1 = 4,
  45596. /** R1 */
  45597. R1 = 5,
  45598. /** Share */
  45599. Share = 8,
  45600. /** Options */
  45601. Options = 9,
  45602. /** Left stick */
  45603. LeftStick = 10,
  45604. /** Right stick */
  45605. RightStick = 11
  45606. }
  45607. /** Defines values for DualShock DPad */
  45608. export enum DualShockDpad {
  45609. /** Up */
  45610. Up = 12,
  45611. /** Down */
  45612. Down = 13,
  45613. /** Left */
  45614. Left = 14,
  45615. /** Right */
  45616. Right = 15
  45617. }
  45618. /**
  45619. * Defines a DualShock gamepad
  45620. */
  45621. export class DualShockPad extends Gamepad {
  45622. private _leftTrigger;
  45623. private _rightTrigger;
  45624. private _onlefttriggerchanged;
  45625. private _onrighttriggerchanged;
  45626. private _onbuttondown;
  45627. private _onbuttonup;
  45628. private _ondpaddown;
  45629. private _ondpadup;
  45630. /** Observable raised when a button is pressed */
  45631. onButtonDownObservable: Observable<DualShockButton>;
  45632. /** Observable raised when a button is released */
  45633. onButtonUpObservable: Observable<DualShockButton>;
  45634. /** Observable raised when a pad is pressed */
  45635. onPadDownObservable: Observable<DualShockDpad>;
  45636. /** Observable raised when a pad is released */
  45637. onPadUpObservable: Observable<DualShockDpad>;
  45638. private _buttonCross;
  45639. private _buttonCircle;
  45640. private _buttonSquare;
  45641. private _buttonTriangle;
  45642. private _buttonShare;
  45643. private _buttonOptions;
  45644. private _buttonL1;
  45645. private _buttonR1;
  45646. private _buttonLeftStick;
  45647. private _buttonRightStick;
  45648. private _dPadUp;
  45649. private _dPadDown;
  45650. private _dPadLeft;
  45651. private _dPadRight;
  45652. /**
  45653. * Creates a new DualShock gamepad object
  45654. * @param id defines the id of this gamepad
  45655. * @param index defines its index
  45656. * @param gamepad defines the internal HTML gamepad object
  45657. */
  45658. constructor(id: string, index: number, gamepad: any);
  45659. /**
  45660. * Defines the callback to call when left trigger is pressed
  45661. * @param callback defines the callback to use
  45662. */
  45663. onlefttriggerchanged(callback: (value: number) => void): void;
  45664. /**
  45665. * Defines the callback to call when right trigger is pressed
  45666. * @param callback defines the callback to use
  45667. */
  45668. onrighttriggerchanged(callback: (value: number) => void): void;
  45669. /**
  45670. * Gets the left trigger value
  45671. */
  45672. get leftTrigger(): number;
  45673. /**
  45674. * Sets the left trigger value
  45675. */
  45676. set leftTrigger(newValue: number);
  45677. /**
  45678. * Gets the right trigger value
  45679. */
  45680. get rightTrigger(): number;
  45681. /**
  45682. * Sets the right trigger value
  45683. */
  45684. set rightTrigger(newValue: number);
  45685. /**
  45686. * Defines the callback to call when a button is pressed
  45687. * @param callback defines the callback to use
  45688. */
  45689. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45690. /**
  45691. * Defines the callback to call when a button is released
  45692. * @param callback defines the callback to use
  45693. */
  45694. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45695. /**
  45696. * Defines the callback to call when a pad is pressed
  45697. * @param callback defines the callback to use
  45698. */
  45699. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45700. /**
  45701. * Defines the callback to call when a pad is released
  45702. * @param callback defines the callback to use
  45703. */
  45704. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45705. private _setButtonValue;
  45706. private _setDPadValue;
  45707. /**
  45708. * Gets the value of the `Cross` button
  45709. */
  45710. get buttonCross(): number;
  45711. /**
  45712. * Sets the value of the `Cross` button
  45713. */
  45714. set buttonCross(value: number);
  45715. /**
  45716. * Gets the value of the `Circle` button
  45717. */
  45718. get buttonCircle(): number;
  45719. /**
  45720. * Sets the value of the `Circle` button
  45721. */
  45722. set buttonCircle(value: number);
  45723. /**
  45724. * Gets the value of the `Square` button
  45725. */
  45726. get buttonSquare(): number;
  45727. /**
  45728. * Sets the value of the `Square` button
  45729. */
  45730. set buttonSquare(value: number);
  45731. /**
  45732. * Gets the value of the `Triangle` button
  45733. */
  45734. get buttonTriangle(): number;
  45735. /**
  45736. * Sets the value of the `Triangle` button
  45737. */
  45738. set buttonTriangle(value: number);
  45739. /**
  45740. * Gets the value of the `Options` button
  45741. */
  45742. get buttonOptions(): number;
  45743. /**
  45744. * Sets the value of the `Options` button
  45745. */
  45746. set buttonOptions(value: number);
  45747. /**
  45748. * Gets the value of the `Share` button
  45749. */
  45750. get buttonShare(): number;
  45751. /**
  45752. * Sets the value of the `Share` button
  45753. */
  45754. set buttonShare(value: number);
  45755. /**
  45756. * Gets the value of the `L1` button
  45757. */
  45758. get buttonL1(): number;
  45759. /**
  45760. * Sets the value of the `L1` button
  45761. */
  45762. set buttonL1(value: number);
  45763. /**
  45764. * Gets the value of the `R1` button
  45765. */
  45766. get buttonR1(): number;
  45767. /**
  45768. * Sets the value of the `R1` button
  45769. */
  45770. set buttonR1(value: number);
  45771. /**
  45772. * Gets the value of the Left joystick
  45773. */
  45774. get buttonLeftStick(): number;
  45775. /**
  45776. * Sets the value of the Left joystick
  45777. */
  45778. set buttonLeftStick(value: number);
  45779. /**
  45780. * Gets the value of the Right joystick
  45781. */
  45782. get buttonRightStick(): number;
  45783. /**
  45784. * Sets the value of the Right joystick
  45785. */
  45786. set buttonRightStick(value: number);
  45787. /**
  45788. * Gets the value of D-pad up
  45789. */
  45790. get dPadUp(): number;
  45791. /**
  45792. * Sets the value of D-pad up
  45793. */
  45794. set dPadUp(value: number);
  45795. /**
  45796. * Gets the value of D-pad down
  45797. */
  45798. get dPadDown(): number;
  45799. /**
  45800. * Sets the value of D-pad down
  45801. */
  45802. set dPadDown(value: number);
  45803. /**
  45804. * Gets the value of D-pad left
  45805. */
  45806. get dPadLeft(): number;
  45807. /**
  45808. * Sets the value of D-pad left
  45809. */
  45810. set dPadLeft(value: number);
  45811. /**
  45812. * Gets the value of D-pad right
  45813. */
  45814. get dPadRight(): number;
  45815. /**
  45816. * Sets the value of D-pad right
  45817. */
  45818. set dPadRight(value: number);
  45819. /**
  45820. * Force the gamepad to synchronize with device values
  45821. */
  45822. update(): void;
  45823. /**
  45824. * Disposes the gamepad
  45825. */
  45826. dispose(): void;
  45827. }
  45828. }
  45829. declare module BABYLON {
  45830. /**
  45831. * Manager for handling gamepads
  45832. */
  45833. export class GamepadManager {
  45834. private _scene?;
  45835. private _babylonGamepads;
  45836. private _oneGamepadConnected;
  45837. /** @hidden */
  45838. _isMonitoring: boolean;
  45839. private _gamepadEventSupported;
  45840. private _gamepadSupport?;
  45841. /**
  45842. * observable to be triggered when the gamepad controller has been connected
  45843. */
  45844. onGamepadConnectedObservable: Observable<Gamepad>;
  45845. /**
  45846. * observable to be triggered when the gamepad controller has been disconnected
  45847. */
  45848. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45849. private _onGamepadConnectedEvent;
  45850. private _onGamepadDisconnectedEvent;
  45851. /**
  45852. * Initializes the gamepad manager
  45853. * @param _scene BabylonJS scene
  45854. */
  45855. constructor(_scene?: Scene | undefined);
  45856. /**
  45857. * The gamepads in the game pad manager
  45858. */
  45859. get gamepads(): Gamepad[];
  45860. /**
  45861. * Get the gamepad controllers based on type
  45862. * @param type The type of gamepad controller
  45863. * @returns Nullable gamepad
  45864. */
  45865. getGamepadByType(type?: number): Nullable<Gamepad>;
  45866. /**
  45867. * Disposes the gamepad manager
  45868. */
  45869. dispose(): void;
  45870. private _addNewGamepad;
  45871. private _startMonitoringGamepads;
  45872. private _stopMonitoringGamepads;
  45873. /** @hidden */
  45874. _checkGamepadsStatus(): void;
  45875. private _updateGamepadObjects;
  45876. }
  45877. }
  45878. declare module BABYLON {
  45879. interface Scene {
  45880. /** @hidden */
  45881. _gamepadManager: Nullable<GamepadManager>;
  45882. /**
  45883. * Gets the gamepad manager associated with the scene
  45884. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45885. */
  45886. gamepadManager: GamepadManager;
  45887. }
  45888. /**
  45889. * Interface representing a free camera inputs manager
  45890. */
  45891. interface FreeCameraInputsManager {
  45892. /**
  45893. * Adds gamepad input support to the FreeCameraInputsManager.
  45894. * @returns the FreeCameraInputsManager
  45895. */
  45896. addGamepad(): FreeCameraInputsManager;
  45897. }
  45898. /**
  45899. * Interface representing an arc rotate camera inputs manager
  45900. */
  45901. interface ArcRotateCameraInputsManager {
  45902. /**
  45903. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45904. * @returns the camera inputs manager
  45905. */
  45906. addGamepad(): ArcRotateCameraInputsManager;
  45907. }
  45908. /**
  45909. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45910. */
  45911. export class GamepadSystemSceneComponent implements ISceneComponent {
  45912. /**
  45913. * The component name helpfull to identify the component in the list of scene components.
  45914. */
  45915. readonly name: string;
  45916. /**
  45917. * The scene the component belongs to.
  45918. */
  45919. scene: Scene;
  45920. /**
  45921. * Creates a new instance of the component for the given scene
  45922. * @param scene Defines the scene to register the component in
  45923. */
  45924. constructor(scene: Scene);
  45925. /**
  45926. * Registers the component in a given scene
  45927. */
  45928. register(): void;
  45929. /**
  45930. * Rebuilds the elements related to this component in case of
  45931. * context lost for instance.
  45932. */
  45933. rebuild(): void;
  45934. /**
  45935. * Disposes the component and the associated ressources
  45936. */
  45937. dispose(): void;
  45938. private _beforeCameraUpdate;
  45939. }
  45940. }
  45941. declare module BABYLON {
  45942. /**
  45943. * 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,
  45944. * which still works and will still be found in many Playgrounds.
  45945. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45946. */
  45947. export class UniversalCamera extends TouchCamera {
  45948. /**
  45949. * Defines the gamepad rotation sensiblity.
  45950. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45951. */
  45952. get gamepadAngularSensibility(): number;
  45953. set gamepadAngularSensibility(value: number);
  45954. /**
  45955. * Defines the gamepad move sensiblity.
  45956. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45957. */
  45958. get gamepadMoveSensibility(): number;
  45959. set gamepadMoveSensibility(value: number);
  45960. /**
  45961. * 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,
  45962. * which still works and will still be found in many Playgrounds.
  45963. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45964. * @param name Define the name of the camera in the scene
  45965. * @param position Define the start position of the camera in the scene
  45966. * @param scene Define the scene the camera belongs to
  45967. */
  45968. constructor(name: string, position: Vector3, scene: Scene);
  45969. /**
  45970. * Gets the current object class name.
  45971. * @return the class name
  45972. */
  45973. getClassName(): string;
  45974. }
  45975. }
  45976. declare module BABYLON {
  45977. /**
  45978. * This represents a FPS type of camera. This is only here for back compat purpose.
  45979. * Please use the UniversalCamera instead as both are identical.
  45980. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45981. */
  45982. export class GamepadCamera extends UniversalCamera {
  45983. /**
  45984. * Instantiates a new Gamepad Camera
  45985. * This represents a FPS type of camera. This is only here for back compat purpose.
  45986. * Please use the UniversalCamera instead as both are identical.
  45987. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45988. * @param name Define the name of the camera in the scene
  45989. * @param position Define the start position of the camera in the scene
  45990. * @param scene Define the scene the camera belongs to
  45991. */
  45992. constructor(name: string, position: Vector3, scene: Scene);
  45993. /**
  45994. * Gets the current object class name.
  45995. * @return the class name
  45996. */
  45997. getClassName(): string;
  45998. }
  45999. }
  46000. declare module BABYLON {
  46001. /** @hidden */
  46002. export var passPixelShader: {
  46003. name: string;
  46004. shader: string;
  46005. };
  46006. }
  46007. declare module BABYLON {
  46008. /** @hidden */
  46009. export var passCubePixelShader: {
  46010. name: string;
  46011. shader: string;
  46012. };
  46013. }
  46014. declare module BABYLON {
  46015. /**
  46016. * PassPostProcess which produces an output the same as it's input
  46017. */
  46018. export class PassPostProcess extends PostProcess {
  46019. /**
  46020. * Gets a string identifying the name of the class
  46021. * @returns "PassPostProcess" string
  46022. */
  46023. getClassName(): string;
  46024. /**
  46025. * Creates the PassPostProcess
  46026. * @param name The name of the effect.
  46027. * @param options The required width/height ratio to downsize to before computing the render pass.
  46028. * @param camera The camera to apply the render pass to.
  46029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46030. * @param engine The engine which the post process will be applied. (default: current engine)
  46031. * @param reusable If the post process can be reused on the same frame. (default: false)
  46032. * @param textureType The type of texture to be used when performing the post processing.
  46033. * @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)
  46034. */
  46035. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46036. /** @hidden */
  46037. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46038. }
  46039. /**
  46040. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46041. */
  46042. export class PassCubePostProcess extends PostProcess {
  46043. private _face;
  46044. /**
  46045. * Gets or sets the cube face to display.
  46046. * * 0 is +X
  46047. * * 1 is -X
  46048. * * 2 is +Y
  46049. * * 3 is -Y
  46050. * * 4 is +Z
  46051. * * 5 is -Z
  46052. */
  46053. get face(): number;
  46054. set face(value: number);
  46055. /**
  46056. * Gets a string identifying the name of the class
  46057. * @returns "PassCubePostProcess" string
  46058. */
  46059. getClassName(): string;
  46060. /**
  46061. * Creates the PassCubePostProcess
  46062. * @param name The name of the effect.
  46063. * @param options The required width/height ratio to downsize to before computing the render pass.
  46064. * @param camera The camera to apply the render pass to.
  46065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46066. * @param engine The engine which the post process will be applied. (default: current engine)
  46067. * @param reusable If the post process can be reused on the same frame. (default: false)
  46068. * @param textureType The type of texture to be used when performing the post processing.
  46069. * @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)
  46070. */
  46071. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46072. /** @hidden */
  46073. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46074. }
  46075. }
  46076. declare module BABYLON {
  46077. /** @hidden */
  46078. export var anaglyphPixelShader: {
  46079. name: string;
  46080. shader: string;
  46081. };
  46082. }
  46083. declare module BABYLON {
  46084. /**
  46085. * Postprocess used to generate anaglyphic rendering
  46086. */
  46087. export class AnaglyphPostProcess extends PostProcess {
  46088. private _passedProcess;
  46089. /**
  46090. * Gets a string identifying the name of the class
  46091. * @returns "AnaglyphPostProcess" string
  46092. */
  46093. getClassName(): string;
  46094. /**
  46095. * Creates a new AnaglyphPostProcess
  46096. * @param name defines postprocess name
  46097. * @param options defines creation options or target ratio scale
  46098. * @param rigCameras defines cameras using this postprocess
  46099. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46100. * @param engine defines hosting engine
  46101. * @param reusable defines if the postprocess will be reused multiple times per frame
  46102. */
  46103. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46104. }
  46105. }
  46106. declare module BABYLON {
  46107. /**
  46108. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46109. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46110. */
  46111. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46112. /**
  46113. * Creates a new AnaglyphArcRotateCamera
  46114. * @param name defines camera name
  46115. * @param alpha defines alpha angle (in radians)
  46116. * @param beta defines beta angle (in radians)
  46117. * @param radius defines radius
  46118. * @param target defines camera target
  46119. * @param interaxialDistance defines distance between each color axis
  46120. * @param scene defines the hosting scene
  46121. */
  46122. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46123. /**
  46124. * Gets camera class name
  46125. * @returns AnaglyphArcRotateCamera
  46126. */
  46127. getClassName(): string;
  46128. }
  46129. }
  46130. declare module BABYLON {
  46131. /**
  46132. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46133. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46134. */
  46135. export class AnaglyphFreeCamera extends FreeCamera {
  46136. /**
  46137. * Creates a new AnaglyphFreeCamera
  46138. * @param name defines camera name
  46139. * @param position defines initial position
  46140. * @param interaxialDistance defines distance between each color axis
  46141. * @param scene defines the hosting scene
  46142. */
  46143. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46144. /**
  46145. * Gets camera class name
  46146. * @returns AnaglyphFreeCamera
  46147. */
  46148. getClassName(): string;
  46149. }
  46150. }
  46151. declare module BABYLON {
  46152. /**
  46153. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46154. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46155. */
  46156. export class AnaglyphGamepadCamera extends GamepadCamera {
  46157. /**
  46158. * Creates a new AnaglyphGamepadCamera
  46159. * @param name defines camera name
  46160. * @param position defines initial position
  46161. * @param interaxialDistance defines distance between each color axis
  46162. * @param scene defines the hosting scene
  46163. */
  46164. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46165. /**
  46166. * Gets camera class name
  46167. * @returns AnaglyphGamepadCamera
  46168. */
  46169. getClassName(): string;
  46170. }
  46171. }
  46172. declare module BABYLON {
  46173. /**
  46174. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46175. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46176. */
  46177. export class AnaglyphUniversalCamera extends UniversalCamera {
  46178. /**
  46179. * Creates a new AnaglyphUniversalCamera
  46180. * @param name defines camera name
  46181. * @param position defines initial position
  46182. * @param interaxialDistance defines distance between each color axis
  46183. * @param scene defines the hosting scene
  46184. */
  46185. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46186. /**
  46187. * Gets camera class name
  46188. * @returns AnaglyphUniversalCamera
  46189. */
  46190. getClassName(): string;
  46191. }
  46192. }
  46193. declare module BABYLON {
  46194. /**
  46195. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46196. * @see https://doc.babylonjs.com/features/cameras
  46197. */
  46198. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46199. /**
  46200. * Creates a new StereoscopicArcRotateCamera
  46201. * @param name defines camera name
  46202. * @param alpha defines alpha angle (in radians)
  46203. * @param beta defines beta angle (in radians)
  46204. * @param radius defines radius
  46205. * @param target defines camera target
  46206. * @param interaxialDistance defines distance between each color axis
  46207. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46208. * @param scene defines the hosting scene
  46209. */
  46210. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46211. /**
  46212. * Gets camera class name
  46213. * @returns StereoscopicArcRotateCamera
  46214. */
  46215. getClassName(): string;
  46216. }
  46217. }
  46218. declare module BABYLON {
  46219. /**
  46220. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46221. * @see https://doc.babylonjs.com/features/cameras
  46222. */
  46223. export class StereoscopicFreeCamera extends FreeCamera {
  46224. /**
  46225. * Creates a new StereoscopicFreeCamera
  46226. * @param name defines camera name
  46227. * @param position defines initial position
  46228. * @param interaxialDistance defines distance between each color axis
  46229. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46230. * @param scene defines the hosting scene
  46231. */
  46232. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46233. /**
  46234. * Gets camera class name
  46235. * @returns StereoscopicFreeCamera
  46236. */
  46237. getClassName(): string;
  46238. }
  46239. }
  46240. declare module BABYLON {
  46241. /**
  46242. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46243. * @see https://doc.babylonjs.com/features/cameras
  46244. */
  46245. export class StereoscopicGamepadCamera extends GamepadCamera {
  46246. /**
  46247. * Creates a new StereoscopicGamepadCamera
  46248. * @param name defines camera name
  46249. * @param position defines initial position
  46250. * @param interaxialDistance defines distance between each color axis
  46251. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46252. * @param scene defines the hosting scene
  46253. */
  46254. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46255. /**
  46256. * Gets camera class name
  46257. * @returns StereoscopicGamepadCamera
  46258. */
  46259. getClassName(): string;
  46260. }
  46261. }
  46262. declare module BABYLON {
  46263. /**
  46264. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46265. * @see https://doc.babylonjs.com/features/cameras
  46266. */
  46267. export class StereoscopicUniversalCamera extends UniversalCamera {
  46268. /**
  46269. * Creates a new StereoscopicUniversalCamera
  46270. * @param name defines camera name
  46271. * @param position defines initial position
  46272. * @param interaxialDistance defines distance between each color axis
  46273. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46274. * @param scene defines the hosting scene
  46275. */
  46276. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46277. /**
  46278. * Gets camera class name
  46279. * @returns StereoscopicUniversalCamera
  46280. */
  46281. getClassName(): string;
  46282. }
  46283. }
  46284. declare module BABYLON {
  46285. /**
  46286. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46287. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46288. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46289. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46290. */
  46291. export class VirtualJoysticksCamera extends FreeCamera {
  46292. /**
  46293. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46294. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46295. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46296. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46297. * @param name Define the name of the camera in the scene
  46298. * @param position Define the start position of the camera in the scene
  46299. * @param scene Define the scene the camera belongs to
  46300. */
  46301. constructor(name: string, position: Vector3, scene: Scene);
  46302. /**
  46303. * Gets the current object class name.
  46304. * @return the class name
  46305. */
  46306. getClassName(): string;
  46307. }
  46308. }
  46309. declare module BABYLON {
  46310. /**
  46311. * This represents all the required metrics to create a VR camera.
  46312. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46313. */
  46314. export class VRCameraMetrics {
  46315. /**
  46316. * Define the horizontal resolution off the screen.
  46317. */
  46318. hResolution: number;
  46319. /**
  46320. * Define the vertical resolution off the screen.
  46321. */
  46322. vResolution: number;
  46323. /**
  46324. * Define the horizontal screen size.
  46325. */
  46326. hScreenSize: number;
  46327. /**
  46328. * Define the vertical screen size.
  46329. */
  46330. vScreenSize: number;
  46331. /**
  46332. * Define the vertical screen center position.
  46333. */
  46334. vScreenCenter: number;
  46335. /**
  46336. * Define the distance of the eyes to the screen.
  46337. */
  46338. eyeToScreenDistance: number;
  46339. /**
  46340. * Define the distance between both lenses
  46341. */
  46342. lensSeparationDistance: number;
  46343. /**
  46344. * Define the distance between both viewer's eyes.
  46345. */
  46346. interpupillaryDistance: number;
  46347. /**
  46348. * Define the distortion factor of the VR postprocess.
  46349. * Please, touch with care.
  46350. */
  46351. distortionK: number[];
  46352. /**
  46353. * Define the chromatic aberration correction factors for the VR post process.
  46354. */
  46355. chromaAbCorrection: number[];
  46356. /**
  46357. * Define the scale factor of the post process.
  46358. * The smaller the better but the slower.
  46359. */
  46360. postProcessScaleFactor: number;
  46361. /**
  46362. * Define an offset for the lens center.
  46363. */
  46364. lensCenterOffset: number;
  46365. /**
  46366. * Define if the current vr camera should compensate the distortion of the lense or not.
  46367. */
  46368. compensateDistortion: boolean;
  46369. /**
  46370. * Defines if multiview should be enabled when rendering (Default: false)
  46371. */
  46372. multiviewEnabled: boolean;
  46373. /**
  46374. * Gets the rendering aspect ratio based on the provided resolutions.
  46375. */
  46376. get aspectRatio(): number;
  46377. /**
  46378. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46379. */
  46380. get aspectRatioFov(): number;
  46381. /**
  46382. * @hidden
  46383. */
  46384. get leftHMatrix(): Matrix;
  46385. /**
  46386. * @hidden
  46387. */
  46388. get rightHMatrix(): Matrix;
  46389. /**
  46390. * @hidden
  46391. */
  46392. get leftPreViewMatrix(): Matrix;
  46393. /**
  46394. * @hidden
  46395. */
  46396. get rightPreViewMatrix(): Matrix;
  46397. /**
  46398. * Get the default VRMetrics based on the most generic setup.
  46399. * @returns the default vr metrics
  46400. */
  46401. static GetDefault(): VRCameraMetrics;
  46402. }
  46403. }
  46404. declare module BABYLON {
  46405. /** @hidden */
  46406. export var vrDistortionCorrectionPixelShader: {
  46407. name: string;
  46408. shader: string;
  46409. };
  46410. }
  46411. declare module BABYLON {
  46412. /**
  46413. * VRDistortionCorrectionPostProcess used for mobile VR
  46414. */
  46415. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46416. private _isRightEye;
  46417. private _distortionFactors;
  46418. private _postProcessScaleFactor;
  46419. private _lensCenterOffset;
  46420. private _scaleIn;
  46421. private _scaleFactor;
  46422. private _lensCenter;
  46423. /**
  46424. * Gets a string identifying the name of the class
  46425. * @returns "VRDistortionCorrectionPostProcess" string
  46426. */
  46427. getClassName(): string;
  46428. /**
  46429. * Initializes the VRDistortionCorrectionPostProcess
  46430. * @param name The name of the effect.
  46431. * @param camera The camera to apply the render pass to.
  46432. * @param isRightEye If this is for the right eye distortion
  46433. * @param vrMetrics All the required metrics for the VR camera
  46434. */
  46435. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46436. }
  46437. }
  46438. declare module BABYLON {
  46439. /**
  46440. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46441. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46442. */
  46443. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46444. /**
  46445. * Creates a new VRDeviceOrientationArcRotateCamera
  46446. * @param name defines camera name
  46447. * @param alpha defines the camera rotation along the logitudinal axis
  46448. * @param beta defines the camera rotation along the latitudinal axis
  46449. * @param radius defines the camera distance from its target
  46450. * @param target defines the camera target
  46451. * @param scene defines the scene the camera belongs to
  46452. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46453. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46454. */
  46455. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46456. /**
  46457. * Gets camera class name
  46458. * @returns VRDeviceOrientationArcRotateCamera
  46459. */
  46460. getClassName(): string;
  46461. }
  46462. }
  46463. declare module BABYLON {
  46464. /**
  46465. * Camera used to simulate VR rendering (based on FreeCamera)
  46466. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46467. */
  46468. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46469. /**
  46470. * Creates a new VRDeviceOrientationFreeCamera
  46471. * @param name defines camera name
  46472. * @param position defines the start position of the camera
  46473. * @param scene defines the scene the camera belongs to
  46474. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46475. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46476. */
  46477. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46478. /**
  46479. * Gets camera class name
  46480. * @returns VRDeviceOrientationFreeCamera
  46481. */
  46482. getClassName(): string;
  46483. }
  46484. }
  46485. declare module BABYLON {
  46486. /**
  46487. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46488. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46489. */
  46490. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46491. /**
  46492. * Creates a new VRDeviceOrientationGamepadCamera
  46493. * @param name defines camera name
  46494. * @param position defines the start position of the camera
  46495. * @param scene defines the scene the camera belongs to
  46496. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46497. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46498. */
  46499. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46500. /**
  46501. * Gets camera class name
  46502. * @returns VRDeviceOrientationGamepadCamera
  46503. */
  46504. getClassName(): string;
  46505. }
  46506. }
  46507. declare module BABYLON {
  46508. /**
  46509. * A class extending Texture allowing drawing on a texture
  46510. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46511. */
  46512. export class DynamicTexture extends Texture {
  46513. private _generateMipMaps;
  46514. private _canvas;
  46515. private _context;
  46516. /**
  46517. * Creates a DynamicTexture
  46518. * @param name defines the name of the texture
  46519. * @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
  46520. * @param scene defines the scene where you want the texture
  46521. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46522. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46523. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46524. */
  46525. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46526. /**
  46527. * Get the current class name of the texture useful for serialization or dynamic coding.
  46528. * @returns "DynamicTexture"
  46529. */
  46530. getClassName(): string;
  46531. /**
  46532. * Gets the current state of canRescale
  46533. */
  46534. get canRescale(): boolean;
  46535. private _recreate;
  46536. /**
  46537. * Scales the texture
  46538. * @param ratio the scale factor to apply to both width and height
  46539. */
  46540. scale(ratio: number): void;
  46541. /**
  46542. * Resizes the texture
  46543. * @param width the new width
  46544. * @param height the new height
  46545. */
  46546. scaleTo(width: number, height: number): void;
  46547. /**
  46548. * Gets the context of the canvas used by the texture
  46549. * @returns the canvas context of the dynamic texture
  46550. */
  46551. getContext(): CanvasRenderingContext2D;
  46552. /**
  46553. * Clears the texture
  46554. */
  46555. clear(): void;
  46556. /**
  46557. * Updates the texture
  46558. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46559. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46560. */
  46561. update(invertY?: boolean, premulAlpha?: boolean): void;
  46562. /**
  46563. * Draws text onto the texture
  46564. * @param text defines the text to be drawn
  46565. * @param x defines the placement of the text from the left
  46566. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46567. * @param font defines the font to be used with font-style, font-size, font-name
  46568. * @param color defines the color used for the text
  46569. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46570. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46571. * @param update defines whether texture is immediately update (default is true)
  46572. */
  46573. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46574. /**
  46575. * Clones the texture
  46576. * @returns the clone of the texture.
  46577. */
  46578. clone(): DynamicTexture;
  46579. /**
  46580. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46581. * @returns a serialized dynamic texture object
  46582. */
  46583. serialize(): any;
  46584. private _IsCanvasElement;
  46585. /** @hidden */
  46586. _rebuild(): void;
  46587. }
  46588. }
  46589. declare module BABYLON {
  46590. /**
  46591. * Class containing static functions to help procedurally build meshes
  46592. */
  46593. export class GroundBuilder {
  46594. /**
  46595. * Creates a ground mesh
  46596. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46597. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46599. * @param name defines the name of the mesh
  46600. * @param options defines the options used to create the mesh
  46601. * @param scene defines the hosting scene
  46602. * @returns the ground mesh
  46603. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46604. */
  46605. static CreateGround(name: string, options: {
  46606. width?: number;
  46607. height?: number;
  46608. subdivisions?: number;
  46609. subdivisionsX?: number;
  46610. subdivisionsY?: number;
  46611. updatable?: boolean;
  46612. }, scene: any): Mesh;
  46613. /**
  46614. * Creates a tiled ground mesh
  46615. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46616. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46617. * * 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
  46618. * * 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
  46619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46620. * @param name defines the name of the mesh
  46621. * @param options defines the options used to create the mesh
  46622. * @param scene defines the hosting scene
  46623. * @returns the tiled ground mesh
  46624. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46625. */
  46626. static CreateTiledGround(name: string, options: {
  46627. xmin: number;
  46628. zmin: number;
  46629. xmax: number;
  46630. zmax: number;
  46631. subdivisions?: {
  46632. w: number;
  46633. h: number;
  46634. };
  46635. precision?: {
  46636. w: number;
  46637. h: number;
  46638. };
  46639. updatable?: boolean;
  46640. }, scene?: Nullable<Scene>): Mesh;
  46641. /**
  46642. * Creates a ground mesh from a height map
  46643. * * The parameter `url` sets the URL of the height map image resource.
  46644. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46645. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46646. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46647. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46648. * * 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.
  46649. * * 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).
  46650. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46652. * @param name defines the name of the mesh
  46653. * @param url defines the url to the height map
  46654. * @param options defines the options used to create the mesh
  46655. * @param scene defines the hosting scene
  46656. * @returns the ground mesh
  46657. * @see https://doc.babylonjs.com/babylon101/height_map
  46658. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46659. */
  46660. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46661. width?: number;
  46662. height?: number;
  46663. subdivisions?: number;
  46664. minHeight?: number;
  46665. maxHeight?: number;
  46666. colorFilter?: Color3;
  46667. alphaFilter?: number;
  46668. updatable?: boolean;
  46669. onReady?: (mesh: GroundMesh) => void;
  46670. }, scene?: Nullable<Scene>): GroundMesh;
  46671. }
  46672. }
  46673. declare module BABYLON {
  46674. /**
  46675. * Class containing static functions to help procedurally build meshes
  46676. */
  46677. export class TorusBuilder {
  46678. /**
  46679. * Creates a torus mesh
  46680. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46681. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46682. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46684. * * 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
  46685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46686. * @param name defines the name of the mesh
  46687. * @param options defines the options used to create the mesh
  46688. * @param scene defines the hosting scene
  46689. * @returns the torus mesh
  46690. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46691. */
  46692. static CreateTorus(name: string, options: {
  46693. diameter?: number;
  46694. thickness?: number;
  46695. tessellation?: number;
  46696. updatable?: boolean;
  46697. sideOrientation?: number;
  46698. frontUVs?: Vector4;
  46699. backUVs?: Vector4;
  46700. }, scene: any): Mesh;
  46701. }
  46702. }
  46703. declare module BABYLON {
  46704. /**
  46705. * Class containing static functions to help procedurally build meshes
  46706. */
  46707. export class CylinderBuilder {
  46708. /**
  46709. * Creates a cylinder or a cone mesh
  46710. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46711. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46712. * * 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.
  46713. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46714. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46715. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46716. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46717. * * 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).
  46718. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46719. * * 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).
  46720. * * 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
  46721. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46722. * * 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
  46723. * * 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.
  46724. * * If `enclose` is false, a ring surface is one element.
  46725. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46726. * * 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
  46727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46728. * * 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
  46729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46730. * @param name defines the name of the mesh
  46731. * @param options defines the options used to create the mesh
  46732. * @param scene defines the hosting scene
  46733. * @returns the cylinder mesh
  46734. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46735. */
  46736. static CreateCylinder(name: string, options: {
  46737. height?: number;
  46738. diameterTop?: number;
  46739. diameterBottom?: number;
  46740. diameter?: number;
  46741. tessellation?: number;
  46742. subdivisions?: number;
  46743. arc?: number;
  46744. faceColors?: Color4[];
  46745. faceUV?: Vector4[];
  46746. updatable?: boolean;
  46747. hasRings?: boolean;
  46748. enclose?: boolean;
  46749. cap?: number;
  46750. sideOrientation?: number;
  46751. frontUVs?: Vector4;
  46752. backUVs?: Vector4;
  46753. }, scene: any): Mesh;
  46754. }
  46755. }
  46756. declare module BABYLON {
  46757. /**
  46758. * States of the webXR experience
  46759. */
  46760. export enum WebXRState {
  46761. /**
  46762. * Transitioning to being in XR mode
  46763. */
  46764. ENTERING_XR = 0,
  46765. /**
  46766. * Transitioning to non XR mode
  46767. */
  46768. EXITING_XR = 1,
  46769. /**
  46770. * In XR mode and presenting
  46771. */
  46772. IN_XR = 2,
  46773. /**
  46774. * Not entered XR mode
  46775. */
  46776. NOT_IN_XR = 3
  46777. }
  46778. /**
  46779. * Abstraction of the XR render target
  46780. */
  46781. export interface WebXRRenderTarget extends IDisposable {
  46782. /**
  46783. * xrpresent context of the canvas which can be used to display/mirror xr content
  46784. */
  46785. canvasContext: WebGLRenderingContext;
  46786. /**
  46787. * xr layer for the canvas
  46788. */
  46789. xrLayer: Nullable<XRWebGLLayer>;
  46790. /**
  46791. * Initializes the xr layer for the session
  46792. * @param xrSession xr session
  46793. * @returns a promise that will resolve once the XR Layer has been created
  46794. */
  46795. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46796. }
  46797. }
  46798. declare module BABYLON {
  46799. /**
  46800. * COnfiguration object for WebXR output canvas
  46801. */
  46802. export class WebXRManagedOutputCanvasOptions {
  46803. /**
  46804. * An optional canvas in case you wish to create it yourself and provide it here.
  46805. * If not provided, a new canvas will be created
  46806. */
  46807. canvasElement?: HTMLCanvasElement;
  46808. /**
  46809. * Options for this XR Layer output
  46810. */
  46811. canvasOptions?: XRWebGLLayerOptions;
  46812. /**
  46813. * CSS styling for a newly created canvas (if not provided)
  46814. */
  46815. newCanvasCssStyle?: string;
  46816. /**
  46817. * Get the default values of the configuration object
  46818. * @param engine defines the engine to use (can be null)
  46819. * @returns default values of this configuration object
  46820. */
  46821. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46822. }
  46823. /**
  46824. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46825. */
  46826. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46827. private _options;
  46828. private _canvas;
  46829. private _engine;
  46830. private _originalCanvasSize;
  46831. /**
  46832. * Rendering context of the canvas which can be used to display/mirror xr content
  46833. */
  46834. canvasContext: WebGLRenderingContext;
  46835. /**
  46836. * xr layer for the canvas
  46837. */
  46838. xrLayer: Nullable<XRWebGLLayer>;
  46839. /**
  46840. * Obseervers registered here will be triggered when the xr layer was initialized
  46841. */
  46842. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46843. /**
  46844. * Initializes the canvas to be added/removed upon entering/exiting xr
  46845. * @param _xrSessionManager The XR Session manager
  46846. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46847. */
  46848. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46849. /**
  46850. * Disposes of the object
  46851. */
  46852. dispose(): void;
  46853. /**
  46854. * Initializes the xr layer for the session
  46855. * @param xrSession xr session
  46856. * @returns a promise that will resolve once the XR Layer has been created
  46857. */
  46858. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46859. private _addCanvas;
  46860. private _removeCanvas;
  46861. private _setCanvasSize;
  46862. private _setManagedOutputCanvas;
  46863. }
  46864. }
  46865. declare module BABYLON {
  46866. /**
  46867. * Manages an XRSession to work with Babylon's engine
  46868. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46869. */
  46870. export class WebXRSessionManager implements IDisposable {
  46871. /** The scene which the session should be created for */
  46872. scene: Scene;
  46873. private _referenceSpace;
  46874. private _rttProvider;
  46875. private _sessionEnded;
  46876. private _xrNavigator;
  46877. private baseLayer;
  46878. /**
  46879. * The base reference space from which the session started. good if you want to reset your
  46880. * reference space
  46881. */
  46882. baseReferenceSpace: XRReferenceSpace;
  46883. /**
  46884. * Current XR frame
  46885. */
  46886. currentFrame: Nullable<XRFrame>;
  46887. /** WebXR timestamp updated every frame */
  46888. currentTimestamp: number;
  46889. /**
  46890. * Used just in case of a failure to initialize an immersive session.
  46891. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46892. */
  46893. defaultHeightCompensation: number;
  46894. /**
  46895. * Fires every time a new xrFrame arrives which can be used to update the camera
  46896. */
  46897. onXRFrameObservable: Observable<XRFrame>;
  46898. /**
  46899. * Fires when the reference space changed
  46900. */
  46901. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46902. /**
  46903. * Fires when the xr session is ended either by the device or manually done
  46904. */
  46905. onXRSessionEnded: Observable<any>;
  46906. /**
  46907. * Fires when the xr session is ended either by the device or manually done
  46908. */
  46909. onXRSessionInit: Observable<XRSession>;
  46910. /**
  46911. * Underlying xr session
  46912. */
  46913. session: XRSession;
  46914. /**
  46915. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46916. * or get the offset the player is currently at.
  46917. */
  46918. viewerReferenceSpace: XRReferenceSpace;
  46919. /**
  46920. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46921. * @param scene The scene which the session should be created for
  46922. */
  46923. constructor(
  46924. /** The scene which the session should be created for */
  46925. scene: Scene);
  46926. /**
  46927. * The current reference space used in this session. This reference space can constantly change!
  46928. * It is mainly used to offset the camera's position.
  46929. */
  46930. get referenceSpace(): XRReferenceSpace;
  46931. /**
  46932. * Set a new reference space and triggers the observable
  46933. */
  46934. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46935. /**
  46936. * Disposes of the session manager
  46937. */
  46938. dispose(): void;
  46939. /**
  46940. * Stops the xrSession and restores the render loop
  46941. * @returns Promise which resolves after it exits XR
  46942. */
  46943. exitXRAsync(): Promise<void>;
  46944. /**
  46945. * Gets the correct render target texture to be rendered this frame for this eye
  46946. * @param eye the eye for which to get the render target
  46947. * @returns the render target for the specified eye
  46948. */
  46949. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46950. /**
  46951. * Creates a WebXRRenderTarget object for the XR session
  46952. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46953. * @param options optional options to provide when creating a new render target
  46954. * @returns a WebXR render target to which the session can render
  46955. */
  46956. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46957. /**
  46958. * Initializes the manager
  46959. * After initialization enterXR can be called to start an XR session
  46960. * @returns Promise which resolves after it is initialized
  46961. */
  46962. initializeAsync(): Promise<void>;
  46963. /**
  46964. * Initializes an xr session
  46965. * @param xrSessionMode mode to initialize
  46966. * @param xrSessionInit defines optional and required values to pass to the session builder
  46967. * @returns a promise which will resolve once the session has been initialized
  46968. */
  46969. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46970. /**
  46971. * Checks if a session would be supported for the creation options specified
  46972. * @param sessionMode session mode to check if supported eg. immersive-vr
  46973. * @returns A Promise that resolves to true if supported and false if not
  46974. */
  46975. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46976. /**
  46977. * Resets the reference space to the one started the session
  46978. */
  46979. resetReferenceSpace(): void;
  46980. /**
  46981. * Starts rendering to the xr layer
  46982. */
  46983. runXRRenderLoop(): void;
  46984. /**
  46985. * Sets the reference space on the xr session
  46986. * @param referenceSpaceType space to set
  46987. * @returns a promise that will resolve once the reference space has been set
  46988. */
  46989. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46990. /**
  46991. * Updates the render state of the session
  46992. * @param state state to set
  46993. * @returns a promise that resolves once the render state has been updated
  46994. */
  46995. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46996. /**
  46997. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46998. * @param sessionMode defines the session to test
  46999. * @returns a promise with boolean as final value
  47000. */
  47001. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47002. private _createRenderTargetTexture;
  47003. }
  47004. }
  47005. declare module BABYLON {
  47006. /**
  47007. * WebXR Camera which holds the views for the xrSession
  47008. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47009. */
  47010. export class WebXRCamera extends FreeCamera {
  47011. private _xrSessionManager;
  47012. private _firstFrame;
  47013. private _referenceQuaternion;
  47014. private _referencedPosition;
  47015. private _xrInvPositionCache;
  47016. private _xrInvQuaternionCache;
  47017. /**
  47018. * Observable raised before camera teleportation
  47019. */
  47020. onBeforeCameraTeleport: Observable<Vector3>;
  47021. /**
  47022. * Observable raised after camera teleportation
  47023. */
  47024. onAfterCameraTeleport: Observable<Vector3>;
  47025. /**
  47026. * Should position compensation execute on first frame.
  47027. * This is used when copying the position from a native (non XR) camera
  47028. */
  47029. compensateOnFirstFrame: boolean;
  47030. /**
  47031. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47032. * @param name the name of the camera
  47033. * @param scene the scene to add the camera to
  47034. * @param _xrSessionManager a constructed xr session manager
  47035. */
  47036. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47037. /**
  47038. * Return the user's height, unrelated to the current ground.
  47039. * This will be the y position of this camera, when ground level is 0.
  47040. */
  47041. get realWorldHeight(): number;
  47042. /** @hidden */
  47043. _updateForDualEyeDebugging(): void;
  47044. /**
  47045. * Sets this camera's transformation based on a non-vr camera
  47046. * @param otherCamera the non-vr camera to copy the transformation from
  47047. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47048. */
  47049. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47050. /**
  47051. * Gets the current instance class name ("WebXRCamera").
  47052. * @returns the class name
  47053. */
  47054. getClassName(): string;
  47055. private _rotate180;
  47056. private _updateFromXRSession;
  47057. private _updateNumberOfRigCameras;
  47058. private _updateReferenceSpace;
  47059. private _updateReferenceSpaceOffset;
  47060. }
  47061. }
  47062. declare module BABYLON {
  47063. /**
  47064. * Defining the interface required for a (webxr) feature
  47065. */
  47066. export interface IWebXRFeature extends IDisposable {
  47067. /**
  47068. * Is this feature attached
  47069. */
  47070. attached: boolean;
  47071. /**
  47072. * Should auto-attach be disabled?
  47073. */
  47074. disableAutoAttach: boolean;
  47075. /**
  47076. * Attach the feature to the session
  47077. * Will usually be called by the features manager
  47078. *
  47079. * @param force should attachment be forced (even when already attached)
  47080. * @returns true if successful.
  47081. */
  47082. attach(force?: boolean): boolean;
  47083. /**
  47084. * Detach the feature from the session
  47085. * Will usually be called by the features manager
  47086. *
  47087. * @returns true if successful.
  47088. */
  47089. detach(): boolean;
  47090. /**
  47091. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47092. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47093. *
  47094. * @returns whether or not the feature is compatible in this environment
  47095. */
  47096. isCompatible(): boolean;
  47097. /**
  47098. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47099. */
  47100. xrNativeFeatureName?: string;
  47101. /**
  47102. * A list of (Babylon WebXR) features this feature depends on
  47103. */
  47104. dependsOn?: string[];
  47105. }
  47106. /**
  47107. * A list of the currently available features without referencing them
  47108. */
  47109. export class WebXRFeatureName {
  47110. /**
  47111. * The name of the anchor system feature
  47112. */
  47113. static readonly ANCHOR_SYSTEM: string;
  47114. /**
  47115. * The name of the background remover feature
  47116. */
  47117. static readonly BACKGROUND_REMOVER: string;
  47118. /**
  47119. * The name of the hit test feature
  47120. */
  47121. static readonly HIT_TEST: string;
  47122. /**
  47123. * physics impostors for xr controllers feature
  47124. */
  47125. static readonly PHYSICS_CONTROLLERS: string;
  47126. /**
  47127. * The name of the plane detection feature
  47128. */
  47129. static readonly PLANE_DETECTION: string;
  47130. /**
  47131. * The name of the pointer selection feature
  47132. */
  47133. static readonly POINTER_SELECTION: string;
  47134. /**
  47135. * The name of the teleportation feature
  47136. */
  47137. static readonly TELEPORTATION: string;
  47138. /**
  47139. * The name of the feature points feature.
  47140. */
  47141. static readonly FEATURE_POINTS: string;
  47142. /**
  47143. * The name of the hand tracking feature.
  47144. */
  47145. static readonly HAND_TRACKING: string;
  47146. }
  47147. /**
  47148. * Defining the constructor of a feature. Used to register the modules.
  47149. */
  47150. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47151. /**
  47152. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47153. * It is mainly used in AR sessions.
  47154. *
  47155. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47156. */
  47157. export class WebXRFeaturesManager implements IDisposable {
  47158. private _xrSessionManager;
  47159. private static readonly _AvailableFeatures;
  47160. private _features;
  47161. /**
  47162. * constructs a new features manages.
  47163. *
  47164. * @param _xrSessionManager an instance of WebXRSessionManager
  47165. */
  47166. constructor(_xrSessionManager: WebXRSessionManager);
  47167. /**
  47168. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47169. * Mainly used internally.
  47170. *
  47171. * @param featureName the name of the feature to register
  47172. * @param constructorFunction the function used to construct the module
  47173. * @param version the (babylon) version of the module
  47174. * @param stable is that a stable version of this module
  47175. */
  47176. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47177. /**
  47178. * Returns a constructor of a specific feature.
  47179. *
  47180. * @param featureName the name of the feature to construct
  47181. * @param version the version of the feature to load
  47182. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47183. * @param options optional options provided to the module.
  47184. * @returns a function that, when called, will return a new instance of this feature
  47185. */
  47186. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47187. /**
  47188. * Can be used to return the list of features currently registered
  47189. *
  47190. * @returns an Array of available features
  47191. */
  47192. static GetAvailableFeatures(): string[];
  47193. /**
  47194. * Gets the versions available for a specific feature
  47195. * @param featureName the name of the feature
  47196. * @returns an array with the available versions
  47197. */
  47198. static GetAvailableVersions(featureName: string): string[];
  47199. /**
  47200. * Return the latest unstable version of this feature
  47201. * @param featureName the name of the feature to search
  47202. * @returns the version number. if not found will return -1
  47203. */
  47204. static GetLatestVersionOfFeature(featureName: string): number;
  47205. /**
  47206. * Return the latest stable version of this feature
  47207. * @param featureName the name of the feature to search
  47208. * @returns the version number. if not found will return -1
  47209. */
  47210. static GetStableVersionOfFeature(featureName: string): number;
  47211. /**
  47212. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47213. * Can be used during a session to start a feature
  47214. * @param featureName the name of feature to attach
  47215. */
  47216. attachFeature(featureName: string): void;
  47217. /**
  47218. * Can be used inside a session or when the session ends to detach a specific feature
  47219. * @param featureName the name of the feature to detach
  47220. */
  47221. detachFeature(featureName: string): void;
  47222. /**
  47223. * Used to disable an already-enabled feature
  47224. * The feature will be disposed and will be recreated once enabled.
  47225. * @param featureName the feature to disable
  47226. * @returns true if disable was successful
  47227. */
  47228. disableFeature(featureName: string | {
  47229. Name: string;
  47230. }): boolean;
  47231. /**
  47232. * dispose this features manager
  47233. */
  47234. dispose(): void;
  47235. /**
  47236. * 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.
  47237. * 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.
  47238. *
  47239. * @param featureName the name of the feature to load or the class of the feature
  47240. * @param version optional version to load. if not provided the latest version will be enabled
  47241. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47242. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47243. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47244. * @returns a new constructed feature or throws an error if feature not found.
  47245. */
  47246. enableFeature(featureName: string | {
  47247. Name: string;
  47248. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47249. /**
  47250. * get the implementation of an enabled feature.
  47251. * @param featureName the name of the feature to load
  47252. * @returns the feature class, if found
  47253. */
  47254. getEnabledFeature(featureName: string): IWebXRFeature;
  47255. /**
  47256. * Get the list of enabled features
  47257. * @returns an array of enabled features
  47258. */
  47259. getEnabledFeatures(): string[];
  47260. /**
  47261. * This function will exten the session creation configuration object with enabled features.
  47262. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47263. * according to the defined "required" variable, provided during enableFeature call
  47264. * @param xrSessionInit the xr Session init object to extend
  47265. *
  47266. * @returns an extended XRSessionInit object
  47267. */
  47268. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47269. }
  47270. }
  47271. declare module BABYLON {
  47272. /**
  47273. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47274. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47275. */
  47276. export class WebXRExperienceHelper implements IDisposable {
  47277. private scene;
  47278. private _nonVRCamera;
  47279. private _originalSceneAutoClear;
  47280. private _supported;
  47281. /**
  47282. * Camera used to render xr content
  47283. */
  47284. camera: WebXRCamera;
  47285. /** A features manager for this xr session */
  47286. featuresManager: WebXRFeaturesManager;
  47287. /**
  47288. * Observers registered here will be triggered after the camera's initial transformation is set
  47289. * This can be used to set a different ground level or an extra rotation.
  47290. *
  47291. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47292. * to the position set after this observable is done executing.
  47293. */
  47294. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47295. /**
  47296. * Fires when the state of the experience helper has changed
  47297. */
  47298. onStateChangedObservable: Observable<WebXRState>;
  47299. /** Session manager used to keep track of xr session */
  47300. sessionManager: WebXRSessionManager;
  47301. /**
  47302. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47303. */
  47304. state: WebXRState;
  47305. /**
  47306. * Creates a WebXRExperienceHelper
  47307. * @param scene The scene the helper should be created in
  47308. */
  47309. private constructor();
  47310. /**
  47311. * Creates the experience helper
  47312. * @param scene the scene to attach the experience helper to
  47313. * @returns a promise for the experience helper
  47314. */
  47315. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47316. /**
  47317. * Disposes of the experience helper
  47318. */
  47319. dispose(): void;
  47320. /**
  47321. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47322. * @param sessionMode options for the XR session
  47323. * @param referenceSpaceType frame of reference of the XR session
  47324. * @param renderTarget the output canvas that will be used to enter XR mode
  47325. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47326. * @returns promise that resolves after xr mode has entered
  47327. */
  47328. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47329. /**
  47330. * Exits XR mode and returns the scene to its original state
  47331. * @returns promise that resolves after xr mode has exited
  47332. */
  47333. exitXRAsync(): Promise<void>;
  47334. private _nonXRToXRCamera;
  47335. private _setState;
  47336. }
  47337. }
  47338. declare module BABYLON {
  47339. /**
  47340. * X-Y values for axes in WebXR
  47341. */
  47342. export interface IWebXRMotionControllerAxesValue {
  47343. /**
  47344. * The value of the x axis
  47345. */
  47346. x: number;
  47347. /**
  47348. * The value of the y-axis
  47349. */
  47350. y: number;
  47351. }
  47352. /**
  47353. * changed / previous values for the values of this component
  47354. */
  47355. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47356. /**
  47357. * current (this frame) value
  47358. */
  47359. current: T;
  47360. /**
  47361. * previous (last change) value
  47362. */
  47363. previous: T;
  47364. }
  47365. /**
  47366. * Represents changes in the component between current frame and last values recorded
  47367. */
  47368. export interface IWebXRMotionControllerComponentChanges {
  47369. /**
  47370. * will be populated with previous and current values if axes changed
  47371. */
  47372. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47373. /**
  47374. * will be populated with previous and current values if pressed changed
  47375. */
  47376. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47377. /**
  47378. * will be populated with previous and current values if touched changed
  47379. */
  47380. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47381. /**
  47382. * will be populated with previous and current values if value changed
  47383. */
  47384. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47385. }
  47386. /**
  47387. * This class represents a single component (for example button or thumbstick) of a motion controller
  47388. */
  47389. export class WebXRControllerComponent implements IDisposable {
  47390. /**
  47391. * the id of this component
  47392. */
  47393. id: string;
  47394. /**
  47395. * the type of the component
  47396. */
  47397. type: MotionControllerComponentType;
  47398. private _buttonIndex;
  47399. private _axesIndices;
  47400. private _axes;
  47401. private _changes;
  47402. private _currentValue;
  47403. private _hasChanges;
  47404. private _pressed;
  47405. private _touched;
  47406. /**
  47407. * button component type
  47408. */
  47409. static BUTTON_TYPE: MotionControllerComponentType;
  47410. /**
  47411. * squeeze component type
  47412. */
  47413. static SQUEEZE_TYPE: MotionControllerComponentType;
  47414. /**
  47415. * Thumbstick component type
  47416. */
  47417. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47418. /**
  47419. * Touchpad component type
  47420. */
  47421. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47422. /**
  47423. * trigger component type
  47424. */
  47425. static TRIGGER_TYPE: MotionControllerComponentType;
  47426. /**
  47427. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47428. * the axes data changes
  47429. */
  47430. onAxisValueChangedObservable: Observable<{
  47431. x: number;
  47432. y: number;
  47433. }>;
  47434. /**
  47435. * Observers registered here will be triggered when the state of a button changes
  47436. * State change is either pressed / touched / value
  47437. */
  47438. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47439. /**
  47440. * Creates a new component for a motion controller.
  47441. * It is created by the motion controller itself
  47442. *
  47443. * @param id the id of this component
  47444. * @param type the type of the component
  47445. * @param _buttonIndex index in the buttons array of the gamepad
  47446. * @param _axesIndices indices of the values in the axes array of the gamepad
  47447. */
  47448. constructor(
  47449. /**
  47450. * the id of this component
  47451. */
  47452. id: string,
  47453. /**
  47454. * the type of the component
  47455. */
  47456. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47457. /**
  47458. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47459. */
  47460. get axes(): IWebXRMotionControllerAxesValue;
  47461. /**
  47462. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47463. */
  47464. get changes(): IWebXRMotionControllerComponentChanges;
  47465. /**
  47466. * Return whether or not the component changed the last frame
  47467. */
  47468. get hasChanges(): boolean;
  47469. /**
  47470. * is the button currently pressed
  47471. */
  47472. get pressed(): boolean;
  47473. /**
  47474. * is the button currently touched
  47475. */
  47476. get touched(): boolean;
  47477. /**
  47478. * Get the current value of this component
  47479. */
  47480. get value(): number;
  47481. /**
  47482. * Dispose this component
  47483. */
  47484. dispose(): void;
  47485. /**
  47486. * Are there axes correlating to this component
  47487. * @return true is axes data is available
  47488. */
  47489. isAxes(): boolean;
  47490. /**
  47491. * Is this component a button (hence - pressable)
  47492. * @returns true if can be pressed
  47493. */
  47494. isButton(): boolean;
  47495. /**
  47496. * update this component using the gamepad object it is in. Called on every frame
  47497. * @param nativeController the native gamepad controller object
  47498. */
  47499. update(nativeController: IMinimalMotionControllerObject): void;
  47500. }
  47501. }
  47502. declare module BABYLON {
  47503. /**
  47504. * Interface used to represent data loading progression
  47505. */
  47506. export interface ISceneLoaderProgressEvent {
  47507. /**
  47508. * Defines if data length to load can be evaluated
  47509. */
  47510. readonly lengthComputable: boolean;
  47511. /**
  47512. * Defines the loaded data length
  47513. */
  47514. readonly loaded: number;
  47515. /**
  47516. * Defines the data length to load
  47517. */
  47518. readonly total: number;
  47519. }
  47520. /**
  47521. * Interface used by SceneLoader plugins to define supported file extensions
  47522. */
  47523. export interface ISceneLoaderPluginExtensions {
  47524. /**
  47525. * Defines the list of supported extensions
  47526. */
  47527. [extension: string]: {
  47528. isBinary: boolean;
  47529. };
  47530. }
  47531. /**
  47532. * Interface used by SceneLoader plugin factory
  47533. */
  47534. export interface ISceneLoaderPluginFactory {
  47535. /**
  47536. * Defines the name of the factory
  47537. */
  47538. name: string;
  47539. /**
  47540. * Function called to create a new plugin
  47541. * @return the new plugin
  47542. */
  47543. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47544. /**
  47545. * The callback that returns true if the data can be directly loaded.
  47546. * @param data string containing the file data
  47547. * @returns if the data can be loaded directly
  47548. */
  47549. canDirectLoad?(data: string): boolean;
  47550. }
  47551. /**
  47552. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47553. */
  47554. export interface ISceneLoaderPluginBase {
  47555. /**
  47556. * The friendly name of this plugin.
  47557. */
  47558. name: string;
  47559. /**
  47560. * The file extensions supported by this plugin.
  47561. */
  47562. extensions: string | ISceneLoaderPluginExtensions;
  47563. /**
  47564. * The callback called when loading from a url.
  47565. * @param scene scene loading this url
  47566. * @param url url to load
  47567. * @param onSuccess callback called when the file successfully loads
  47568. * @param onProgress callback called while file is loading (if the server supports this mode)
  47569. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47570. * @param onError callback called when the file fails to load
  47571. * @returns a file request object
  47572. */
  47573. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47574. /**
  47575. * The callback called when loading from a file object.
  47576. * @param scene scene loading this file
  47577. * @param file defines the file to load
  47578. * @param onSuccess defines the callback to call when data is loaded
  47579. * @param onProgress defines the callback to call during loading process
  47580. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47581. * @param onError defines the callback to call when an error occurs
  47582. * @returns a file request object
  47583. */
  47584. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47585. /**
  47586. * The callback that returns true if the data can be directly loaded.
  47587. * @param data string containing the file data
  47588. * @returns if the data can be loaded directly
  47589. */
  47590. canDirectLoad?(data: string): boolean;
  47591. /**
  47592. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47593. * @param scene scene loading this data
  47594. * @param data string containing the data
  47595. * @returns data to pass to the plugin
  47596. */
  47597. directLoad?(scene: Scene, data: string): any;
  47598. /**
  47599. * The callback that allows custom handling of the root url based on the response url.
  47600. * @param rootUrl the original root url
  47601. * @param responseURL the response url if available
  47602. * @returns the new root url
  47603. */
  47604. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47605. }
  47606. /**
  47607. * Interface used to define a SceneLoader plugin
  47608. */
  47609. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47610. /**
  47611. * Import meshes into a scene.
  47612. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47613. * @param scene The scene to import into
  47614. * @param data The data to import
  47615. * @param rootUrl The root url for scene and resources
  47616. * @param meshes The meshes array to import into
  47617. * @param particleSystems The particle systems array to import into
  47618. * @param skeletons The skeletons array to import into
  47619. * @param onError The callback when import fails
  47620. * @returns True if successful or false otherwise
  47621. */
  47622. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47623. /**
  47624. * Load into a scene.
  47625. * @param scene The scene to load into
  47626. * @param data The data to import
  47627. * @param rootUrl The root url for scene and resources
  47628. * @param onError The callback when import fails
  47629. * @returns True if successful or false otherwise
  47630. */
  47631. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47632. /**
  47633. * Load into an asset container.
  47634. * @param scene The scene to load into
  47635. * @param data The data to import
  47636. * @param rootUrl The root url for scene and resources
  47637. * @param onError The callback when import fails
  47638. * @returns The loaded asset container
  47639. */
  47640. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47641. }
  47642. /**
  47643. * Interface used to define an async SceneLoader plugin
  47644. */
  47645. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47646. /**
  47647. * Import meshes into a scene.
  47648. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47649. * @param scene The scene to import into
  47650. * @param data The data to import
  47651. * @param rootUrl The root url for scene and resources
  47652. * @param onProgress The callback when the load progresses
  47653. * @param fileName Defines the name of the file to load
  47654. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47655. */
  47656. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47657. meshes: AbstractMesh[];
  47658. particleSystems: IParticleSystem[];
  47659. skeletons: Skeleton[];
  47660. animationGroups: AnimationGroup[];
  47661. }>;
  47662. /**
  47663. * Load into a scene.
  47664. * @param scene The scene to load into
  47665. * @param data The data to import
  47666. * @param rootUrl The root url for scene and resources
  47667. * @param onProgress The callback when the load progresses
  47668. * @param fileName Defines the name of the file to load
  47669. * @returns Nothing
  47670. */
  47671. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47672. /**
  47673. * Load into an asset container.
  47674. * @param scene The scene to load into
  47675. * @param data The data to import
  47676. * @param rootUrl The root url for scene and resources
  47677. * @param onProgress The callback when the load progresses
  47678. * @param fileName Defines the name of the file to load
  47679. * @returns The loaded asset container
  47680. */
  47681. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47682. }
  47683. /**
  47684. * Mode that determines how to handle old animation groups before loading new ones.
  47685. */
  47686. export enum SceneLoaderAnimationGroupLoadingMode {
  47687. /**
  47688. * Reset all old animations to initial state then dispose them.
  47689. */
  47690. Clean = 0,
  47691. /**
  47692. * Stop all old animations.
  47693. */
  47694. Stop = 1,
  47695. /**
  47696. * Restart old animations from first frame.
  47697. */
  47698. Sync = 2,
  47699. /**
  47700. * Old animations remains untouched.
  47701. */
  47702. NoSync = 3
  47703. }
  47704. /**
  47705. * Defines a plugin registered by the SceneLoader
  47706. */
  47707. interface IRegisteredPlugin {
  47708. /**
  47709. * Defines the plugin to use
  47710. */
  47711. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47712. /**
  47713. * Defines if the plugin supports binary data
  47714. */
  47715. isBinary: boolean;
  47716. }
  47717. /**
  47718. * Class used to load scene from various file formats using registered plugins
  47719. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47720. */
  47721. export class SceneLoader {
  47722. /**
  47723. * No logging while loading
  47724. */
  47725. static readonly NO_LOGGING: number;
  47726. /**
  47727. * Minimal logging while loading
  47728. */
  47729. static readonly MINIMAL_LOGGING: number;
  47730. /**
  47731. * Summary logging while loading
  47732. */
  47733. static readonly SUMMARY_LOGGING: number;
  47734. /**
  47735. * Detailled logging while loading
  47736. */
  47737. static readonly DETAILED_LOGGING: number;
  47738. /**
  47739. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47740. */
  47741. static get ForceFullSceneLoadingForIncremental(): boolean;
  47742. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47743. /**
  47744. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47745. */
  47746. static get ShowLoadingScreen(): boolean;
  47747. static set ShowLoadingScreen(value: boolean);
  47748. /**
  47749. * Defines the current logging level (while loading the scene)
  47750. * @ignorenaming
  47751. */
  47752. static get loggingLevel(): number;
  47753. static set loggingLevel(value: number);
  47754. /**
  47755. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47756. */
  47757. static get CleanBoneMatrixWeights(): boolean;
  47758. static set CleanBoneMatrixWeights(value: boolean);
  47759. /**
  47760. * Event raised when a plugin is used to load a scene
  47761. */
  47762. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47763. private static _registeredPlugins;
  47764. private static _showingLoadingScreen;
  47765. /**
  47766. * Gets the default plugin (used to load Babylon files)
  47767. * @returns the .babylon plugin
  47768. */
  47769. static GetDefaultPlugin(): IRegisteredPlugin;
  47770. private static _GetPluginForExtension;
  47771. private static _GetPluginForDirectLoad;
  47772. private static _GetPluginForFilename;
  47773. private static _GetDirectLoad;
  47774. private static _LoadData;
  47775. private static _GetFileInfo;
  47776. /**
  47777. * Gets a plugin that can load the given extension
  47778. * @param extension defines the extension to load
  47779. * @returns a plugin or null if none works
  47780. */
  47781. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47782. /**
  47783. * Gets a boolean indicating that the given extension can be loaded
  47784. * @param extension defines the extension to load
  47785. * @returns true if the extension is supported
  47786. */
  47787. static IsPluginForExtensionAvailable(extension: string): boolean;
  47788. /**
  47789. * Adds a new plugin to the list of registered plugins
  47790. * @param plugin defines the plugin to add
  47791. */
  47792. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47793. /**
  47794. * Import meshes into a scene
  47795. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47796. * @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)
  47797. * @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)
  47798. * @param scene the instance of BABYLON.Scene to append to
  47799. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47800. * @param onProgress a callback with a progress event for each file being loaded
  47801. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47802. * @param pluginExtension the extension used to determine the plugin
  47803. * @returns The loaded plugin
  47804. */
  47805. 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>;
  47806. /**
  47807. * Import meshes into a scene
  47808. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47809. * @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)
  47810. * @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)
  47811. * @param scene the instance of BABYLON.Scene to append to
  47812. * @param onProgress a callback with a progress event for each file being loaded
  47813. * @param pluginExtension the extension used to determine the plugin
  47814. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47815. */
  47816. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47817. meshes: AbstractMesh[];
  47818. particleSystems: IParticleSystem[];
  47819. skeletons: Skeleton[];
  47820. animationGroups: AnimationGroup[];
  47821. }>;
  47822. /**
  47823. * Load a scene
  47824. * @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)
  47825. * @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)
  47826. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47827. * @param onSuccess a callback with the scene when import succeeds
  47828. * @param onProgress a callback with a progress event for each file being loaded
  47829. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47830. * @param pluginExtension the extension used to determine the plugin
  47831. * @returns The loaded plugin
  47832. */
  47833. 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>;
  47834. /**
  47835. * Load a scene
  47836. * @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)
  47837. * @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)
  47838. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47839. * @param onProgress a callback with a progress event for each file being loaded
  47840. * @param pluginExtension the extension used to determine the plugin
  47841. * @returns The loaded scene
  47842. */
  47843. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47844. /**
  47845. * Append a scene
  47846. * @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)
  47847. * @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)
  47848. * @param scene is the instance of BABYLON.Scene to append to
  47849. * @param onSuccess a callback with the scene when import succeeds
  47850. * @param onProgress a callback with a progress event for each file being loaded
  47851. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47852. * @param pluginExtension the extension used to determine the plugin
  47853. * @returns The loaded plugin
  47854. */
  47855. 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>;
  47856. /**
  47857. * Append a scene
  47858. * @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)
  47859. * @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)
  47860. * @param scene is the instance of BABYLON.Scene to append to
  47861. * @param onProgress a callback with a progress event for each file being loaded
  47862. * @param pluginExtension the extension used to determine the plugin
  47863. * @returns The given scene
  47864. */
  47865. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47866. /**
  47867. * Load a scene into an asset container
  47868. * @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)
  47869. * @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)
  47870. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47871. * @param onSuccess a callback with the scene when import succeeds
  47872. * @param onProgress a callback with a progress event for each file being loaded
  47873. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47874. * @param pluginExtension the extension used to determine the plugin
  47875. * @returns The loaded plugin
  47876. */
  47877. 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>;
  47878. /**
  47879. * Load a scene into an asset container
  47880. * @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)
  47881. * @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)
  47882. * @param scene is the instance of Scene to append to
  47883. * @param onProgress a callback with a progress event for each file being loaded
  47884. * @param pluginExtension the extension used to determine the plugin
  47885. * @returns The loaded asset container
  47886. */
  47887. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47888. /**
  47889. * Import animations from a file into a scene
  47890. * @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)
  47891. * @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)
  47892. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47893. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47894. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47895. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47896. * @param onSuccess a callback with the scene when import succeeds
  47897. * @param onProgress a callback with a progress event for each file being loaded
  47898. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47899. * @param pluginExtension the extension used to determine the plugin
  47900. */
  47901. 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;
  47902. /**
  47903. * Import animations from a file into a scene
  47904. * @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)
  47905. * @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)
  47906. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47907. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47908. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47909. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47910. * @param onSuccess a callback with the scene when import succeeds
  47911. * @param onProgress a callback with a progress event for each file being loaded
  47912. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47913. * @param pluginExtension the extension used to determine the plugin
  47914. * @returns the updated scene with imported animations
  47915. */
  47916. 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>;
  47917. }
  47918. }
  47919. declare module BABYLON {
  47920. /**
  47921. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47922. */
  47923. export type MotionControllerHandedness = "none" | "left" | "right";
  47924. /**
  47925. * The type of components available in motion controllers.
  47926. * This is not the name of the component.
  47927. */
  47928. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47929. /**
  47930. * The state of a controller component
  47931. */
  47932. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47933. /**
  47934. * The schema of motion controller layout.
  47935. * No object will be initialized using this interface
  47936. * This is used just to define the profile.
  47937. */
  47938. export interface IMotionControllerLayout {
  47939. /**
  47940. * Path to load the assets. Usually relative to the base path
  47941. */
  47942. assetPath: string;
  47943. /**
  47944. * Available components (unsorted)
  47945. */
  47946. components: {
  47947. /**
  47948. * A map of component Ids
  47949. */
  47950. [componentId: string]: {
  47951. /**
  47952. * The type of input the component outputs
  47953. */
  47954. type: MotionControllerComponentType;
  47955. /**
  47956. * The indices of this component in the gamepad object
  47957. */
  47958. gamepadIndices: {
  47959. /**
  47960. * Index of button
  47961. */
  47962. button?: number;
  47963. /**
  47964. * If available, index of x-axis
  47965. */
  47966. xAxis?: number;
  47967. /**
  47968. * If available, index of y-axis
  47969. */
  47970. yAxis?: number;
  47971. };
  47972. /**
  47973. * The mesh's root node name
  47974. */
  47975. rootNodeName: string;
  47976. /**
  47977. * Animation definitions for this model
  47978. */
  47979. visualResponses: {
  47980. [stateKey: string]: {
  47981. /**
  47982. * What property will be animated
  47983. */
  47984. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47985. /**
  47986. * What states influence this visual response
  47987. */
  47988. states: MotionControllerComponentStateType[];
  47989. /**
  47990. * Type of animation - movement or visibility
  47991. */
  47992. valueNodeProperty: "transform" | "visibility";
  47993. /**
  47994. * Base node name to move. Its position will be calculated according to the min and max nodes
  47995. */
  47996. valueNodeName?: string;
  47997. /**
  47998. * Minimum movement node
  47999. */
  48000. minNodeName?: string;
  48001. /**
  48002. * Max movement node
  48003. */
  48004. maxNodeName?: string;
  48005. };
  48006. };
  48007. /**
  48008. * If touch enabled, what is the name of node to display user feedback
  48009. */
  48010. touchPointNodeName?: string;
  48011. };
  48012. };
  48013. /**
  48014. * Is it xr standard mapping or not
  48015. */
  48016. gamepadMapping: "" | "xr-standard";
  48017. /**
  48018. * Base root node of this entire model
  48019. */
  48020. rootNodeName: string;
  48021. /**
  48022. * Defines the main button component id
  48023. */
  48024. selectComponentId: string;
  48025. }
  48026. /**
  48027. * A definition for the layout map in the input profile
  48028. */
  48029. export interface IMotionControllerLayoutMap {
  48030. /**
  48031. * Layouts with handedness type as a key
  48032. */
  48033. [handedness: string]: IMotionControllerLayout;
  48034. }
  48035. /**
  48036. * The XR Input profile schema
  48037. * Profiles can be found here:
  48038. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48039. */
  48040. export interface IMotionControllerProfile {
  48041. /**
  48042. * fallback profiles for this profileId
  48043. */
  48044. fallbackProfileIds: string[];
  48045. /**
  48046. * The layout map, with handedness as key
  48047. */
  48048. layouts: IMotionControllerLayoutMap;
  48049. /**
  48050. * The id of this profile
  48051. * correlates to the profile(s) in the xrInput.profiles array
  48052. */
  48053. profileId: string;
  48054. }
  48055. /**
  48056. * A helper-interface for the 3 meshes needed for controller button animation
  48057. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48058. */
  48059. export interface IMotionControllerButtonMeshMap {
  48060. /**
  48061. * the mesh that defines the pressed value mesh position.
  48062. * This is used to find the max-position of this button
  48063. */
  48064. pressedMesh: AbstractMesh;
  48065. /**
  48066. * the mesh that defines the unpressed value mesh position.
  48067. * This is used to find the min (or initial) position of this button
  48068. */
  48069. unpressedMesh: AbstractMesh;
  48070. /**
  48071. * The mesh that will be changed when value changes
  48072. */
  48073. valueMesh: AbstractMesh;
  48074. }
  48075. /**
  48076. * A helper-interface for the 3 meshes needed for controller axis animation.
  48077. * This will be expanded when touchpad animations are fully supported
  48078. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48079. */
  48080. export interface IMotionControllerMeshMap {
  48081. /**
  48082. * the mesh that defines the maximum value mesh position.
  48083. */
  48084. maxMesh?: AbstractMesh;
  48085. /**
  48086. * the mesh that defines the minimum value mesh position.
  48087. */
  48088. minMesh?: AbstractMesh;
  48089. /**
  48090. * The mesh that will be changed when axis value changes
  48091. */
  48092. valueMesh?: AbstractMesh;
  48093. }
  48094. /**
  48095. * The elements needed for change-detection of the gamepad objects in motion controllers
  48096. */
  48097. export interface IMinimalMotionControllerObject {
  48098. /**
  48099. * Available axes of this controller
  48100. */
  48101. axes: number[];
  48102. /**
  48103. * An array of available buttons
  48104. */
  48105. buttons: Array<{
  48106. /**
  48107. * Value of the button/trigger
  48108. */
  48109. value: number;
  48110. /**
  48111. * If the button/trigger is currently touched
  48112. */
  48113. touched: boolean;
  48114. /**
  48115. * If the button/trigger is currently pressed
  48116. */
  48117. pressed: boolean;
  48118. }>;
  48119. /**
  48120. * EXPERIMENTAL haptic support.
  48121. */
  48122. hapticActuators?: Array<{
  48123. pulse: (value: number, duration: number) => Promise<boolean>;
  48124. }>;
  48125. }
  48126. /**
  48127. * An Abstract Motion controller
  48128. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48129. * Each component has an observable to check for changes in value and state
  48130. */
  48131. export abstract class WebXRAbstractMotionController implements IDisposable {
  48132. protected scene: Scene;
  48133. protected layout: IMotionControllerLayout;
  48134. /**
  48135. * The gamepad object correlating to this controller
  48136. */
  48137. gamepadObject: IMinimalMotionControllerObject;
  48138. /**
  48139. * handedness (left/right/none) of this controller
  48140. */
  48141. handedness: MotionControllerHandedness;
  48142. private _initComponent;
  48143. private _modelReady;
  48144. /**
  48145. * A map of components (WebXRControllerComponent) in this motion controller
  48146. * Components have a ComponentType and can also have both button and axis definitions
  48147. */
  48148. readonly components: {
  48149. [id: string]: WebXRControllerComponent;
  48150. };
  48151. /**
  48152. * Disable the model's animation. Can be set at any time.
  48153. */
  48154. disableAnimation: boolean;
  48155. /**
  48156. * Observers registered here will be triggered when the model of this controller is done loading
  48157. */
  48158. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48159. /**
  48160. * The profile id of this motion controller
  48161. */
  48162. abstract profileId: string;
  48163. /**
  48164. * The root mesh of the model. It is null if the model was not yet initialized
  48165. */
  48166. rootMesh: Nullable<AbstractMesh>;
  48167. /**
  48168. * constructs a new abstract motion controller
  48169. * @param scene the scene to which the model of the controller will be added
  48170. * @param layout The profile layout to load
  48171. * @param gamepadObject The gamepad object correlating to this controller
  48172. * @param handedness handedness (left/right/none) of this controller
  48173. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48174. */
  48175. constructor(scene: Scene, layout: IMotionControllerLayout,
  48176. /**
  48177. * The gamepad object correlating to this controller
  48178. */
  48179. gamepadObject: IMinimalMotionControllerObject,
  48180. /**
  48181. * handedness (left/right/none) of this controller
  48182. */
  48183. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48184. /**
  48185. * Dispose this controller, the model mesh and all its components
  48186. */
  48187. dispose(): void;
  48188. /**
  48189. * Returns all components of specific type
  48190. * @param type the type to search for
  48191. * @return an array of components with this type
  48192. */
  48193. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48194. /**
  48195. * get a component based an its component id as defined in layout.components
  48196. * @param id the id of the component
  48197. * @returns the component correlates to the id or undefined if not found
  48198. */
  48199. getComponent(id: string): WebXRControllerComponent;
  48200. /**
  48201. * Get the list of components available in this motion controller
  48202. * @returns an array of strings correlating to available components
  48203. */
  48204. getComponentIds(): string[];
  48205. /**
  48206. * Get the first component of specific type
  48207. * @param type type of component to find
  48208. * @return a controller component or null if not found
  48209. */
  48210. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48211. /**
  48212. * Get the main (Select) component of this controller as defined in the layout
  48213. * @returns the main component of this controller
  48214. */
  48215. getMainComponent(): WebXRControllerComponent;
  48216. /**
  48217. * Loads the model correlating to this controller
  48218. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48219. * @returns A promise fulfilled with the result of the model loading
  48220. */
  48221. loadModel(): Promise<boolean>;
  48222. /**
  48223. * Update this model using the current XRFrame
  48224. * @param xrFrame the current xr frame to use and update the model
  48225. */
  48226. updateFromXRFrame(xrFrame: XRFrame): void;
  48227. /**
  48228. * Backwards compatibility due to a deeply-integrated typo
  48229. */
  48230. get handness(): XREye;
  48231. /**
  48232. * Pulse (vibrate) this controller
  48233. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48234. * Consecutive calls to this function will cancel the last pulse call
  48235. *
  48236. * @param value the strength of the pulse in 0.0...1.0 range
  48237. * @param duration Duration of the pulse in milliseconds
  48238. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48239. * @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
  48240. */
  48241. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48242. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48243. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48244. /**
  48245. * Moves the axis on the controller mesh based on its current state
  48246. * @param axis the index of the axis
  48247. * @param axisValue the value of the axis which determines the meshes new position
  48248. * @hidden
  48249. */
  48250. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48251. /**
  48252. * Update the model itself with the current frame data
  48253. * @param xrFrame the frame to use for updating the model mesh
  48254. */
  48255. protected updateModel(xrFrame: XRFrame): void;
  48256. /**
  48257. * Get the filename and path for this controller's model
  48258. * @returns a map of filename and path
  48259. */
  48260. protected abstract _getFilenameAndPath(): {
  48261. filename: string;
  48262. path: string;
  48263. };
  48264. /**
  48265. * This function is called before the mesh is loaded. It checks for loading constraints.
  48266. * For example, this function can check if the GLB loader is available
  48267. * If this function returns false, the generic controller will be loaded instead
  48268. * @returns Is the client ready to load the mesh
  48269. */
  48270. protected abstract _getModelLoadingConstraints(): boolean;
  48271. /**
  48272. * This function will be called after the model was successfully loaded and can be used
  48273. * for mesh transformations before it is available for the user
  48274. * @param meshes the loaded meshes
  48275. */
  48276. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48277. /**
  48278. * Set the root mesh for this controller. Important for the WebXR controller class
  48279. * @param meshes the loaded meshes
  48280. */
  48281. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48282. /**
  48283. * A function executed each frame that updates the mesh (if needed)
  48284. * @param xrFrame the current xrFrame
  48285. */
  48286. protected abstract _updateModel(xrFrame: XRFrame): void;
  48287. private _getGenericFilenameAndPath;
  48288. private _getGenericParentMesh;
  48289. }
  48290. }
  48291. declare module BABYLON {
  48292. /**
  48293. * A generic trigger-only motion controller for WebXR
  48294. */
  48295. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48296. /**
  48297. * Static version of the profile id of this controller
  48298. */
  48299. static ProfileId: string;
  48300. profileId: string;
  48301. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48302. protected _getFilenameAndPath(): {
  48303. filename: string;
  48304. path: string;
  48305. };
  48306. protected _getModelLoadingConstraints(): boolean;
  48307. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48308. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48309. protected _updateModel(): void;
  48310. }
  48311. }
  48312. declare module BABYLON {
  48313. /**
  48314. * Class containing static functions to help procedurally build meshes
  48315. */
  48316. export class SphereBuilder {
  48317. /**
  48318. * Creates a sphere mesh
  48319. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48320. * * 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`)
  48321. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48322. * * 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
  48323. * * 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)
  48324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48325. * * 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
  48326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48327. * @param name defines the name of the mesh
  48328. * @param options defines the options used to create the mesh
  48329. * @param scene defines the hosting scene
  48330. * @returns the sphere mesh
  48331. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48332. */
  48333. static CreateSphere(name: string, options: {
  48334. segments?: number;
  48335. diameter?: number;
  48336. diameterX?: number;
  48337. diameterY?: number;
  48338. diameterZ?: number;
  48339. arc?: number;
  48340. slice?: number;
  48341. sideOrientation?: number;
  48342. frontUVs?: Vector4;
  48343. backUVs?: Vector4;
  48344. updatable?: boolean;
  48345. }, scene?: Nullable<Scene>): Mesh;
  48346. }
  48347. }
  48348. declare module BABYLON {
  48349. /**
  48350. * A profiled motion controller has its profile loaded from an online repository.
  48351. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48352. */
  48353. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48354. private _repositoryUrl;
  48355. private _buttonMeshMapping;
  48356. private _touchDots;
  48357. /**
  48358. * The profile ID of this controller. Will be populated when the controller initializes.
  48359. */
  48360. profileId: string;
  48361. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48362. dispose(): void;
  48363. protected _getFilenameAndPath(): {
  48364. filename: string;
  48365. path: string;
  48366. };
  48367. protected _getModelLoadingConstraints(): boolean;
  48368. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48369. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48370. protected _updateModel(_xrFrame: XRFrame): void;
  48371. }
  48372. }
  48373. declare module BABYLON {
  48374. /**
  48375. * A construction function type to create a new controller based on an xrInput object
  48376. */
  48377. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48378. /**
  48379. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48380. *
  48381. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48382. * it should be replaced with auto-loaded controllers.
  48383. *
  48384. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48385. */
  48386. export class WebXRMotionControllerManager {
  48387. private static _AvailableControllers;
  48388. private static _Fallbacks;
  48389. private static _ProfileLoadingPromises;
  48390. private static _ProfilesList;
  48391. /**
  48392. * The base URL of the online controller repository. Can be changed at any time.
  48393. */
  48394. static BaseRepositoryUrl: string;
  48395. /**
  48396. * Which repository gets priority - local or online
  48397. */
  48398. static PrioritizeOnlineRepository: boolean;
  48399. /**
  48400. * Use the online repository, or use only locally-defined controllers
  48401. */
  48402. static UseOnlineRepository: boolean;
  48403. /**
  48404. * Clear the cache used for profile loading and reload when requested again
  48405. */
  48406. static ClearProfilesCache(): void;
  48407. /**
  48408. * Register the default fallbacks.
  48409. * This function is called automatically when this file is imported.
  48410. */
  48411. static DefaultFallbacks(): void;
  48412. /**
  48413. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48414. * @param profileId the profile to which a fallback needs to be found
  48415. * @return an array with corresponding fallback profiles
  48416. */
  48417. static FindFallbackWithProfileId(profileId: string): string[];
  48418. /**
  48419. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48420. * The order of search:
  48421. *
  48422. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48423. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48424. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48425. * 4) return the generic trigger controller if none were found
  48426. *
  48427. * @param xrInput the xrInput to which a new controller is initialized
  48428. * @param scene the scene to which the model will be added
  48429. * @param forceProfile force a certain profile for this controller
  48430. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48431. */
  48432. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48433. /**
  48434. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48435. *
  48436. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48437. *
  48438. * @param type the profile type to register
  48439. * @param constructFunction the function to be called when loading this profile
  48440. */
  48441. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48442. /**
  48443. * Register a fallback to a specific profile.
  48444. * @param profileId the profileId that will receive the fallbacks
  48445. * @param fallbacks A list of fallback profiles
  48446. */
  48447. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48448. /**
  48449. * Will update the list of profiles available in the repository
  48450. * @return a promise that resolves to a map of profiles available online
  48451. */
  48452. static UpdateProfilesList(): Promise<{
  48453. [profile: string]: string;
  48454. }>;
  48455. private static _LoadProfileFromRepository;
  48456. private static _LoadProfilesFromAvailableControllers;
  48457. }
  48458. }
  48459. declare module BABYLON {
  48460. /**
  48461. * Configuration options for the WebXR controller creation
  48462. */
  48463. export interface IWebXRControllerOptions {
  48464. /**
  48465. * Should the controller mesh be animated when a user interacts with it
  48466. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48467. */
  48468. disableMotionControllerAnimation?: boolean;
  48469. /**
  48470. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48471. */
  48472. doNotLoadControllerMesh?: boolean;
  48473. /**
  48474. * Force a specific controller type for this controller.
  48475. * This can be used when creating your own profile or when testing different controllers
  48476. */
  48477. forceControllerProfile?: string;
  48478. /**
  48479. * Defines a rendering group ID for meshes that will be loaded.
  48480. * This is for the default controllers only.
  48481. */
  48482. renderingGroupId?: number;
  48483. }
  48484. /**
  48485. * Represents an XR controller
  48486. */
  48487. export class WebXRInputSource {
  48488. private _scene;
  48489. /** The underlying input source for the controller */
  48490. inputSource: XRInputSource;
  48491. private _options;
  48492. private _tmpVector;
  48493. private _uniqueId;
  48494. private _disposed;
  48495. /**
  48496. * 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
  48497. */
  48498. grip?: AbstractMesh;
  48499. /**
  48500. * If available, this is the gamepad object related to this controller.
  48501. * Using this object it is possible to get click events and trackpad changes of the
  48502. * webxr controller that is currently being used.
  48503. */
  48504. motionController?: WebXRAbstractMotionController;
  48505. /**
  48506. * Event that fires when the controller is removed/disposed.
  48507. * The object provided as event data is this controller, after associated assets were disposed.
  48508. * uniqueId is still available.
  48509. */
  48510. onDisposeObservable: Observable<WebXRInputSource>;
  48511. /**
  48512. * Will be triggered when the mesh associated with the motion controller is done loading.
  48513. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48514. * A shortened version of controller -> motion controller -> on mesh loaded.
  48515. */
  48516. onMeshLoadedObservable: Observable<AbstractMesh>;
  48517. /**
  48518. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48519. */
  48520. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48521. /**
  48522. * Pointer which can be used to select objects or attach a visible laser to
  48523. */
  48524. pointer: AbstractMesh;
  48525. /**
  48526. * Creates the input source object
  48527. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48528. * @param _scene the scene which the controller should be associated to
  48529. * @param inputSource the underlying input source for the controller
  48530. * @param _options options for this controller creation
  48531. */
  48532. constructor(_scene: Scene,
  48533. /** The underlying input source for the controller */
  48534. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48535. /**
  48536. * Get this controllers unique id
  48537. */
  48538. get uniqueId(): string;
  48539. /**
  48540. * Disposes of the object
  48541. */
  48542. dispose(): void;
  48543. /**
  48544. * Gets a world space ray coming from the pointer or grip
  48545. * @param result the resulting ray
  48546. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48547. */
  48548. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48549. /**
  48550. * Updates the controller pose based on the given XRFrame
  48551. * @param xrFrame xr frame to update the pose with
  48552. * @param referenceSpace reference space to use
  48553. */
  48554. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48555. }
  48556. }
  48557. declare module BABYLON {
  48558. /**
  48559. * The schema for initialization options of the XR Input class
  48560. */
  48561. export interface IWebXRInputOptions {
  48562. /**
  48563. * If set to true no model will be automatically loaded
  48564. */
  48565. doNotLoadControllerMeshes?: boolean;
  48566. /**
  48567. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48568. * If not found, the xr input profile data will be used.
  48569. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48570. */
  48571. forceInputProfile?: string;
  48572. /**
  48573. * Do not send a request to the controller repository to load the profile.
  48574. *
  48575. * Instead, use the controllers available in babylon itself.
  48576. */
  48577. disableOnlineControllerRepository?: boolean;
  48578. /**
  48579. * A custom URL for the controllers repository
  48580. */
  48581. customControllersRepositoryURL?: string;
  48582. /**
  48583. * Should the controller model's components not move according to the user input
  48584. */
  48585. disableControllerAnimation?: boolean;
  48586. /**
  48587. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48588. */
  48589. controllerOptions?: IWebXRControllerOptions;
  48590. }
  48591. /**
  48592. * XR input used to track XR inputs such as controllers/rays
  48593. */
  48594. export class WebXRInput implements IDisposable {
  48595. /**
  48596. * the xr session manager for this session
  48597. */
  48598. xrSessionManager: WebXRSessionManager;
  48599. /**
  48600. * the WebXR camera for this session. Mainly used for teleportation
  48601. */
  48602. xrCamera: WebXRCamera;
  48603. private readonly options;
  48604. /**
  48605. * XR controllers being tracked
  48606. */
  48607. controllers: Array<WebXRInputSource>;
  48608. private _frameObserver;
  48609. private _sessionEndedObserver;
  48610. private _sessionInitObserver;
  48611. /**
  48612. * Event when a controller has been connected/added
  48613. */
  48614. onControllerAddedObservable: Observable<WebXRInputSource>;
  48615. /**
  48616. * Event when a controller has been removed/disconnected
  48617. */
  48618. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48619. /**
  48620. * Initializes the WebXRInput
  48621. * @param xrSessionManager the xr session manager for this session
  48622. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48623. * @param options = initialization options for this xr input
  48624. */
  48625. constructor(
  48626. /**
  48627. * the xr session manager for this session
  48628. */
  48629. xrSessionManager: WebXRSessionManager,
  48630. /**
  48631. * the WebXR camera for this session. Mainly used for teleportation
  48632. */
  48633. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48634. private _onInputSourcesChange;
  48635. private _addAndRemoveControllers;
  48636. /**
  48637. * Disposes of the object
  48638. */
  48639. dispose(): void;
  48640. }
  48641. }
  48642. declare module BABYLON {
  48643. /**
  48644. * This is the base class for all WebXR features.
  48645. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48646. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48647. */
  48648. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48649. protected _xrSessionManager: WebXRSessionManager;
  48650. private _attached;
  48651. private _removeOnDetach;
  48652. /**
  48653. * Should auto-attach be disabled?
  48654. */
  48655. disableAutoAttach: boolean;
  48656. /**
  48657. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48658. */
  48659. xrNativeFeatureName: string;
  48660. /**
  48661. * Construct a new (abstract) WebXR feature
  48662. * @param _xrSessionManager the xr session manager for this feature
  48663. */
  48664. constructor(_xrSessionManager: WebXRSessionManager);
  48665. /**
  48666. * Is this feature attached
  48667. */
  48668. get attached(): boolean;
  48669. /**
  48670. * attach this feature
  48671. *
  48672. * @param force should attachment be forced (even when already attached)
  48673. * @returns true if successful, false is failed or already attached
  48674. */
  48675. attach(force?: boolean): boolean;
  48676. /**
  48677. * detach this feature.
  48678. *
  48679. * @returns true if successful, false if failed or already detached
  48680. */
  48681. detach(): boolean;
  48682. /**
  48683. * Dispose this feature and all of the resources attached
  48684. */
  48685. dispose(): void;
  48686. /**
  48687. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48688. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48689. *
  48690. * @returns whether or not the feature is compatible in this environment
  48691. */
  48692. isCompatible(): boolean;
  48693. /**
  48694. * This is used to register callbacks that will automatically be removed when detach is called.
  48695. * @param observable the observable to which the observer will be attached
  48696. * @param callback the callback to register
  48697. */
  48698. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48699. /**
  48700. * Code in this function will be executed on each xrFrame received from the browser.
  48701. * This function will not execute after the feature is detached.
  48702. * @param _xrFrame the current frame
  48703. */
  48704. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48705. }
  48706. }
  48707. declare module BABYLON {
  48708. /**
  48709. * Renders a layer on top of an existing scene
  48710. */
  48711. export class UtilityLayerRenderer implements IDisposable {
  48712. /** the original scene that will be rendered on top of */
  48713. originalScene: Scene;
  48714. private _pointerCaptures;
  48715. private _lastPointerEvents;
  48716. private static _DefaultUtilityLayer;
  48717. private static _DefaultKeepDepthUtilityLayer;
  48718. private _sharedGizmoLight;
  48719. private _renderCamera;
  48720. /**
  48721. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48722. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48723. * @returns the camera that is used when rendering the utility layer
  48724. */
  48725. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48726. /**
  48727. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48728. * @param cam the camera that should be used when rendering the utility layer
  48729. */
  48730. setRenderCamera(cam: Nullable<Camera>): void;
  48731. /**
  48732. * @hidden
  48733. * Light which used by gizmos to get light shading
  48734. */
  48735. _getSharedGizmoLight(): HemisphericLight;
  48736. /**
  48737. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48738. */
  48739. pickUtilitySceneFirst: boolean;
  48740. /**
  48741. * 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)
  48742. */
  48743. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48744. /**
  48745. * 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)
  48746. */
  48747. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48748. /**
  48749. * The scene that is rendered on top of the original scene
  48750. */
  48751. utilityLayerScene: Scene;
  48752. /**
  48753. * If the utility layer should automatically be rendered on top of existing scene
  48754. */
  48755. shouldRender: boolean;
  48756. /**
  48757. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48758. */
  48759. onlyCheckPointerDownEvents: boolean;
  48760. /**
  48761. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48762. */
  48763. processAllEvents: boolean;
  48764. /**
  48765. * Observable raised when the pointer move from the utility layer scene to the main scene
  48766. */
  48767. onPointerOutObservable: Observable<number>;
  48768. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48769. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48770. private _afterRenderObserver;
  48771. private _sceneDisposeObserver;
  48772. private _originalPointerObserver;
  48773. /**
  48774. * Instantiates a UtilityLayerRenderer
  48775. * @param originalScene the original scene that will be rendered on top of
  48776. * @param handleEvents boolean indicating if the utility layer should handle events
  48777. */
  48778. constructor(
  48779. /** the original scene that will be rendered on top of */
  48780. originalScene: Scene, handleEvents?: boolean);
  48781. private _notifyObservers;
  48782. /**
  48783. * Renders the utility layers scene on top of the original scene
  48784. */
  48785. render(): void;
  48786. /**
  48787. * Disposes of the renderer
  48788. */
  48789. dispose(): void;
  48790. private _updateCamera;
  48791. }
  48792. }
  48793. declare module BABYLON {
  48794. /**
  48795. * Options interface for the pointer selection module
  48796. */
  48797. export interface IWebXRControllerPointerSelectionOptions {
  48798. /**
  48799. * if provided, this scene will be used to render meshes.
  48800. */
  48801. customUtilityLayerScene?: Scene;
  48802. /**
  48803. * 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)
  48804. * If not disabled, the last picked point will be used to execute a pointer up event
  48805. * If disabled, pointer up event will be triggered right after the pointer down event.
  48806. * Used in screen and gaze target ray mode only
  48807. */
  48808. disablePointerUpOnTouchOut: boolean;
  48809. /**
  48810. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48811. */
  48812. forceGazeMode: boolean;
  48813. /**
  48814. * 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
  48815. * to start a new countdown to the pointer down event.
  48816. * Defaults to 1.
  48817. */
  48818. gazeModePointerMovedFactor?: number;
  48819. /**
  48820. * Different button type to use instead of the main component
  48821. */
  48822. overrideButtonId?: string;
  48823. /**
  48824. * use this rendering group id for the meshes (optional)
  48825. */
  48826. renderingGroupId?: number;
  48827. /**
  48828. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48829. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48830. * 3000 means 3 seconds between pointing at something and selecting it
  48831. */
  48832. timeToSelect?: number;
  48833. /**
  48834. * Should meshes created here be added to a utility layer or the main scene
  48835. */
  48836. useUtilityLayer?: boolean;
  48837. /**
  48838. * Optional WebXR camera to be used for gaze selection
  48839. */
  48840. gazeCamera?: WebXRCamera;
  48841. /**
  48842. * the xr input to use with this pointer selection
  48843. */
  48844. xrInput: WebXRInput;
  48845. }
  48846. /**
  48847. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48848. */
  48849. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48850. private readonly _options;
  48851. private static _idCounter;
  48852. private _attachController;
  48853. private _controllers;
  48854. private _scene;
  48855. private _tmpVectorForPickCompare;
  48856. /**
  48857. * The module's name
  48858. */
  48859. static readonly Name: string;
  48860. /**
  48861. * The (Babylon) version of this module.
  48862. * This is an integer representing the implementation version.
  48863. * This number does not correspond to the WebXR specs version
  48864. */
  48865. static readonly Version: number;
  48866. /**
  48867. * Disable lighting on the laser pointer (so it will always be visible)
  48868. */
  48869. disablePointerLighting: boolean;
  48870. /**
  48871. * Disable lighting on the selection mesh (so it will always be visible)
  48872. */
  48873. disableSelectionMeshLighting: boolean;
  48874. /**
  48875. * Should the laser pointer be displayed
  48876. */
  48877. displayLaserPointer: boolean;
  48878. /**
  48879. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48880. */
  48881. displaySelectionMesh: boolean;
  48882. /**
  48883. * This color will be set to the laser pointer when selection is triggered
  48884. */
  48885. laserPointerPickedColor: Color3;
  48886. /**
  48887. * Default color of the laser pointer
  48888. */
  48889. laserPointerDefaultColor: Color3;
  48890. /**
  48891. * default color of the selection ring
  48892. */
  48893. selectionMeshDefaultColor: Color3;
  48894. /**
  48895. * This color will be applied to the selection ring when selection is triggered
  48896. */
  48897. selectionMeshPickedColor: Color3;
  48898. /**
  48899. * Optional filter to be used for ray selection. This predicate shares behavior with
  48900. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48901. */
  48902. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48903. /**
  48904. * constructs a new background remover module
  48905. * @param _xrSessionManager the session manager for this module
  48906. * @param _options read-only options to be used in this module
  48907. */
  48908. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48909. /**
  48910. * attach this feature
  48911. * Will usually be called by the features manager
  48912. *
  48913. * @returns true if successful.
  48914. */
  48915. attach(): boolean;
  48916. /**
  48917. * detach this feature.
  48918. * Will usually be called by the features manager
  48919. *
  48920. * @returns true if successful.
  48921. */
  48922. detach(): boolean;
  48923. /**
  48924. * Will get the mesh under a specific pointer.
  48925. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48926. * @param controllerId the controllerId to check
  48927. * @returns The mesh under pointer or null if no mesh is under the pointer
  48928. */
  48929. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48930. /**
  48931. * Get the xr controller that correlates to the pointer id in the pointer event
  48932. *
  48933. * @param id the pointer id to search for
  48934. * @returns the controller that correlates to this id or null if not found
  48935. */
  48936. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48937. protected _onXRFrame(_xrFrame: XRFrame): void;
  48938. private _attachGazeMode;
  48939. private _attachScreenRayMode;
  48940. private _attachTrackedPointerRayMode;
  48941. private _convertNormalToDirectionOfRay;
  48942. private _detachController;
  48943. private _generateNewMeshPair;
  48944. private _pickingMoved;
  48945. private _updatePointerDistance;
  48946. /** @hidden */
  48947. get lasterPointerDefaultColor(): Color3;
  48948. }
  48949. }
  48950. declare module BABYLON {
  48951. /**
  48952. * Button which can be used to enter a different mode of XR
  48953. */
  48954. export class WebXREnterExitUIButton {
  48955. /** button element */
  48956. element: HTMLElement;
  48957. /** XR initialization options for the button */
  48958. sessionMode: XRSessionMode;
  48959. /** Reference space type */
  48960. referenceSpaceType: XRReferenceSpaceType;
  48961. /**
  48962. * Creates a WebXREnterExitUIButton
  48963. * @param element button element
  48964. * @param sessionMode XR initialization session mode
  48965. * @param referenceSpaceType the type of reference space to be used
  48966. */
  48967. constructor(
  48968. /** button element */
  48969. element: HTMLElement,
  48970. /** XR initialization options for the button */
  48971. sessionMode: XRSessionMode,
  48972. /** Reference space type */
  48973. referenceSpaceType: XRReferenceSpaceType);
  48974. /**
  48975. * Extendable function which can be used to update the button's visuals when the state changes
  48976. * @param activeButton the current active button in the UI
  48977. */
  48978. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48979. }
  48980. /**
  48981. * Options to create the webXR UI
  48982. */
  48983. export class WebXREnterExitUIOptions {
  48984. /**
  48985. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48986. */
  48987. customButtons?: Array<WebXREnterExitUIButton>;
  48988. /**
  48989. * A reference space type to use when creating the default button.
  48990. * Default is local-floor
  48991. */
  48992. referenceSpaceType?: XRReferenceSpaceType;
  48993. /**
  48994. * Context to enter xr with
  48995. */
  48996. renderTarget?: Nullable<WebXRRenderTarget>;
  48997. /**
  48998. * A session mode to use when creating the default button.
  48999. * Default is immersive-vr
  49000. */
  49001. sessionMode?: XRSessionMode;
  49002. /**
  49003. * A list of optional features to init the session with
  49004. */
  49005. optionalFeatures?: string[];
  49006. /**
  49007. * A list of optional features to init the session with
  49008. */
  49009. requiredFeatures?: string[];
  49010. }
  49011. /**
  49012. * UI to allow the user to enter/exit XR mode
  49013. */
  49014. export class WebXREnterExitUI implements IDisposable {
  49015. private scene;
  49016. /** version of the options passed to this UI */
  49017. options: WebXREnterExitUIOptions;
  49018. private _activeButton;
  49019. private _buttons;
  49020. /**
  49021. * The HTML Div Element to which buttons are added.
  49022. */
  49023. readonly overlay: HTMLDivElement;
  49024. /**
  49025. * Fired every time the active button is changed.
  49026. *
  49027. * When xr is entered via a button that launches xr that button will be the callback parameter
  49028. *
  49029. * When exiting xr the callback parameter will be null)
  49030. */
  49031. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49032. /**
  49033. *
  49034. * @param scene babylon scene object to use
  49035. * @param options (read-only) version of the options passed to this UI
  49036. */
  49037. private constructor();
  49038. /**
  49039. * Creates UI to allow the user to enter/exit XR mode
  49040. * @param scene the scene to add the ui to
  49041. * @param helper the xr experience helper to enter/exit xr with
  49042. * @param options options to configure the UI
  49043. * @returns the created ui
  49044. */
  49045. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49046. /**
  49047. * Disposes of the XR UI component
  49048. */
  49049. dispose(): void;
  49050. private _updateButtons;
  49051. }
  49052. }
  49053. declare module BABYLON {
  49054. /**
  49055. * Class containing static functions to help procedurally build meshes
  49056. */
  49057. export class LinesBuilder {
  49058. /**
  49059. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49060. * * 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
  49061. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49062. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49063. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49064. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49065. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49066. * * 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
  49067. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49070. * @param name defines the name of the new line system
  49071. * @param options defines the options used to create the line system
  49072. * @param scene defines the hosting scene
  49073. * @returns a new line system mesh
  49074. */
  49075. static CreateLineSystem(name: string, options: {
  49076. lines: Vector3[][];
  49077. updatable?: boolean;
  49078. instance?: Nullable<LinesMesh>;
  49079. colors?: Nullable<Color4[][]>;
  49080. useVertexAlpha?: boolean;
  49081. }, scene: Nullable<Scene>): LinesMesh;
  49082. /**
  49083. * Creates a line mesh
  49084. * 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
  49085. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49086. * * The parameter `points` is an array successive Vector3
  49087. * * 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
  49088. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49089. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49090. * * When updating an instance, remember that only point positions can change, not the number of points
  49091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49093. * @param name defines the name of the new line system
  49094. * @param options defines the options used to create the line system
  49095. * @param scene defines the hosting scene
  49096. * @returns a new line mesh
  49097. */
  49098. static CreateLines(name: string, options: {
  49099. points: Vector3[];
  49100. updatable?: boolean;
  49101. instance?: Nullable<LinesMesh>;
  49102. colors?: Color4[];
  49103. useVertexAlpha?: boolean;
  49104. }, scene?: Nullable<Scene>): LinesMesh;
  49105. /**
  49106. * Creates a dashed line mesh
  49107. * * 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
  49108. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49109. * * The parameter `points` is an array successive Vector3
  49110. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49111. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49112. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49113. * * 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
  49114. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49115. * * When updating an instance, remember that only point positions can change, not the number of points
  49116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49117. * @param name defines the name of the mesh
  49118. * @param options defines the options used to create the mesh
  49119. * @param scene defines the hosting scene
  49120. * @returns the dashed line mesh
  49121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49122. */
  49123. static CreateDashedLines(name: string, options: {
  49124. points: Vector3[];
  49125. dashSize?: number;
  49126. gapSize?: number;
  49127. dashNb?: number;
  49128. updatable?: boolean;
  49129. instance?: LinesMesh;
  49130. useVertexAlpha?: boolean;
  49131. }, scene?: Nullable<Scene>): LinesMesh;
  49132. }
  49133. }
  49134. declare module BABYLON {
  49135. /**
  49136. * Construction options for a timer
  49137. */
  49138. export interface ITimerOptions<T> {
  49139. /**
  49140. * Time-to-end
  49141. */
  49142. timeout: number;
  49143. /**
  49144. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49145. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49146. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49147. */
  49148. contextObservable: Observable<T>;
  49149. /**
  49150. * Optional parameters when adding an observer to the observable
  49151. */
  49152. observableParameters?: {
  49153. mask?: number;
  49154. insertFirst?: boolean;
  49155. scope?: any;
  49156. };
  49157. /**
  49158. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49159. */
  49160. breakCondition?: (data?: ITimerData<T>) => boolean;
  49161. /**
  49162. * Will be triggered when the time condition has met
  49163. */
  49164. onEnded?: (data: ITimerData<any>) => void;
  49165. /**
  49166. * Will be triggered when the break condition has met (prematurely ended)
  49167. */
  49168. onAborted?: (data: ITimerData<any>) => void;
  49169. /**
  49170. * Optional function to execute on each tick (or count)
  49171. */
  49172. onTick?: (data: ITimerData<any>) => void;
  49173. }
  49174. /**
  49175. * An interface defining the data sent by the timer
  49176. */
  49177. export interface ITimerData<T> {
  49178. /**
  49179. * When did it start
  49180. */
  49181. startTime: number;
  49182. /**
  49183. * Time now
  49184. */
  49185. currentTime: number;
  49186. /**
  49187. * Time passed since started
  49188. */
  49189. deltaTime: number;
  49190. /**
  49191. * How much is completed, in [0.0...1.0].
  49192. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49193. */
  49194. completeRate: number;
  49195. /**
  49196. * What the registered observable sent in the last count
  49197. */
  49198. payload: T;
  49199. }
  49200. /**
  49201. * The current state of the timer
  49202. */
  49203. export enum TimerState {
  49204. /**
  49205. * Timer initialized, not yet started
  49206. */
  49207. INIT = 0,
  49208. /**
  49209. * Timer started and counting
  49210. */
  49211. STARTED = 1,
  49212. /**
  49213. * Timer ended (whether aborted or time reached)
  49214. */
  49215. ENDED = 2
  49216. }
  49217. /**
  49218. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49219. *
  49220. * @param options options with which to initialize this timer
  49221. */
  49222. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49223. /**
  49224. * An advanced implementation of a timer class
  49225. */
  49226. export class AdvancedTimer<T = any> implements IDisposable {
  49227. /**
  49228. * Will notify each time the timer calculates the remaining time
  49229. */
  49230. onEachCountObservable: Observable<ITimerData<T>>;
  49231. /**
  49232. * Will trigger when the timer was aborted due to the break condition
  49233. */
  49234. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49235. /**
  49236. * Will trigger when the timer ended successfully
  49237. */
  49238. onTimerEndedObservable: Observable<ITimerData<T>>;
  49239. /**
  49240. * Will trigger when the timer state has changed
  49241. */
  49242. onStateChangedObservable: Observable<TimerState>;
  49243. private _observer;
  49244. private _contextObservable;
  49245. private _observableParameters;
  49246. private _startTime;
  49247. private _timer;
  49248. private _state;
  49249. private _breakCondition;
  49250. private _timeToEnd;
  49251. private _breakOnNextTick;
  49252. /**
  49253. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49254. * @param options construction options for this advanced timer
  49255. */
  49256. constructor(options: ITimerOptions<T>);
  49257. /**
  49258. * set a breaking condition for this timer. Default is to never break during count
  49259. * @param predicate the new break condition. Returns true to break, false otherwise
  49260. */
  49261. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49262. /**
  49263. * Reset ALL associated observables in this advanced timer
  49264. */
  49265. clearObservables(): void;
  49266. /**
  49267. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49268. *
  49269. * @param timeToEnd how much time to measure until timer ended
  49270. */
  49271. start(timeToEnd?: number): void;
  49272. /**
  49273. * Will force a stop on the next tick.
  49274. */
  49275. stop(): void;
  49276. /**
  49277. * Dispose this timer, clearing all resources
  49278. */
  49279. dispose(): void;
  49280. private _setState;
  49281. private _tick;
  49282. private _stop;
  49283. }
  49284. }
  49285. declare module BABYLON {
  49286. /**
  49287. * The options container for the teleportation module
  49288. */
  49289. export interface IWebXRTeleportationOptions {
  49290. /**
  49291. * if provided, this scene will be used to render meshes.
  49292. */
  49293. customUtilityLayerScene?: Scene;
  49294. /**
  49295. * Values to configure the default target mesh
  49296. */
  49297. defaultTargetMeshOptions?: {
  49298. /**
  49299. * Fill color of the teleportation area
  49300. */
  49301. teleportationFillColor?: string;
  49302. /**
  49303. * Border color for the teleportation area
  49304. */
  49305. teleportationBorderColor?: string;
  49306. /**
  49307. * Disable the mesh's animation sequence
  49308. */
  49309. disableAnimation?: boolean;
  49310. /**
  49311. * Disable lighting on the material or the ring and arrow
  49312. */
  49313. disableLighting?: boolean;
  49314. /**
  49315. * Override the default material of the torus and arrow
  49316. */
  49317. torusArrowMaterial?: Material;
  49318. };
  49319. /**
  49320. * A list of meshes to use as floor meshes.
  49321. * Meshes can be added and removed after initializing the feature using the
  49322. * addFloorMesh and removeFloorMesh functions
  49323. * If empty, rotation will still work
  49324. */
  49325. floorMeshes?: AbstractMesh[];
  49326. /**
  49327. * use this rendering group id for the meshes (optional)
  49328. */
  49329. renderingGroupId?: number;
  49330. /**
  49331. * Should teleportation move only to snap points
  49332. */
  49333. snapPointsOnly?: boolean;
  49334. /**
  49335. * An array of points to which the teleportation will snap to.
  49336. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49337. */
  49338. snapPositions?: Vector3[];
  49339. /**
  49340. * How close should the teleportation ray be in order to snap to position.
  49341. * Default to 0.8 units (meters)
  49342. */
  49343. snapToPositionRadius?: number;
  49344. /**
  49345. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49346. * If you want to support rotation, make sure your mesh has a direction indicator.
  49347. *
  49348. * When left untouched, the default mesh will be initialized.
  49349. */
  49350. teleportationTargetMesh?: AbstractMesh;
  49351. /**
  49352. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49353. */
  49354. timeToTeleport?: number;
  49355. /**
  49356. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49357. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49358. */
  49359. useMainComponentOnly?: boolean;
  49360. /**
  49361. * Should meshes created here be added to a utility layer or the main scene
  49362. */
  49363. useUtilityLayer?: boolean;
  49364. /**
  49365. * Babylon XR Input class for controller
  49366. */
  49367. xrInput: WebXRInput;
  49368. }
  49369. /**
  49370. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49371. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49372. * the input of the attached controllers.
  49373. */
  49374. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49375. private _options;
  49376. private _controllers;
  49377. private _currentTeleportationControllerId;
  49378. private _floorMeshes;
  49379. private _quadraticBezierCurve;
  49380. private _selectionFeature;
  49381. private _snapToPositions;
  49382. private _snappedToPoint;
  49383. private _teleportationRingMaterial?;
  49384. private _tmpRay;
  49385. private _tmpVector;
  49386. /**
  49387. * The module's name
  49388. */
  49389. static readonly Name: string;
  49390. /**
  49391. * The (Babylon) version of this module.
  49392. * This is an integer representing the implementation version.
  49393. * This number does not correspond to the webxr specs version
  49394. */
  49395. static readonly Version: number;
  49396. /**
  49397. * Is movement backwards enabled
  49398. */
  49399. backwardsMovementEnabled: boolean;
  49400. /**
  49401. * Distance to travel when moving backwards
  49402. */
  49403. backwardsTeleportationDistance: number;
  49404. /**
  49405. * The distance from the user to the inspection point in the direction of the controller
  49406. * A higher number will allow the user to move further
  49407. * defaults to 5 (meters, in xr units)
  49408. */
  49409. parabolicCheckRadius: number;
  49410. /**
  49411. * Should the module support parabolic ray on top of direct ray
  49412. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49413. * Very helpful when moving between floors / different heights
  49414. */
  49415. parabolicRayEnabled: boolean;
  49416. /**
  49417. * How much rotation should be applied when rotating right and left
  49418. */
  49419. rotationAngle: number;
  49420. /**
  49421. * Is rotation enabled when moving forward?
  49422. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49423. */
  49424. rotationEnabled: boolean;
  49425. /**
  49426. * constructs a new anchor system
  49427. * @param _xrSessionManager an instance of WebXRSessionManager
  49428. * @param _options configuration object for this feature
  49429. */
  49430. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49431. /**
  49432. * Get the snapPointsOnly flag
  49433. */
  49434. get snapPointsOnly(): boolean;
  49435. /**
  49436. * Sets the snapPointsOnly flag
  49437. * @param snapToPoints should teleportation be exclusively to snap points
  49438. */
  49439. set snapPointsOnly(snapToPoints: boolean);
  49440. /**
  49441. * Add a new mesh to the floor meshes array
  49442. * @param mesh the mesh to use as floor mesh
  49443. */
  49444. addFloorMesh(mesh: AbstractMesh): void;
  49445. /**
  49446. * Add a new snap-to point to fix teleportation to this position
  49447. * @param newSnapPoint The new Snap-To point
  49448. */
  49449. addSnapPoint(newSnapPoint: Vector3): void;
  49450. attach(): boolean;
  49451. detach(): boolean;
  49452. dispose(): void;
  49453. /**
  49454. * Remove a mesh from the floor meshes array
  49455. * @param mesh the mesh to remove
  49456. */
  49457. removeFloorMesh(mesh: AbstractMesh): void;
  49458. /**
  49459. * Remove a mesh from the floor meshes array using its name
  49460. * @param name the mesh name to remove
  49461. */
  49462. removeFloorMeshByName(name: string): void;
  49463. /**
  49464. * 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
  49465. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49466. * @returns was the point found and removed or not
  49467. */
  49468. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49469. /**
  49470. * This function sets a selection feature that will be disabled when
  49471. * the forward ray is shown and will be reattached when hidden.
  49472. * This is used to remove the selection rays when moving.
  49473. * @param selectionFeature the feature to disable when forward movement is enabled
  49474. */
  49475. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49476. protected _onXRFrame(_xrFrame: XRFrame): void;
  49477. private _attachController;
  49478. private _createDefaultTargetMesh;
  49479. private _detachController;
  49480. private _findClosestSnapPointWithRadius;
  49481. private _setTargetMeshPosition;
  49482. private _setTargetMeshVisibility;
  49483. private _showParabolicPath;
  49484. private _teleportForward;
  49485. }
  49486. }
  49487. declare module BABYLON {
  49488. /**
  49489. * Options for the default xr helper
  49490. */
  49491. export class WebXRDefaultExperienceOptions {
  49492. /**
  49493. * Enable or disable default UI to enter XR
  49494. */
  49495. disableDefaultUI?: boolean;
  49496. /**
  49497. * Should teleportation not initialize. defaults to false.
  49498. */
  49499. disableTeleportation?: boolean;
  49500. /**
  49501. * Floor meshes that will be used for teleport
  49502. */
  49503. floorMeshes?: Array<AbstractMesh>;
  49504. /**
  49505. * If set to true, the first frame will not be used to reset position
  49506. * The first frame is mainly used when copying transformation from the old camera
  49507. * Mainly used in AR
  49508. */
  49509. ignoreNativeCameraTransformation?: boolean;
  49510. /**
  49511. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49512. */
  49513. inputOptions?: IWebXRInputOptions;
  49514. /**
  49515. * optional configuration for the output canvas
  49516. */
  49517. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49518. /**
  49519. * optional UI options. This can be used among other to change session mode and reference space type
  49520. */
  49521. uiOptions?: WebXREnterExitUIOptions;
  49522. /**
  49523. * When loading teleportation and pointer select, use stable versions instead of latest.
  49524. */
  49525. useStablePlugins?: boolean;
  49526. /**
  49527. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49528. */
  49529. renderingGroupId?: number;
  49530. /**
  49531. * A list of optional features to init the session with
  49532. * If set to true, all features we support will be added
  49533. */
  49534. optionalFeatures?: boolean | string[];
  49535. }
  49536. /**
  49537. * Default experience which provides a similar setup to the previous webVRExperience
  49538. */
  49539. export class WebXRDefaultExperience {
  49540. /**
  49541. * Base experience
  49542. */
  49543. baseExperience: WebXRExperienceHelper;
  49544. /**
  49545. * Enables ui for entering/exiting xr
  49546. */
  49547. enterExitUI: WebXREnterExitUI;
  49548. /**
  49549. * Input experience extension
  49550. */
  49551. input: WebXRInput;
  49552. /**
  49553. * Enables laser pointer and selection
  49554. */
  49555. pointerSelection: WebXRControllerPointerSelection;
  49556. /**
  49557. * Default target xr should render to
  49558. */
  49559. renderTarget: WebXRRenderTarget;
  49560. /**
  49561. * Enables teleportation
  49562. */
  49563. teleportation: WebXRMotionControllerTeleportation;
  49564. private constructor();
  49565. /**
  49566. * Creates the default xr experience
  49567. * @param scene scene
  49568. * @param options options for basic configuration
  49569. * @returns resulting WebXRDefaultExperience
  49570. */
  49571. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49572. /**
  49573. * DIsposes of the experience helper
  49574. */
  49575. dispose(): void;
  49576. }
  49577. }
  49578. declare module BABYLON {
  49579. /**
  49580. * Options to modify the vr teleportation behavior.
  49581. */
  49582. export interface VRTeleportationOptions {
  49583. /**
  49584. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49585. */
  49586. floorMeshName?: string;
  49587. /**
  49588. * A list of meshes to be used as the teleportation floor. (default: empty)
  49589. */
  49590. floorMeshes?: Mesh[];
  49591. /**
  49592. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49593. */
  49594. teleportationMode?: number;
  49595. /**
  49596. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49597. */
  49598. teleportationTime?: number;
  49599. /**
  49600. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49601. */
  49602. teleportationSpeed?: number;
  49603. /**
  49604. * The easing function used in the animation or null for Linear. (default CircleEase)
  49605. */
  49606. easingFunction?: EasingFunction;
  49607. }
  49608. /**
  49609. * Options to modify the vr experience helper's behavior.
  49610. */
  49611. export interface VRExperienceHelperOptions extends WebVROptions {
  49612. /**
  49613. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49614. */
  49615. createDeviceOrientationCamera?: boolean;
  49616. /**
  49617. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49618. */
  49619. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49620. /**
  49621. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49622. */
  49623. laserToggle?: boolean;
  49624. /**
  49625. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49626. */
  49627. floorMeshes?: Mesh[];
  49628. /**
  49629. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49630. */
  49631. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49632. /**
  49633. * Defines if WebXR should be used instead of WebVR (if available)
  49634. */
  49635. useXR?: boolean;
  49636. }
  49637. /**
  49638. * Event containing information after VR has been entered
  49639. */
  49640. export class OnAfterEnteringVRObservableEvent {
  49641. /**
  49642. * If entering vr was successful
  49643. */
  49644. success: boolean;
  49645. }
  49646. /**
  49647. * Helps to quickly add VR support to an existing scene.
  49648. * See https://doc.babylonjs.com/how_to/webvr_helper
  49649. */
  49650. export class VRExperienceHelper {
  49651. /** Options to modify the vr experience helper's behavior. */
  49652. webVROptions: VRExperienceHelperOptions;
  49653. private _scene;
  49654. private _position;
  49655. private _btnVR;
  49656. private _btnVRDisplayed;
  49657. private _webVRsupported;
  49658. private _webVRready;
  49659. private _webVRrequesting;
  49660. private _webVRpresenting;
  49661. private _hasEnteredVR;
  49662. private _fullscreenVRpresenting;
  49663. private _inputElement;
  49664. private _webVRCamera;
  49665. private _vrDeviceOrientationCamera;
  49666. private _deviceOrientationCamera;
  49667. private _existingCamera;
  49668. private _onKeyDown;
  49669. private _onVrDisplayPresentChange;
  49670. private _onVRDisplayChanged;
  49671. private _onVRRequestPresentStart;
  49672. private _onVRRequestPresentComplete;
  49673. /**
  49674. * 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)
  49675. */
  49676. enableGazeEvenWhenNoPointerLock: boolean;
  49677. /**
  49678. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49679. */
  49680. exitVROnDoubleTap: boolean;
  49681. /**
  49682. * Observable raised right before entering VR.
  49683. */
  49684. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49685. /**
  49686. * Observable raised when entering VR has completed.
  49687. */
  49688. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49689. /**
  49690. * Observable raised when exiting VR.
  49691. */
  49692. onExitingVRObservable: Observable<VRExperienceHelper>;
  49693. /**
  49694. * Observable raised when controller mesh is loaded.
  49695. */
  49696. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49697. /** Return this.onEnteringVRObservable
  49698. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49699. */
  49700. get onEnteringVR(): Observable<VRExperienceHelper>;
  49701. /** Return this.onExitingVRObservable
  49702. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49703. */
  49704. get onExitingVR(): Observable<VRExperienceHelper>;
  49705. /** Return this.onControllerMeshLoadedObservable
  49706. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49707. */
  49708. get onControllerMeshLoaded(): Observable<WebVRController>;
  49709. private _rayLength;
  49710. private _useCustomVRButton;
  49711. private _teleportationRequested;
  49712. private _teleportActive;
  49713. private _floorMeshName;
  49714. private _floorMeshesCollection;
  49715. private _teleportationMode;
  49716. private _teleportationTime;
  49717. private _teleportationSpeed;
  49718. private _teleportationEasing;
  49719. private _rotationAllowed;
  49720. private _teleportBackwardsVector;
  49721. private _teleportationTarget;
  49722. private _isDefaultTeleportationTarget;
  49723. private _postProcessMove;
  49724. private _teleportationFillColor;
  49725. private _teleportationBorderColor;
  49726. private _rotationAngle;
  49727. private _haloCenter;
  49728. private _cameraGazer;
  49729. private _padSensibilityUp;
  49730. private _padSensibilityDown;
  49731. private _leftController;
  49732. private _rightController;
  49733. private _gazeColor;
  49734. private _laserColor;
  49735. private _pickedLaserColor;
  49736. private _pickedGazeColor;
  49737. /**
  49738. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49739. */
  49740. onNewMeshSelected: Observable<AbstractMesh>;
  49741. /**
  49742. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49743. * This observable will provide the mesh and the controller used to select the mesh
  49744. */
  49745. onMeshSelectedWithController: Observable<{
  49746. mesh: AbstractMesh;
  49747. controller: WebVRController;
  49748. }>;
  49749. /**
  49750. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49751. */
  49752. onNewMeshPicked: Observable<PickingInfo>;
  49753. private _circleEase;
  49754. /**
  49755. * Observable raised before camera teleportation
  49756. */
  49757. onBeforeCameraTeleport: Observable<Vector3>;
  49758. /**
  49759. * Observable raised after camera teleportation
  49760. */
  49761. onAfterCameraTeleport: Observable<Vector3>;
  49762. /**
  49763. * Observable raised when current selected mesh gets unselected
  49764. */
  49765. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49766. private _raySelectionPredicate;
  49767. /**
  49768. * To be optionaly changed by user to define custom ray selection
  49769. */
  49770. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49771. /**
  49772. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49773. */
  49774. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49775. /**
  49776. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49777. */
  49778. teleportationEnabled: boolean;
  49779. private _defaultHeight;
  49780. private _teleportationInitialized;
  49781. private _interactionsEnabled;
  49782. private _interactionsRequested;
  49783. private _displayGaze;
  49784. private _displayLaserPointer;
  49785. /**
  49786. * The mesh used to display where the user is going to teleport.
  49787. */
  49788. get teleportationTarget(): Mesh;
  49789. /**
  49790. * Sets the mesh to be used to display where the user is going to teleport.
  49791. */
  49792. set teleportationTarget(value: Mesh);
  49793. /**
  49794. * 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
  49795. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49796. * See https://doc.babylonjs.com/resources/baking_transformations
  49797. */
  49798. get gazeTrackerMesh(): Mesh;
  49799. set gazeTrackerMesh(value: Mesh);
  49800. /**
  49801. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49802. */
  49803. updateGazeTrackerScale: boolean;
  49804. /**
  49805. * If the gaze trackers color should be updated when selecting meshes
  49806. */
  49807. updateGazeTrackerColor: boolean;
  49808. /**
  49809. * If the controller laser color should be updated when selecting meshes
  49810. */
  49811. updateControllerLaserColor: boolean;
  49812. /**
  49813. * The gaze tracking mesh corresponding to the left controller
  49814. */
  49815. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49816. /**
  49817. * The gaze tracking mesh corresponding to the right controller
  49818. */
  49819. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49820. /**
  49821. * If the ray of the gaze should be displayed.
  49822. */
  49823. get displayGaze(): boolean;
  49824. /**
  49825. * Sets if the ray of the gaze should be displayed.
  49826. */
  49827. set displayGaze(value: boolean);
  49828. /**
  49829. * If the ray of the LaserPointer should be displayed.
  49830. */
  49831. get displayLaserPointer(): boolean;
  49832. /**
  49833. * Sets if the ray of the LaserPointer should be displayed.
  49834. */
  49835. set displayLaserPointer(value: boolean);
  49836. /**
  49837. * The deviceOrientationCamera used as the camera when not in VR.
  49838. */
  49839. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49840. /**
  49841. * Based on the current WebVR support, returns the current VR camera used.
  49842. */
  49843. get currentVRCamera(): Nullable<Camera>;
  49844. /**
  49845. * The webVRCamera which is used when in VR.
  49846. */
  49847. get webVRCamera(): WebVRFreeCamera;
  49848. /**
  49849. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49850. */
  49851. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49852. /**
  49853. * The html button that is used to trigger entering into VR.
  49854. */
  49855. get vrButton(): Nullable<HTMLButtonElement>;
  49856. private get _teleportationRequestInitiated();
  49857. /**
  49858. * Defines whether or not Pointer lock should be requested when switching to
  49859. * full screen.
  49860. */
  49861. requestPointerLockOnFullScreen: boolean;
  49862. /**
  49863. * If asking to force XR, this will be populated with the default xr experience
  49864. */
  49865. xr: WebXRDefaultExperience;
  49866. /**
  49867. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49868. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49869. */
  49870. xrTestDone: boolean;
  49871. /**
  49872. * Instantiates a VRExperienceHelper.
  49873. * Helps to quickly add VR support to an existing scene.
  49874. * @param scene The scene the VRExperienceHelper belongs to.
  49875. * @param webVROptions Options to modify the vr experience helper's behavior.
  49876. */
  49877. constructor(scene: Scene,
  49878. /** Options to modify the vr experience helper's behavior. */
  49879. webVROptions?: VRExperienceHelperOptions);
  49880. private completeVRInit;
  49881. private _onDefaultMeshLoaded;
  49882. private _onResize;
  49883. private _onFullscreenChange;
  49884. /**
  49885. * Gets a value indicating if we are currently in VR mode.
  49886. */
  49887. get isInVRMode(): boolean;
  49888. private onVrDisplayPresentChange;
  49889. private onVRDisplayChanged;
  49890. private moveButtonToBottomRight;
  49891. private displayVRButton;
  49892. private updateButtonVisibility;
  49893. private _cachedAngularSensibility;
  49894. /**
  49895. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49896. * Otherwise, will use the fullscreen API.
  49897. */
  49898. enterVR(): void;
  49899. /**
  49900. * Attempt to exit VR, or fullscreen.
  49901. */
  49902. exitVR(): void;
  49903. /**
  49904. * The position of the vr experience helper.
  49905. */
  49906. get position(): Vector3;
  49907. /**
  49908. * Sets the position of the vr experience helper.
  49909. */
  49910. set position(value: Vector3);
  49911. /**
  49912. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49913. */
  49914. enableInteractions(): void;
  49915. private get _noControllerIsActive();
  49916. private beforeRender;
  49917. private _isTeleportationFloor;
  49918. /**
  49919. * Adds a floor mesh to be used for teleportation.
  49920. * @param floorMesh the mesh to be used for teleportation.
  49921. */
  49922. addFloorMesh(floorMesh: Mesh): void;
  49923. /**
  49924. * Removes a floor mesh from being used for teleportation.
  49925. * @param floorMesh the mesh to be removed.
  49926. */
  49927. removeFloorMesh(floorMesh: Mesh): void;
  49928. /**
  49929. * Enables interactions and teleportation using the VR controllers and gaze.
  49930. * @param vrTeleportationOptions options to modify teleportation behavior.
  49931. */
  49932. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49933. private _onNewGamepadConnected;
  49934. private _tryEnableInteractionOnController;
  49935. private _onNewGamepadDisconnected;
  49936. private _enableInteractionOnController;
  49937. private _checkTeleportWithRay;
  49938. private _checkRotate;
  49939. private _checkTeleportBackwards;
  49940. private _enableTeleportationOnController;
  49941. private _createTeleportationCircles;
  49942. private _displayTeleportationTarget;
  49943. private _hideTeleportationTarget;
  49944. private _rotateCamera;
  49945. private _moveTeleportationSelectorTo;
  49946. private _workingVector;
  49947. private _workingQuaternion;
  49948. private _workingMatrix;
  49949. /**
  49950. * Time Constant Teleportation Mode
  49951. */
  49952. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49953. /**
  49954. * Speed Constant Teleportation Mode
  49955. */
  49956. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49957. /**
  49958. * Teleports the users feet to the desired location
  49959. * @param location The location where the user's feet should be placed
  49960. */
  49961. teleportCamera(location: Vector3): void;
  49962. private _convertNormalToDirectionOfRay;
  49963. private _castRayAndSelectObject;
  49964. private _notifySelectedMeshUnselected;
  49965. /**
  49966. * Permanently set new colors for the laser pointer
  49967. * @param color the new laser color
  49968. * @param pickedColor the new laser color when picked mesh detected
  49969. */
  49970. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49971. /**
  49972. * Set lighting enabled / disabled on the laser pointer of both controllers
  49973. * @param enabled should the lighting be enabled on the laser pointer
  49974. */
  49975. setLaserLightingState(enabled?: boolean): void;
  49976. /**
  49977. * Permanently set new colors for the gaze pointer
  49978. * @param color the new gaze color
  49979. * @param pickedColor the new gaze color when picked mesh detected
  49980. */
  49981. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49982. /**
  49983. * Sets the color of the laser ray from the vr controllers.
  49984. * @param color new color for the ray.
  49985. */
  49986. changeLaserColor(color: Color3): void;
  49987. /**
  49988. * Sets the color of the ray from the vr headsets gaze.
  49989. * @param color new color for the ray.
  49990. */
  49991. changeGazeColor(color: Color3): void;
  49992. /**
  49993. * Exits VR and disposes of the vr experience helper
  49994. */
  49995. dispose(): void;
  49996. /**
  49997. * Gets the name of the VRExperienceHelper class
  49998. * @returns "VRExperienceHelper"
  49999. */
  50000. getClassName(): string;
  50001. }
  50002. }
  50003. declare module BABYLON {
  50004. /**
  50005. * Contains an array of blocks representing the octree
  50006. */
  50007. export interface IOctreeContainer<T> {
  50008. /**
  50009. * Blocks within the octree
  50010. */
  50011. blocks: Array<OctreeBlock<T>>;
  50012. }
  50013. /**
  50014. * Class used to store a cell in an octree
  50015. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50016. */
  50017. export class OctreeBlock<T> {
  50018. /**
  50019. * Gets the content of the current block
  50020. */
  50021. entries: T[];
  50022. /**
  50023. * Gets the list of block children
  50024. */
  50025. blocks: Array<OctreeBlock<T>>;
  50026. private _depth;
  50027. private _maxDepth;
  50028. private _capacity;
  50029. private _minPoint;
  50030. private _maxPoint;
  50031. private _boundingVectors;
  50032. private _creationFunc;
  50033. /**
  50034. * Creates a new block
  50035. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50036. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50037. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50038. * @param depth defines the current depth of this block in the octree
  50039. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50040. * @param creationFunc defines a callback to call when an element is added to the block
  50041. */
  50042. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50043. /**
  50044. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50045. */
  50046. get capacity(): number;
  50047. /**
  50048. * Gets the minimum vector (in world space) of the block's bounding box
  50049. */
  50050. get minPoint(): Vector3;
  50051. /**
  50052. * Gets the maximum vector (in world space) of the block's bounding box
  50053. */
  50054. get maxPoint(): Vector3;
  50055. /**
  50056. * Add a new element to this block
  50057. * @param entry defines the element to add
  50058. */
  50059. addEntry(entry: T): void;
  50060. /**
  50061. * Remove an element from this block
  50062. * @param entry defines the element to remove
  50063. */
  50064. removeEntry(entry: T): void;
  50065. /**
  50066. * Add an array of elements to this block
  50067. * @param entries defines the array of elements to add
  50068. */
  50069. addEntries(entries: T[]): void;
  50070. /**
  50071. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50072. * @param frustumPlanes defines the frustum planes to test
  50073. * @param selection defines the array to store current content if selection is positive
  50074. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50075. */
  50076. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50077. /**
  50078. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50079. * @param sphereCenter defines the bounding sphere center
  50080. * @param sphereRadius defines the bounding sphere radius
  50081. * @param selection defines the array to store current content if selection is positive
  50082. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50083. */
  50084. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50085. /**
  50086. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50087. * @param ray defines the ray to test with
  50088. * @param selection defines the array to store current content if selection is positive
  50089. */
  50090. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50091. /**
  50092. * Subdivide the content into child blocks (this block will then be empty)
  50093. */
  50094. createInnerBlocks(): void;
  50095. /**
  50096. * @hidden
  50097. */
  50098. 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;
  50099. }
  50100. }
  50101. declare module BABYLON {
  50102. /**
  50103. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50104. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50105. */
  50106. export class Octree<T> {
  50107. /** 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.) */
  50108. maxDepth: number;
  50109. /**
  50110. * Blocks within the octree containing objects
  50111. */
  50112. blocks: Array<OctreeBlock<T>>;
  50113. /**
  50114. * Content stored in the octree
  50115. */
  50116. dynamicContent: T[];
  50117. private _maxBlockCapacity;
  50118. private _selectionContent;
  50119. private _creationFunc;
  50120. /**
  50121. * Creates a octree
  50122. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50123. * @param creationFunc function to be used to instatiate the octree
  50124. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50125. * @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.)
  50126. */
  50127. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50128. /** 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.) */
  50129. maxDepth?: number);
  50130. /**
  50131. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50132. * @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);
  50133. * @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);
  50134. * @param entries meshes to be added to the octree blocks
  50135. */
  50136. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50137. /**
  50138. * Adds a mesh to the octree
  50139. * @param entry Mesh to add to the octree
  50140. */
  50141. addMesh(entry: T): void;
  50142. /**
  50143. * Remove an element from the octree
  50144. * @param entry defines the element to remove
  50145. */
  50146. removeMesh(entry: T): void;
  50147. /**
  50148. * Selects an array of meshes within the frustum
  50149. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50150. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50151. * @returns array of meshes within the frustum
  50152. */
  50153. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50154. /**
  50155. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50156. * @param sphereCenter defines the bounding sphere center
  50157. * @param sphereRadius defines the bounding sphere radius
  50158. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50159. * @returns an array of objects that intersect the sphere
  50160. */
  50161. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50162. /**
  50163. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50164. * @param ray defines the ray to test with
  50165. * @returns array of intersected objects
  50166. */
  50167. intersectsRay(ray: Ray): SmartArray<T>;
  50168. /**
  50169. * Adds a mesh into the octree block if it intersects the block
  50170. */
  50171. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50172. /**
  50173. * Adds a submesh into the octree block if it intersects the block
  50174. */
  50175. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50176. }
  50177. }
  50178. declare module BABYLON {
  50179. interface Scene {
  50180. /**
  50181. * @hidden
  50182. * Backing Filed
  50183. */
  50184. _selectionOctree: Octree<AbstractMesh>;
  50185. /**
  50186. * Gets the octree used to boost mesh selection (picking)
  50187. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50188. */
  50189. selectionOctree: Octree<AbstractMesh>;
  50190. /**
  50191. * Creates or updates the octree used to boost selection (picking)
  50192. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50193. * @param maxCapacity defines the maximum capacity per leaf
  50194. * @param maxDepth defines the maximum depth of the octree
  50195. * @returns an octree of AbstractMesh
  50196. */
  50197. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50198. }
  50199. interface AbstractMesh {
  50200. /**
  50201. * @hidden
  50202. * Backing Field
  50203. */
  50204. _submeshesOctree: Octree<SubMesh>;
  50205. /**
  50206. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50207. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50208. * @param maxCapacity defines the maximum size of each block (64 by default)
  50209. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50210. * @returns the new octree
  50211. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50212. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50213. */
  50214. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50215. }
  50216. /**
  50217. * Defines the octree scene component responsible to manage any octrees
  50218. * in a given scene.
  50219. */
  50220. export class OctreeSceneComponent {
  50221. /**
  50222. * The component name help to identify the component in the list of scene components.
  50223. */
  50224. readonly name: string;
  50225. /**
  50226. * The scene the component belongs to.
  50227. */
  50228. scene: Scene;
  50229. /**
  50230. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50231. */
  50232. readonly checksIsEnabled: boolean;
  50233. /**
  50234. * Creates a new instance of the component for the given scene
  50235. * @param scene Defines the scene to register the component in
  50236. */
  50237. constructor(scene: Scene);
  50238. /**
  50239. * Registers the component in a given scene
  50240. */
  50241. register(): void;
  50242. /**
  50243. * Return the list of active meshes
  50244. * @returns the list of active meshes
  50245. */
  50246. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50247. /**
  50248. * Return the list of active sub meshes
  50249. * @param mesh The mesh to get the candidates sub meshes from
  50250. * @returns the list of active sub meshes
  50251. */
  50252. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50253. private _tempRay;
  50254. /**
  50255. * Return the list of sub meshes intersecting with a given local ray
  50256. * @param mesh defines the mesh to find the submesh for
  50257. * @param localRay defines the ray in local space
  50258. * @returns the list of intersecting sub meshes
  50259. */
  50260. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50261. /**
  50262. * Return the list of sub meshes colliding with a collider
  50263. * @param mesh defines the mesh to find the submesh for
  50264. * @param collider defines the collider to evaluate the collision against
  50265. * @returns the list of colliding sub meshes
  50266. */
  50267. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50268. /**
  50269. * Rebuilds the elements related to this component in case of
  50270. * context lost for instance.
  50271. */
  50272. rebuild(): void;
  50273. /**
  50274. * Disposes the component and the associated ressources.
  50275. */
  50276. dispose(): void;
  50277. }
  50278. }
  50279. declare module BABYLON {
  50280. /**
  50281. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50282. */
  50283. export class Gizmo implements IDisposable {
  50284. /** The utility layer the gizmo will be added to */
  50285. gizmoLayer: UtilityLayerRenderer;
  50286. /**
  50287. * The root mesh of the gizmo
  50288. */
  50289. _rootMesh: Mesh;
  50290. private _attachedMesh;
  50291. private _attachedNode;
  50292. /**
  50293. * Ratio for the scale of the gizmo (Default: 1)
  50294. */
  50295. protected _scaleRatio: number;
  50296. /**
  50297. * Ratio for the scale of the gizmo (Default: 1)
  50298. */
  50299. set scaleRatio(value: number);
  50300. get scaleRatio(): number;
  50301. /**
  50302. * If a custom mesh has been set (Default: false)
  50303. */
  50304. protected _customMeshSet: boolean;
  50305. /**
  50306. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50307. * * When set, interactions will be enabled
  50308. */
  50309. get attachedMesh(): Nullable<AbstractMesh>;
  50310. set attachedMesh(value: Nullable<AbstractMesh>);
  50311. /**
  50312. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50313. * * When set, interactions will be enabled
  50314. */
  50315. get attachedNode(): Nullable<Node>;
  50316. set attachedNode(value: Nullable<Node>);
  50317. /**
  50318. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50319. * @param mesh The mesh to replace the default mesh of the gizmo
  50320. */
  50321. setCustomMesh(mesh: Mesh): void;
  50322. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50323. /**
  50324. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50325. */
  50326. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50327. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50328. /**
  50329. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50330. */
  50331. updateGizmoPositionToMatchAttachedMesh: boolean;
  50332. /**
  50333. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50334. */
  50335. updateScale: boolean;
  50336. protected _interactionsEnabled: boolean;
  50337. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50338. private _beforeRenderObserver;
  50339. private _tempQuaternion;
  50340. private _tempVector;
  50341. private _tempVector2;
  50342. /**
  50343. * Creates a gizmo
  50344. * @param gizmoLayer The utility layer the gizmo will be added to
  50345. */
  50346. constructor(
  50347. /** The utility layer the gizmo will be added to */
  50348. gizmoLayer?: UtilityLayerRenderer);
  50349. /**
  50350. * Updates the gizmo to match the attached mesh's position/rotation
  50351. */
  50352. protected _update(): void;
  50353. /**
  50354. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50355. * @param value Node, TransformNode or mesh
  50356. */
  50357. protected _matrixChanged(): void;
  50358. /**
  50359. * Disposes of the gizmo
  50360. */
  50361. dispose(): void;
  50362. }
  50363. }
  50364. declare module BABYLON {
  50365. /**
  50366. * Single plane drag gizmo
  50367. */
  50368. export class PlaneDragGizmo extends Gizmo {
  50369. /**
  50370. * Drag behavior responsible for the gizmos dragging interactions
  50371. */
  50372. dragBehavior: PointerDragBehavior;
  50373. private _pointerObserver;
  50374. /**
  50375. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50376. */
  50377. snapDistance: number;
  50378. /**
  50379. * Event that fires each time the gizmo snaps to a new location.
  50380. * * snapDistance is the the change in distance
  50381. */
  50382. onSnapObservable: Observable<{
  50383. snapDistance: number;
  50384. }>;
  50385. private _plane;
  50386. private _coloredMaterial;
  50387. private _hoverMaterial;
  50388. private _isEnabled;
  50389. private _parent;
  50390. /** @hidden */
  50391. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50392. /** @hidden */
  50393. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50394. /**
  50395. * Creates a PlaneDragGizmo
  50396. * @param gizmoLayer The utility layer the gizmo will be added to
  50397. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50398. * @param color The color of the gizmo
  50399. */
  50400. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50401. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50402. /**
  50403. * If the gizmo is enabled
  50404. */
  50405. set isEnabled(value: boolean);
  50406. get isEnabled(): boolean;
  50407. /**
  50408. * Disposes of the gizmo
  50409. */
  50410. dispose(): void;
  50411. }
  50412. }
  50413. declare module BABYLON {
  50414. /**
  50415. * Gizmo that enables dragging a mesh along 3 axis
  50416. */
  50417. export class PositionGizmo extends Gizmo {
  50418. /**
  50419. * Internal gizmo used for interactions on the x axis
  50420. */
  50421. xGizmo: AxisDragGizmo;
  50422. /**
  50423. * Internal gizmo used for interactions on the y axis
  50424. */
  50425. yGizmo: AxisDragGizmo;
  50426. /**
  50427. * Internal gizmo used for interactions on the z axis
  50428. */
  50429. zGizmo: AxisDragGizmo;
  50430. /**
  50431. * Internal gizmo used for interactions on the yz plane
  50432. */
  50433. xPlaneGizmo: PlaneDragGizmo;
  50434. /**
  50435. * Internal gizmo used for interactions on the xz plane
  50436. */
  50437. yPlaneGizmo: PlaneDragGizmo;
  50438. /**
  50439. * Internal gizmo used for interactions on the xy plane
  50440. */
  50441. zPlaneGizmo: PlaneDragGizmo;
  50442. /**
  50443. * private variables
  50444. */
  50445. private _meshAttached;
  50446. private _nodeAttached;
  50447. private _snapDistance;
  50448. /** Fires an event when any of it's sub gizmos are dragged */
  50449. onDragStartObservable: Observable<unknown>;
  50450. /** Fires an event when any of it's sub gizmos are released from dragging */
  50451. onDragEndObservable: Observable<unknown>;
  50452. /**
  50453. * If set to true, planar drag is enabled
  50454. */
  50455. private _planarGizmoEnabled;
  50456. get attachedMesh(): Nullable<AbstractMesh>;
  50457. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50458. get attachedNode(): Nullable<Node>;
  50459. set attachedNode(node: Nullable<Node>);
  50460. /**
  50461. * Creates a PositionGizmo
  50462. * @param gizmoLayer The utility layer the gizmo will be added to
  50463. @param thickness display gizmo axis thickness
  50464. */
  50465. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50466. /**
  50467. * If the planar drag gizmo is enabled
  50468. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50469. */
  50470. set planarGizmoEnabled(value: boolean);
  50471. get planarGizmoEnabled(): boolean;
  50472. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50473. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50474. /**
  50475. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50476. */
  50477. set snapDistance(value: number);
  50478. get snapDistance(): number;
  50479. /**
  50480. * Ratio for the scale of the gizmo (Default: 1)
  50481. */
  50482. set scaleRatio(value: number);
  50483. get scaleRatio(): number;
  50484. /**
  50485. * Disposes of the gizmo
  50486. */
  50487. dispose(): void;
  50488. /**
  50489. * CustomMeshes are not supported by this gizmo
  50490. * @param mesh The mesh to replace the default mesh of the gizmo
  50491. */
  50492. setCustomMesh(mesh: Mesh): void;
  50493. }
  50494. }
  50495. declare module BABYLON {
  50496. /**
  50497. * Single axis drag gizmo
  50498. */
  50499. export class AxisDragGizmo extends Gizmo {
  50500. /**
  50501. * Drag behavior responsible for the gizmos dragging interactions
  50502. */
  50503. dragBehavior: PointerDragBehavior;
  50504. private _pointerObserver;
  50505. /**
  50506. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50507. */
  50508. snapDistance: number;
  50509. /**
  50510. * Event that fires each time the gizmo snaps to a new location.
  50511. * * snapDistance is the the change in distance
  50512. */
  50513. onSnapObservable: Observable<{
  50514. snapDistance: number;
  50515. }>;
  50516. private _isEnabled;
  50517. private _parent;
  50518. private _arrow;
  50519. private _coloredMaterial;
  50520. private _hoverMaterial;
  50521. /** @hidden */
  50522. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50523. /** @hidden */
  50524. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50525. /**
  50526. * Creates an AxisDragGizmo
  50527. * @param gizmoLayer The utility layer the gizmo will be added to
  50528. * @param dragAxis The axis which the gizmo will be able to drag on
  50529. * @param color The color of the gizmo
  50530. * @param thickness display gizmo axis thickness
  50531. */
  50532. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50533. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50534. /**
  50535. * If the gizmo is enabled
  50536. */
  50537. set isEnabled(value: boolean);
  50538. get isEnabled(): boolean;
  50539. /**
  50540. * Disposes of the gizmo
  50541. */
  50542. dispose(): void;
  50543. }
  50544. }
  50545. declare module BABYLON.Debug {
  50546. /**
  50547. * The Axes viewer will show 3 axes in a specific point in space
  50548. */
  50549. export class AxesViewer {
  50550. private _xAxis;
  50551. private _yAxis;
  50552. private _zAxis;
  50553. private _scaleLinesFactor;
  50554. private _instanced;
  50555. /**
  50556. * Gets the hosting scene
  50557. */
  50558. scene: Nullable<Scene>;
  50559. /**
  50560. * Gets or sets a number used to scale line length
  50561. */
  50562. scaleLines: number;
  50563. /** Gets the node hierarchy used to render x-axis */
  50564. get xAxis(): TransformNode;
  50565. /** Gets the node hierarchy used to render y-axis */
  50566. get yAxis(): TransformNode;
  50567. /** Gets the node hierarchy used to render z-axis */
  50568. get zAxis(): TransformNode;
  50569. /**
  50570. * Creates a new AxesViewer
  50571. * @param scene defines the hosting scene
  50572. * @param scaleLines defines a number used to scale line length (1 by default)
  50573. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50574. * @param xAxis defines the node hierarchy used to render the x-axis
  50575. * @param yAxis defines the node hierarchy used to render the y-axis
  50576. * @param zAxis defines the node hierarchy used to render the z-axis
  50577. */
  50578. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50579. /**
  50580. * Force the viewer to update
  50581. * @param position defines the position of the viewer
  50582. * @param xaxis defines the x axis of the viewer
  50583. * @param yaxis defines the y axis of the viewer
  50584. * @param zaxis defines the z axis of the viewer
  50585. */
  50586. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50587. /**
  50588. * Creates an instance of this axes viewer.
  50589. * @returns a new axes viewer with instanced meshes
  50590. */
  50591. createInstance(): AxesViewer;
  50592. /** Releases resources */
  50593. dispose(): void;
  50594. private static _SetRenderingGroupId;
  50595. }
  50596. }
  50597. declare module BABYLON.Debug {
  50598. /**
  50599. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50600. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50601. */
  50602. export class BoneAxesViewer extends AxesViewer {
  50603. /**
  50604. * Gets or sets the target mesh where to display the axes viewer
  50605. */
  50606. mesh: Nullable<Mesh>;
  50607. /**
  50608. * Gets or sets the target bone where to display the axes viewer
  50609. */
  50610. bone: Nullable<Bone>;
  50611. /** Gets current position */
  50612. pos: Vector3;
  50613. /** Gets direction of X axis */
  50614. xaxis: Vector3;
  50615. /** Gets direction of Y axis */
  50616. yaxis: Vector3;
  50617. /** Gets direction of Z axis */
  50618. zaxis: Vector3;
  50619. /**
  50620. * Creates a new BoneAxesViewer
  50621. * @param scene defines the hosting scene
  50622. * @param bone defines the target bone
  50623. * @param mesh defines the target mesh
  50624. * @param scaleLines defines a scaling factor for line length (1 by default)
  50625. */
  50626. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50627. /**
  50628. * Force the viewer to update
  50629. */
  50630. update(): void;
  50631. /** Releases resources */
  50632. dispose(): void;
  50633. }
  50634. }
  50635. declare module BABYLON {
  50636. /**
  50637. * Interface used to define scene explorer extensibility option
  50638. */
  50639. export interface IExplorerExtensibilityOption {
  50640. /**
  50641. * Define the option label
  50642. */
  50643. label: string;
  50644. /**
  50645. * Defines the action to execute on click
  50646. */
  50647. action: (entity: any) => void;
  50648. }
  50649. /**
  50650. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50651. */
  50652. export interface IExplorerExtensibilityGroup {
  50653. /**
  50654. * Defines a predicate to test if a given type mut be extended
  50655. */
  50656. predicate: (entity: any) => boolean;
  50657. /**
  50658. * Gets the list of options added to a type
  50659. */
  50660. entries: IExplorerExtensibilityOption[];
  50661. }
  50662. /**
  50663. * Interface used to define the options to use to create the Inspector
  50664. */
  50665. export interface IInspectorOptions {
  50666. /**
  50667. * Display in overlay mode (default: false)
  50668. */
  50669. overlay?: boolean;
  50670. /**
  50671. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50672. */
  50673. globalRoot?: HTMLElement;
  50674. /**
  50675. * Display the Scene explorer
  50676. */
  50677. showExplorer?: boolean;
  50678. /**
  50679. * Display the property inspector
  50680. */
  50681. showInspector?: boolean;
  50682. /**
  50683. * Display in embed mode (both panes on the right)
  50684. */
  50685. embedMode?: boolean;
  50686. /**
  50687. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50688. */
  50689. handleResize?: boolean;
  50690. /**
  50691. * Allow the panes to popup (default: true)
  50692. */
  50693. enablePopup?: boolean;
  50694. /**
  50695. * Allow the panes to be closed by users (default: true)
  50696. */
  50697. enableClose?: boolean;
  50698. /**
  50699. * Optional list of extensibility entries
  50700. */
  50701. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50702. /**
  50703. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50704. */
  50705. inspectorURL?: string;
  50706. /**
  50707. * Optional initial tab (default to DebugLayerTab.Properties)
  50708. */
  50709. initialTab?: DebugLayerTab;
  50710. }
  50711. interface Scene {
  50712. /**
  50713. * @hidden
  50714. * Backing field
  50715. */
  50716. _debugLayer: DebugLayer;
  50717. /**
  50718. * Gets the debug layer (aka Inspector) associated with the scene
  50719. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50720. */
  50721. debugLayer: DebugLayer;
  50722. }
  50723. /**
  50724. * Enum of inspector action tab
  50725. */
  50726. export enum DebugLayerTab {
  50727. /**
  50728. * Properties tag (default)
  50729. */
  50730. Properties = 0,
  50731. /**
  50732. * Debug tab
  50733. */
  50734. Debug = 1,
  50735. /**
  50736. * Statistics tab
  50737. */
  50738. Statistics = 2,
  50739. /**
  50740. * Tools tab
  50741. */
  50742. Tools = 3,
  50743. /**
  50744. * Settings tab
  50745. */
  50746. Settings = 4
  50747. }
  50748. /**
  50749. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50750. * what is happening in your scene
  50751. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50752. */
  50753. export class DebugLayer {
  50754. /**
  50755. * Define the url to get the inspector script from.
  50756. * By default it uses the babylonjs CDN.
  50757. * @ignoreNaming
  50758. */
  50759. static InspectorURL: string;
  50760. private _scene;
  50761. private BJSINSPECTOR;
  50762. private _onPropertyChangedObservable?;
  50763. /**
  50764. * Observable triggered when a property is changed through the inspector.
  50765. */
  50766. get onPropertyChangedObservable(): any;
  50767. /**
  50768. * Instantiates a new debug layer.
  50769. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50770. * what is happening in your scene
  50771. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50772. * @param scene Defines the scene to inspect
  50773. */
  50774. constructor(scene: Scene);
  50775. /** Creates the inspector window. */
  50776. private _createInspector;
  50777. /**
  50778. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50779. * @param entity defines the entity to select
  50780. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50781. */
  50782. select(entity: any, lineContainerTitles?: string | string[]): void;
  50783. /** Get the inspector from bundle or global */
  50784. private _getGlobalInspector;
  50785. /**
  50786. * Get if the inspector is visible or not.
  50787. * @returns true if visible otherwise, false
  50788. */
  50789. isVisible(): boolean;
  50790. /**
  50791. * Hide the inspector and close its window.
  50792. */
  50793. hide(): void;
  50794. /**
  50795. * Update the scene in the inspector
  50796. */
  50797. setAsActiveScene(): void;
  50798. /**
  50799. * Launch the debugLayer.
  50800. * @param config Define the configuration of the inspector
  50801. * @return a promise fulfilled when the debug layer is visible
  50802. */
  50803. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50804. }
  50805. }
  50806. declare module BABYLON {
  50807. /**
  50808. * Class containing static functions to help procedurally build meshes
  50809. */
  50810. export class BoxBuilder {
  50811. /**
  50812. * Creates a box mesh
  50813. * * The parameter `size` sets the size (float) of each box side (default 1)
  50814. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50815. * * 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)
  50816. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50818. * * 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
  50819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50820. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50821. * @param name defines the name of the mesh
  50822. * @param options defines the options used to create the mesh
  50823. * @param scene defines the hosting scene
  50824. * @returns the box mesh
  50825. */
  50826. static CreateBox(name: string, options: {
  50827. size?: number;
  50828. width?: number;
  50829. height?: number;
  50830. depth?: number;
  50831. faceUV?: Vector4[];
  50832. faceColors?: Color4[];
  50833. sideOrientation?: number;
  50834. frontUVs?: Vector4;
  50835. backUVs?: Vector4;
  50836. wrap?: boolean;
  50837. topBaseAt?: number;
  50838. bottomBaseAt?: number;
  50839. updatable?: boolean;
  50840. }, scene?: Nullable<Scene>): Mesh;
  50841. }
  50842. }
  50843. declare module BABYLON.Debug {
  50844. /**
  50845. * Used to show the physics impostor around the specific mesh
  50846. */
  50847. export class PhysicsViewer {
  50848. /** @hidden */
  50849. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50850. /** @hidden */
  50851. protected _meshes: Array<Nullable<AbstractMesh>>;
  50852. /** @hidden */
  50853. protected _scene: Nullable<Scene>;
  50854. /** @hidden */
  50855. protected _numMeshes: number;
  50856. /** @hidden */
  50857. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50858. private _renderFunction;
  50859. private _utilityLayer;
  50860. private _debugBoxMesh;
  50861. private _debugSphereMesh;
  50862. private _debugCylinderMesh;
  50863. private _debugMaterial;
  50864. private _debugMeshMeshes;
  50865. /**
  50866. * Creates a new PhysicsViewer
  50867. * @param scene defines the hosting scene
  50868. */
  50869. constructor(scene: Scene);
  50870. /** @hidden */
  50871. protected _updateDebugMeshes(): void;
  50872. /**
  50873. * Renders a specified physic impostor
  50874. * @param impostor defines the impostor to render
  50875. * @param targetMesh defines the mesh represented by the impostor
  50876. * @returns the new debug mesh used to render the impostor
  50877. */
  50878. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50879. /**
  50880. * Hides a specified physic impostor
  50881. * @param impostor defines the impostor to hide
  50882. */
  50883. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50884. private _getDebugMaterial;
  50885. private _getDebugBoxMesh;
  50886. private _getDebugSphereMesh;
  50887. private _getDebugCylinderMesh;
  50888. private _getDebugMeshMesh;
  50889. private _getDebugMesh;
  50890. /** Releases all resources */
  50891. dispose(): void;
  50892. }
  50893. }
  50894. declare module BABYLON {
  50895. /**
  50896. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50897. * in order to better appreciate the issue one might have.
  50898. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50899. */
  50900. export class RayHelper {
  50901. /**
  50902. * Defines the ray we are currently tryin to visualize.
  50903. */
  50904. ray: Nullable<Ray>;
  50905. private _renderPoints;
  50906. private _renderLine;
  50907. private _renderFunction;
  50908. private _scene;
  50909. private _onAfterRenderObserver;
  50910. private _onAfterStepObserver;
  50911. private _attachedToMesh;
  50912. private _meshSpaceDirection;
  50913. private _meshSpaceOrigin;
  50914. /**
  50915. * Helper function to create a colored helper in a scene in one line.
  50916. * @param ray Defines the ray we are currently tryin to visualize
  50917. * @param scene Defines the scene the ray is used in
  50918. * @param color Defines the color we want to see the ray in
  50919. * @returns The newly created ray helper.
  50920. */
  50921. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50922. /**
  50923. * Instantiate a new ray helper.
  50924. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50925. * in order to better appreciate the issue one might have.
  50926. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50927. * @param ray Defines the ray we are currently tryin to visualize
  50928. */
  50929. constructor(ray: Ray);
  50930. /**
  50931. * Shows the ray we are willing to debug.
  50932. * @param scene Defines the scene the ray needs to be rendered in
  50933. * @param color Defines the color the ray needs to be rendered in
  50934. */
  50935. show(scene: Scene, color?: Color3): void;
  50936. /**
  50937. * Hides the ray we are debugging.
  50938. */
  50939. hide(): void;
  50940. private _render;
  50941. /**
  50942. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50943. * @param mesh Defines the mesh we want the helper attached to
  50944. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50945. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50946. * @param length Defines the length of the ray
  50947. */
  50948. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50949. /**
  50950. * Detach the ray helper from the mesh it has previously been attached to.
  50951. */
  50952. detachFromMesh(): void;
  50953. private _updateToMesh;
  50954. /**
  50955. * Dispose the helper and release its associated resources.
  50956. */
  50957. dispose(): void;
  50958. }
  50959. }
  50960. declare module BABYLON {
  50961. /**
  50962. * Defines the options associated with the creation of a SkeletonViewer.
  50963. */
  50964. export interface ISkeletonViewerOptions {
  50965. /** Should the system pause animations before building the Viewer? */
  50966. pauseAnimations: boolean;
  50967. /** Should the system return the skeleton to rest before building? */
  50968. returnToRest: boolean;
  50969. /** public Display Mode of the Viewer */
  50970. displayMode: number;
  50971. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50972. displayOptions: ISkeletonViewerDisplayOptions;
  50973. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50974. computeBonesUsingShaders: boolean;
  50975. }
  50976. /**
  50977. * Defines how to display the various bone meshes for the viewer.
  50978. */
  50979. export interface ISkeletonViewerDisplayOptions {
  50980. /** How far down to start tapering the bone spurs */
  50981. midStep?: number;
  50982. /** How big is the midStep? */
  50983. midStepFactor?: number;
  50984. /** Base for the Sphere Size */
  50985. sphereBaseSize?: number;
  50986. /** The ratio of the sphere to the longest bone in units */
  50987. sphereScaleUnit?: number;
  50988. /** Ratio for the Sphere Size */
  50989. sphereFactor?: number;
  50990. }
  50991. }
  50992. declare module BABYLON {
  50993. /**
  50994. * Class containing static functions to help procedurally build meshes
  50995. */
  50996. export class RibbonBuilder {
  50997. /**
  50998. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50999. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51000. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51001. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51002. * * 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
  51003. * * 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
  51004. * * 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
  51005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51006. * * 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
  51007. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51008. * * 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
  51009. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51010. * * 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
  51011. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51013. * @param name defines the name of the mesh
  51014. * @param options defines the options used to create the mesh
  51015. * @param scene defines the hosting scene
  51016. * @returns the ribbon mesh
  51017. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51018. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51019. */
  51020. static CreateRibbon(name: string, options: {
  51021. pathArray: Vector3[][];
  51022. closeArray?: boolean;
  51023. closePath?: boolean;
  51024. offset?: number;
  51025. updatable?: boolean;
  51026. sideOrientation?: number;
  51027. frontUVs?: Vector4;
  51028. backUVs?: Vector4;
  51029. instance?: Mesh;
  51030. invertUV?: boolean;
  51031. uvs?: Vector2[];
  51032. colors?: Color4[];
  51033. }, scene?: Nullable<Scene>): Mesh;
  51034. }
  51035. }
  51036. declare module BABYLON {
  51037. /**
  51038. * Class containing static functions to help procedurally build meshes
  51039. */
  51040. export class ShapeBuilder {
  51041. /**
  51042. * 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.
  51043. * * 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.
  51044. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51045. * * 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.
  51046. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51047. * * 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
  51048. * * 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
  51049. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51051. * * 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
  51052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51054. * @param name defines the name of the mesh
  51055. * @param options defines the options used to create the mesh
  51056. * @param scene defines the hosting scene
  51057. * @returns the extruded shape mesh
  51058. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51059. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51060. */
  51061. static ExtrudeShape(name: string, options: {
  51062. shape: Vector3[];
  51063. path: Vector3[];
  51064. scale?: number;
  51065. rotation?: number;
  51066. cap?: number;
  51067. updatable?: boolean;
  51068. sideOrientation?: number;
  51069. frontUVs?: Vector4;
  51070. backUVs?: Vector4;
  51071. instance?: Mesh;
  51072. invertUV?: boolean;
  51073. }, scene?: Nullable<Scene>): Mesh;
  51074. /**
  51075. * Creates an custom extruded shape mesh.
  51076. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51077. * * 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.
  51078. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51079. * * 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
  51080. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51081. * * 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
  51082. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51083. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51084. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51085. * * 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
  51086. * * 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
  51087. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51089. * * 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
  51090. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51092. * @param name defines the name of the mesh
  51093. * @param options defines the options used to create the mesh
  51094. * @param scene defines the hosting scene
  51095. * @returns the custom extruded shape mesh
  51096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51097. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51098. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51099. */
  51100. static ExtrudeShapeCustom(name: string, options: {
  51101. shape: Vector3[];
  51102. path: Vector3[];
  51103. scaleFunction?: any;
  51104. rotationFunction?: any;
  51105. ribbonCloseArray?: boolean;
  51106. ribbonClosePath?: boolean;
  51107. cap?: number;
  51108. updatable?: boolean;
  51109. sideOrientation?: number;
  51110. frontUVs?: Vector4;
  51111. backUVs?: Vector4;
  51112. instance?: Mesh;
  51113. invertUV?: boolean;
  51114. }, scene?: Nullable<Scene>): Mesh;
  51115. private static _ExtrudeShapeGeneric;
  51116. }
  51117. }
  51118. declare module BABYLON.Debug {
  51119. /**
  51120. * Class used to render a debug view of a given skeleton
  51121. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51122. */
  51123. export class SkeletonViewer {
  51124. /** defines the skeleton to render */
  51125. skeleton: Skeleton;
  51126. /** defines the mesh attached to the skeleton */
  51127. mesh: AbstractMesh;
  51128. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51129. autoUpdateBonesMatrices: boolean;
  51130. /** defines the rendering group id to use with the viewer */
  51131. renderingGroupId: number;
  51132. /** is the options for the viewer */
  51133. options: Partial<ISkeletonViewerOptions>;
  51134. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51135. static readonly DISPLAY_LINES: number;
  51136. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51137. static readonly DISPLAY_SPHERES: number;
  51138. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51139. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51140. /** If SkeletonViewer scene scope. */
  51141. private _scene;
  51142. /** Gets or sets the color used to render the skeleton */
  51143. color: Color3;
  51144. /** Array of the points of the skeleton fo the line view. */
  51145. private _debugLines;
  51146. /** The SkeletonViewers Mesh. */
  51147. private _debugMesh;
  51148. /** If SkeletonViewer is enabled. */
  51149. private _isEnabled;
  51150. /** If SkeletonViewer is ready. */
  51151. private _ready;
  51152. /** SkeletonViewer render observable. */
  51153. private _obs;
  51154. /** The Utility Layer to render the gizmos in. */
  51155. private _utilityLayer;
  51156. private _boneIndices;
  51157. /** Gets the Scene. */
  51158. get scene(): Scene;
  51159. /** Gets the utilityLayer. */
  51160. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51161. /** Checks Ready Status. */
  51162. get isReady(): Boolean;
  51163. /** Sets Ready Status. */
  51164. set ready(value: boolean);
  51165. /** Gets the debugMesh */
  51166. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51167. /** Sets the debugMesh */
  51168. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51169. /** Gets the material */
  51170. get material(): StandardMaterial;
  51171. /** Sets the material */
  51172. set material(value: StandardMaterial);
  51173. /** Gets the material */
  51174. get displayMode(): number;
  51175. /** Sets the material */
  51176. set displayMode(value: number);
  51177. /**
  51178. * Creates a new SkeletonViewer
  51179. * @param skeleton defines the skeleton to render
  51180. * @param mesh defines the mesh attached to the skeleton
  51181. * @param scene defines the hosting scene
  51182. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51183. * @param renderingGroupId defines the rendering group id to use with the viewer
  51184. * @param options All of the extra constructor options for the SkeletonViewer
  51185. */
  51186. constructor(
  51187. /** defines the skeleton to render */
  51188. skeleton: Skeleton,
  51189. /** defines the mesh attached to the skeleton */
  51190. mesh: AbstractMesh,
  51191. /** The Scene scope*/
  51192. scene: Scene,
  51193. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51194. autoUpdateBonesMatrices?: boolean,
  51195. /** defines the rendering group id to use with the viewer */
  51196. renderingGroupId?: number,
  51197. /** is the options for the viewer */
  51198. options?: Partial<ISkeletonViewerOptions>);
  51199. /** The Dynamic bindings for the update functions */
  51200. private _bindObs;
  51201. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51202. update(): void;
  51203. /** Gets or sets a boolean indicating if the viewer is enabled */
  51204. set isEnabled(value: boolean);
  51205. get isEnabled(): boolean;
  51206. private _getBonePosition;
  51207. private _getLinesForBonesWithLength;
  51208. private _getLinesForBonesNoLength;
  51209. /** function to revert the mesh and scene back to the initial state. */
  51210. private _revert;
  51211. /** function to build and bind sphere joint points and spur bone representations. */
  51212. private _buildSpheresAndSpurs;
  51213. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51214. private _displayLinesUpdate;
  51215. /** Changes the displayMode of the skeleton viewer
  51216. * @param mode The displayMode numerical value
  51217. */
  51218. changeDisplayMode(mode: number): void;
  51219. /** Changes the displayMode of the skeleton viewer
  51220. * @param option String of the option name
  51221. * @param value The numerical option value
  51222. */
  51223. changeDisplayOptions(option: string, value: number): void;
  51224. /** Release associated resources */
  51225. dispose(): void;
  51226. }
  51227. }
  51228. declare module BABYLON {
  51229. /**
  51230. * Enum for Device Types
  51231. */
  51232. export enum DeviceType {
  51233. /** Generic */
  51234. Generic = 0,
  51235. /** Keyboard */
  51236. Keyboard = 1,
  51237. /** Mouse */
  51238. Mouse = 2,
  51239. /** Touch Pointers */
  51240. Touch = 3,
  51241. /** PS4 Dual Shock */
  51242. DualShock = 4,
  51243. /** Xbox */
  51244. Xbox = 5,
  51245. /** Switch Controller */
  51246. Switch = 6
  51247. }
  51248. /**
  51249. * Enum for All Pointers (Touch/Mouse)
  51250. */
  51251. export enum PointerInput {
  51252. /** Horizontal Axis */
  51253. Horizontal = 0,
  51254. /** Vertical Axis */
  51255. Vertical = 1,
  51256. /** Left Click or Touch */
  51257. LeftClick = 2,
  51258. /** Middle Click */
  51259. MiddleClick = 3,
  51260. /** Right Click */
  51261. RightClick = 4,
  51262. /** Browser Back */
  51263. BrowserBack = 5,
  51264. /** Browser Forward */
  51265. BrowserForward = 6
  51266. }
  51267. /**
  51268. * Enum for Dual Shock Gamepad
  51269. */
  51270. export enum DualShockInput {
  51271. /** Cross */
  51272. Cross = 0,
  51273. /** Circle */
  51274. Circle = 1,
  51275. /** Square */
  51276. Square = 2,
  51277. /** Triangle */
  51278. Triangle = 3,
  51279. /** L1 */
  51280. L1 = 4,
  51281. /** R1 */
  51282. R1 = 5,
  51283. /** L2 */
  51284. L2 = 6,
  51285. /** R2 */
  51286. R2 = 7,
  51287. /** Share */
  51288. Share = 8,
  51289. /** Options */
  51290. Options = 9,
  51291. /** L3 */
  51292. L3 = 10,
  51293. /** R3 */
  51294. R3 = 11,
  51295. /** DPadUp */
  51296. DPadUp = 12,
  51297. /** DPadDown */
  51298. DPadDown = 13,
  51299. /** DPadLeft */
  51300. DPadLeft = 14,
  51301. /** DRight */
  51302. DPadRight = 15,
  51303. /** Home */
  51304. Home = 16,
  51305. /** TouchPad */
  51306. TouchPad = 17,
  51307. /** LStickXAxis */
  51308. LStickXAxis = 18,
  51309. /** LStickYAxis */
  51310. LStickYAxis = 19,
  51311. /** RStickXAxis */
  51312. RStickXAxis = 20,
  51313. /** RStickYAxis */
  51314. RStickYAxis = 21
  51315. }
  51316. /**
  51317. * Enum for Xbox Gamepad
  51318. */
  51319. export enum XboxInput {
  51320. /** A */
  51321. A = 0,
  51322. /** B */
  51323. B = 1,
  51324. /** X */
  51325. X = 2,
  51326. /** Y */
  51327. Y = 3,
  51328. /** LB */
  51329. LB = 4,
  51330. /** RB */
  51331. RB = 5,
  51332. /** LT */
  51333. LT = 6,
  51334. /** RT */
  51335. RT = 7,
  51336. /** Back */
  51337. Back = 8,
  51338. /** Start */
  51339. Start = 9,
  51340. /** LS */
  51341. LS = 10,
  51342. /** RS */
  51343. RS = 11,
  51344. /** DPadUp */
  51345. DPadUp = 12,
  51346. /** DPadDown */
  51347. DPadDown = 13,
  51348. /** DPadLeft */
  51349. DPadLeft = 14,
  51350. /** DRight */
  51351. DPadRight = 15,
  51352. /** Home */
  51353. Home = 16,
  51354. /** LStickXAxis */
  51355. LStickXAxis = 17,
  51356. /** LStickYAxis */
  51357. LStickYAxis = 18,
  51358. /** RStickXAxis */
  51359. RStickXAxis = 19,
  51360. /** RStickYAxis */
  51361. RStickYAxis = 20
  51362. }
  51363. /**
  51364. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51365. */
  51366. export enum SwitchInput {
  51367. /** B */
  51368. B = 0,
  51369. /** A */
  51370. A = 1,
  51371. /** Y */
  51372. Y = 2,
  51373. /** X */
  51374. X = 3,
  51375. /** L */
  51376. L = 4,
  51377. /** R */
  51378. R = 5,
  51379. /** ZL */
  51380. ZL = 6,
  51381. /** ZR */
  51382. ZR = 7,
  51383. /** Minus */
  51384. Minus = 8,
  51385. /** Plus */
  51386. Plus = 9,
  51387. /** LS */
  51388. LS = 10,
  51389. /** RS */
  51390. RS = 11,
  51391. /** DPadUp */
  51392. DPadUp = 12,
  51393. /** DPadDown */
  51394. DPadDown = 13,
  51395. /** DPadLeft */
  51396. DPadLeft = 14,
  51397. /** DRight */
  51398. DPadRight = 15,
  51399. /** Home */
  51400. Home = 16,
  51401. /** Capture */
  51402. Capture = 17,
  51403. /** LStickXAxis */
  51404. LStickXAxis = 18,
  51405. /** LStickYAxis */
  51406. LStickYAxis = 19,
  51407. /** RStickXAxis */
  51408. RStickXAxis = 20,
  51409. /** RStickYAxis */
  51410. RStickYAxis = 21
  51411. }
  51412. }
  51413. declare module BABYLON {
  51414. /**
  51415. * This class will take all inputs from Keyboard, Pointer, and
  51416. * any Gamepads and provide a polling system that all devices
  51417. * will use. This class assumes that there will only be one
  51418. * pointer device and one keyboard.
  51419. */
  51420. export class DeviceInputSystem implements IDisposable {
  51421. /**
  51422. * Callback to be triggered when a device is connected
  51423. */
  51424. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51425. /**
  51426. * Callback to be triggered when a device is disconnected
  51427. */
  51428. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51429. /**
  51430. * Callback to be triggered when event driven input is updated
  51431. */
  51432. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51433. private _inputs;
  51434. private _gamepads;
  51435. private _keyboardActive;
  51436. private _pointerActive;
  51437. private _elementToAttachTo;
  51438. private _keyboardDownEvent;
  51439. private _keyboardUpEvent;
  51440. private _pointerMoveEvent;
  51441. private _pointerDownEvent;
  51442. private _pointerUpEvent;
  51443. private _gamepadConnectedEvent;
  51444. private _gamepadDisconnectedEvent;
  51445. private static _MAX_KEYCODES;
  51446. private static _MAX_POINTER_INPUTS;
  51447. private constructor();
  51448. /**
  51449. * Creates a new DeviceInputSystem instance
  51450. * @param engine Engine to pull input element from
  51451. * @returns The new instance
  51452. */
  51453. static Create(engine: Engine): DeviceInputSystem;
  51454. /**
  51455. * Checks for current device input value, given an id and input index
  51456. * @param deviceName Id of connected device
  51457. * @param inputIndex Index of device input
  51458. * @returns Current value of input
  51459. */
  51460. /**
  51461. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51462. * @param deviceType Enum specifiying device type
  51463. * @param deviceSlot "Slot" or index that device is referenced in
  51464. * @param inputIndex Id of input to be checked
  51465. * @returns Current value of input
  51466. */
  51467. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51468. /**
  51469. * Dispose of all the eventlisteners
  51470. */
  51471. dispose(): void;
  51472. /**
  51473. * Add device and inputs to device array
  51474. * @param deviceType Enum specifiying device type
  51475. * @param deviceSlot "Slot" or index that device is referenced in
  51476. * @param numberOfInputs Number of input entries to create for given device
  51477. */
  51478. private _registerDevice;
  51479. /**
  51480. * Given a specific device name, remove that device from the device map
  51481. * @param deviceType Enum specifiying device type
  51482. * @param deviceSlot "Slot" or index that device is referenced in
  51483. */
  51484. private _unregisterDevice;
  51485. /**
  51486. * Handle all actions that come from keyboard interaction
  51487. */
  51488. private _handleKeyActions;
  51489. /**
  51490. * Handle all actions that come from pointer interaction
  51491. */
  51492. private _handlePointerActions;
  51493. /**
  51494. * Handle all actions that come from gamepad interaction
  51495. */
  51496. private _handleGamepadActions;
  51497. /**
  51498. * Update all non-event based devices with each frame
  51499. * @param deviceType Enum specifiying device type
  51500. * @param deviceSlot "Slot" or index that device is referenced in
  51501. * @param inputIndex Id of input to be checked
  51502. */
  51503. private _updateDevice;
  51504. /**
  51505. * Gets DeviceType from the device name
  51506. * @param deviceName Name of Device from DeviceInputSystem
  51507. * @returns DeviceType enum value
  51508. */
  51509. private _getGamepadDeviceType;
  51510. }
  51511. }
  51512. declare module BABYLON {
  51513. /**
  51514. * Type to handle enforcement of inputs
  51515. */
  51516. 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;
  51517. }
  51518. declare module BABYLON {
  51519. /**
  51520. * Class that handles all input for a specific device
  51521. */
  51522. export class DeviceSource<T extends DeviceType> {
  51523. /** Type of device */
  51524. readonly deviceType: DeviceType;
  51525. /** "Slot" or index that device is referenced in */
  51526. readonly deviceSlot: number;
  51527. /**
  51528. * Observable to handle device input changes per device
  51529. */
  51530. readonly onInputChangedObservable: Observable<{
  51531. inputIndex: DeviceInput<T>;
  51532. previousState: Nullable<number>;
  51533. currentState: Nullable<number>;
  51534. }>;
  51535. private readonly _deviceInputSystem;
  51536. /**
  51537. * Default Constructor
  51538. * @param deviceInputSystem Reference to DeviceInputSystem
  51539. * @param deviceType Type of device
  51540. * @param deviceSlot "Slot" or index that device is referenced in
  51541. */
  51542. constructor(deviceInputSystem: DeviceInputSystem,
  51543. /** Type of device */
  51544. deviceType: DeviceType,
  51545. /** "Slot" or index that device is referenced in */
  51546. deviceSlot?: number);
  51547. /**
  51548. * Get input for specific input
  51549. * @param inputIndex index of specific input on device
  51550. * @returns Input value from DeviceInputSystem
  51551. */
  51552. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51553. }
  51554. /**
  51555. * Class to keep track of devices
  51556. */
  51557. export class DeviceSourceManager implements IDisposable {
  51558. /**
  51559. * Observable to be triggered when before a device is connected
  51560. */
  51561. readonly onBeforeDeviceConnectedObservable: Observable<{
  51562. deviceType: DeviceType;
  51563. deviceSlot: number;
  51564. }>;
  51565. /**
  51566. * Observable to be triggered when before a device is disconnected
  51567. */
  51568. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51569. deviceType: DeviceType;
  51570. deviceSlot: number;
  51571. }>;
  51572. /**
  51573. * Observable to be triggered when after a device is connected
  51574. */
  51575. readonly onAfterDeviceConnectedObservable: Observable<{
  51576. deviceType: DeviceType;
  51577. deviceSlot: number;
  51578. }>;
  51579. /**
  51580. * Observable to be triggered when after a device is disconnected
  51581. */
  51582. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51583. deviceType: DeviceType;
  51584. deviceSlot: number;
  51585. }>;
  51586. private readonly _devices;
  51587. private readonly _firstDevice;
  51588. private readonly _deviceInputSystem;
  51589. /**
  51590. * Default Constructor
  51591. * @param engine engine to pull input element from
  51592. */
  51593. constructor(engine: Engine);
  51594. /**
  51595. * Gets a DeviceSource, given a type and slot
  51596. * @param deviceType Enum specifying device type
  51597. * @param deviceSlot "Slot" or index that device is referenced in
  51598. * @returns DeviceSource object
  51599. */
  51600. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51601. /**
  51602. * Gets an array of DeviceSource objects for a given device type
  51603. * @param deviceType Enum specifying device type
  51604. * @returns Array of DeviceSource objects
  51605. */
  51606. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51607. /**
  51608. * Dispose of DeviceInputSystem and other parts
  51609. */
  51610. dispose(): void;
  51611. /**
  51612. * Function to add device name to device list
  51613. * @param deviceType Enum specifying device type
  51614. * @param deviceSlot "Slot" or index that device is referenced in
  51615. */
  51616. private _addDevice;
  51617. /**
  51618. * Function to remove device name to device list
  51619. * @param deviceType Enum specifying device type
  51620. * @param deviceSlot "Slot" or index that device is referenced in
  51621. */
  51622. private _removeDevice;
  51623. /**
  51624. * Updates array storing first connected device of each type
  51625. * @param type Type of Device
  51626. */
  51627. private _updateFirstDevices;
  51628. }
  51629. }
  51630. declare module BABYLON {
  51631. /**
  51632. * Options to create the null engine
  51633. */
  51634. export class NullEngineOptions {
  51635. /**
  51636. * Render width (Default: 512)
  51637. */
  51638. renderWidth: number;
  51639. /**
  51640. * Render height (Default: 256)
  51641. */
  51642. renderHeight: number;
  51643. /**
  51644. * Texture size (Default: 512)
  51645. */
  51646. textureSize: number;
  51647. /**
  51648. * If delta time between frames should be constant
  51649. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51650. */
  51651. deterministicLockstep: boolean;
  51652. /**
  51653. * Maximum about of steps between frames (Default: 4)
  51654. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51655. */
  51656. lockstepMaxSteps: number;
  51657. /**
  51658. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51659. */
  51660. useHighPrecisionMatrix?: boolean;
  51661. }
  51662. /**
  51663. * The null engine class provides support for headless version of babylon.js.
  51664. * This can be used in server side scenario or for testing purposes
  51665. */
  51666. export class NullEngine extends Engine {
  51667. private _options;
  51668. /**
  51669. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51670. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51671. * @returns true if engine is in deterministic lock step mode
  51672. */
  51673. isDeterministicLockStep(): boolean;
  51674. /**
  51675. * Gets the max steps when engine is running in deterministic lock step
  51676. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51677. * @returns the max steps
  51678. */
  51679. getLockstepMaxSteps(): number;
  51680. /**
  51681. * Gets the current hardware scaling level.
  51682. * By default the hardware scaling level is computed from the window device ratio.
  51683. * 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.
  51684. * @returns a number indicating the current hardware scaling level
  51685. */
  51686. getHardwareScalingLevel(): number;
  51687. constructor(options?: NullEngineOptions);
  51688. /**
  51689. * Creates a vertex buffer
  51690. * @param vertices the data for the vertex buffer
  51691. * @returns the new WebGL static buffer
  51692. */
  51693. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51694. /**
  51695. * Creates a new index buffer
  51696. * @param indices defines the content of the index buffer
  51697. * @param updatable defines if the index buffer must be updatable
  51698. * @returns a new webGL buffer
  51699. */
  51700. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51701. /**
  51702. * Clear the current render buffer or the current render target (if any is set up)
  51703. * @param color defines the color to use
  51704. * @param backBuffer defines if the back buffer must be cleared
  51705. * @param depth defines if the depth buffer must be cleared
  51706. * @param stencil defines if the stencil buffer must be cleared
  51707. */
  51708. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51709. /**
  51710. * Gets the current render width
  51711. * @param useScreen defines if screen size must be used (or the current render target if any)
  51712. * @returns a number defining the current render width
  51713. */
  51714. getRenderWidth(useScreen?: boolean): number;
  51715. /**
  51716. * Gets the current render height
  51717. * @param useScreen defines if screen size must be used (or the current render target if any)
  51718. * @returns a number defining the current render height
  51719. */
  51720. getRenderHeight(useScreen?: boolean): number;
  51721. /**
  51722. * Set the WebGL's viewport
  51723. * @param viewport defines the viewport element to be used
  51724. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51725. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51726. */
  51727. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51728. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51729. /**
  51730. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51731. * @param pipelineContext defines the pipeline context to use
  51732. * @param uniformsNames defines the list of uniform names
  51733. * @returns an array of webGL uniform locations
  51734. */
  51735. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51736. /**
  51737. * Gets the lsit of active attributes for a given webGL program
  51738. * @param pipelineContext defines the pipeline context to use
  51739. * @param attributesNames defines the list of attribute names to get
  51740. * @returns an array of indices indicating the offset of each attribute
  51741. */
  51742. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51743. /**
  51744. * Binds an effect to the webGL context
  51745. * @param effect defines the effect to bind
  51746. */
  51747. bindSamplers(effect: Effect): void;
  51748. /**
  51749. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51750. * @param effect defines the effect to activate
  51751. */
  51752. enableEffect(effect: Effect): void;
  51753. /**
  51754. * Set various states to the webGL context
  51755. * @param culling defines backface culling state
  51756. * @param zOffset defines the value to apply to zOffset (0 by default)
  51757. * @param force defines if states must be applied even if cache is up to date
  51758. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51759. */
  51760. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51761. /**
  51762. * Set the value of an uniform to an array of int32
  51763. * @param uniform defines the webGL uniform location where to store the value
  51764. * @param array defines the array of int32 to store
  51765. */
  51766. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51767. /**
  51768. * Set the value of an uniform to an array of int32 (stored as vec2)
  51769. * @param uniform defines the webGL uniform location where to store the value
  51770. * @param array defines the array of int32 to store
  51771. */
  51772. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51773. /**
  51774. * Set the value of an uniform to an array of int32 (stored as vec3)
  51775. * @param uniform defines the webGL uniform location where to store the value
  51776. * @param array defines the array of int32 to store
  51777. */
  51778. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51779. /**
  51780. * Set the value of an uniform to an array of int32 (stored as vec4)
  51781. * @param uniform defines the webGL uniform location where to store the value
  51782. * @param array defines the array of int32 to store
  51783. */
  51784. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51785. /**
  51786. * Set the value of an uniform to an array of float32
  51787. * @param uniform defines the webGL uniform location where to store the value
  51788. * @param array defines the array of float32 to store
  51789. */
  51790. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51791. /**
  51792. * Set the value of an uniform to an array of float32 (stored as vec2)
  51793. * @param uniform defines the webGL uniform location where to store the value
  51794. * @param array defines the array of float32 to store
  51795. */
  51796. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51797. /**
  51798. * Set the value of an uniform to an array of float32 (stored as vec3)
  51799. * @param uniform defines the webGL uniform location where to store the value
  51800. * @param array defines the array of float32 to store
  51801. */
  51802. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51803. /**
  51804. * Set the value of an uniform to an array of float32 (stored as vec4)
  51805. * @param uniform defines the webGL uniform location where to store the value
  51806. * @param array defines the array of float32 to store
  51807. */
  51808. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51809. /**
  51810. * Set the value of an uniform to an array of number
  51811. * @param uniform defines the webGL uniform location where to store the value
  51812. * @param array defines the array of number to store
  51813. */
  51814. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51815. /**
  51816. * Set the value of an uniform to an array of number (stored as vec2)
  51817. * @param uniform defines the webGL uniform location where to store the value
  51818. * @param array defines the array of number to store
  51819. */
  51820. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51821. /**
  51822. * Set the value of an uniform to an array of number (stored as vec3)
  51823. * @param uniform defines the webGL uniform location where to store the value
  51824. * @param array defines the array of number to store
  51825. */
  51826. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51827. /**
  51828. * Set the value of an uniform to an array of number (stored as vec4)
  51829. * @param uniform defines the webGL uniform location where to store the value
  51830. * @param array defines the array of number to store
  51831. */
  51832. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51833. /**
  51834. * Set the value of an uniform to an array of float32 (stored as matrices)
  51835. * @param uniform defines the webGL uniform location where to store the value
  51836. * @param matrices defines the array of float32 to store
  51837. */
  51838. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51839. /**
  51840. * Set the value of an uniform to a matrix (3x3)
  51841. * @param uniform defines the webGL uniform location where to store the value
  51842. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51843. */
  51844. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51845. /**
  51846. * Set the value of an uniform to a matrix (2x2)
  51847. * @param uniform defines the webGL uniform location where to store the value
  51848. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51849. */
  51850. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51851. /**
  51852. * Set the value of an uniform to a number (float)
  51853. * @param uniform defines the webGL uniform location where to store the value
  51854. * @param value defines the float number to store
  51855. */
  51856. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51857. /**
  51858. * Set the value of an uniform to a vec2
  51859. * @param uniform defines the webGL uniform location where to store the value
  51860. * @param x defines the 1st component of the value
  51861. * @param y defines the 2nd component of the value
  51862. */
  51863. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51864. /**
  51865. * Set the value of an uniform to a vec3
  51866. * @param uniform defines the webGL uniform location where to store the value
  51867. * @param x defines the 1st component of the value
  51868. * @param y defines the 2nd component of the value
  51869. * @param z defines the 3rd component of the value
  51870. */
  51871. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51872. /**
  51873. * Set the value of an uniform to a boolean
  51874. * @param uniform defines the webGL uniform location where to store the value
  51875. * @param bool defines the boolean to store
  51876. */
  51877. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51878. /**
  51879. * Set the value of an uniform to a vec4
  51880. * @param uniform defines the webGL uniform location where to store the value
  51881. * @param x defines the 1st component of the value
  51882. * @param y defines the 2nd component of the value
  51883. * @param z defines the 3rd component of the value
  51884. * @param w defines the 4th component of the value
  51885. */
  51886. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51887. /**
  51888. * Sets the current alpha mode
  51889. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51890. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51891. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51892. */
  51893. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51894. /**
  51895. * Bind webGl buffers directly to the webGL context
  51896. * @param vertexBuffers defines the vertex buffer to bind
  51897. * @param indexBuffer defines the index buffer to bind
  51898. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51899. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51900. * @param effect defines the effect associated with the vertex buffer
  51901. */
  51902. bindBuffers(vertexBuffers: {
  51903. [key: string]: VertexBuffer;
  51904. }, indexBuffer: DataBuffer, effect: Effect): void;
  51905. /**
  51906. * Force the entire cache to be cleared
  51907. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51908. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51909. */
  51910. wipeCaches(bruteForce?: boolean): void;
  51911. /**
  51912. * Send a draw order
  51913. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51914. * @param indexStart defines the starting index
  51915. * @param indexCount defines the number of index to draw
  51916. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51917. */
  51918. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51919. /**
  51920. * Draw a list of indexed primitives
  51921. * @param fillMode defines the primitive to use
  51922. * @param indexStart defines the starting index
  51923. * @param indexCount defines the number of index to draw
  51924. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51925. */
  51926. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51927. /**
  51928. * Draw a list of unindexed primitives
  51929. * @param fillMode defines the primitive to use
  51930. * @param verticesStart defines the index of first vertex to draw
  51931. * @param verticesCount defines the count of vertices to draw
  51932. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51933. */
  51934. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51935. /** @hidden */
  51936. _createTexture(): WebGLTexture;
  51937. /** @hidden */
  51938. _releaseTexture(texture: InternalTexture): void;
  51939. /**
  51940. * Usually called from Texture.ts.
  51941. * Passed information to create a WebGLTexture
  51942. * @param urlArg defines a value which contains one of the following:
  51943. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51944. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51945. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51946. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51947. * @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)
  51948. * @param scene needed for loading to the correct scene
  51949. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51950. * @param onLoad optional callback to be called upon successful completion
  51951. * @param onError optional callback to be called upon failure
  51952. * @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
  51953. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51954. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51955. * @param forcedExtension defines the extension to use to pick the right loader
  51956. * @param mimeType defines an optional mime type
  51957. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51958. */
  51959. 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;
  51960. /**
  51961. * Creates a new render target texture
  51962. * @param size defines the size of the texture
  51963. * @param options defines the options used to create the texture
  51964. * @returns a new render target texture stored in an InternalTexture
  51965. */
  51966. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51967. /**
  51968. * Update the sampling mode of a given texture
  51969. * @param samplingMode defines the required sampling mode
  51970. * @param texture defines the texture to update
  51971. */
  51972. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51973. /**
  51974. * Binds the frame buffer to the specified texture.
  51975. * @param texture The texture to render to or null for the default canvas
  51976. * @param faceIndex The face of the texture to render to in case of cube texture
  51977. * @param requiredWidth The width of the target to render to
  51978. * @param requiredHeight The height of the target to render to
  51979. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51980. * @param lodLevel defines le lod level to bind to the frame buffer
  51981. */
  51982. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51983. /**
  51984. * Unbind the current render target texture from the webGL context
  51985. * @param texture defines the render target texture to unbind
  51986. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51987. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51988. */
  51989. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51990. /**
  51991. * Creates a dynamic vertex buffer
  51992. * @param vertices the data for the dynamic vertex buffer
  51993. * @returns the new WebGL dynamic buffer
  51994. */
  51995. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51996. /**
  51997. * Update the content of a dynamic texture
  51998. * @param texture defines the texture to update
  51999. * @param canvas defines the canvas containing the source
  52000. * @param invertY defines if data must be stored with Y axis inverted
  52001. * @param premulAlpha defines if alpha is stored as premultiplied
  52002. * @param format defines the format of the data
  52003. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52004. */
  52005. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52006. /**
  52007. * Gets a boolean indicating if all created effects are ready
  52008. * @returns true if all effects are ready
  52009. */
  52010. areAllEffectsReady(): boolean;
  52011. /**
  52012. * @hidden
  52013. * Get the current error code of the webGL context
  52014. * @returns the error code
  52015. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52016. */
  52017. getError(): number;
  52018. /** @hidden */
  52019. _getUnpackAlignement(): number;
  52020. /** @hidden */
  52021. _unpackFlipY(value: boolean): void;
  52022. /**
  52023. * Update a dynamic index buffer
  52024. * @param indexBuffer defines the target index buffer
  52025. * @param indices defines the data to update
  52026. * @param offset defines the offset in the target index buffer where update should start
  52027. */
  52028. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52029. /**
  52030. * Updates a dynamic vertex buffer.
  52031. * @param vertexBuffer the vertex buffer to update
  52032. * @param vertices the data used to update the vertex buffer
  52033. * @param byteOffset the byte offset of the data (optional)
  52034. * @param byteLength the byte length of the data (optional)
  52035. */
  52036. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52037. /** @hidden */
  52038. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52039. /** @hidden */
  52040. _bindTexture(channel: number, texture: InternalTexture): void;
  52041. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52042. /**
  52043. * 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
  52044. */
  52045. releaseEffects(): void;
  52046. displayLoadingUI(): void;
  52047. hideLoadingUI(): void;
  52048. /** @hidden */
  52049. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52050. /** @hidden */
  52051. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52052. /** @hidden */
  52053. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52054. /** @hidden */
  52055. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52056. }
  52057. }
  52058. declare module BABYLON {
  52059. /**
  52060. * @hidden
  52061. **/
  52062. export class _TimeToken {
  52063. _startTimeQuery: Nullable<WebGLQuery>;
  52064. _endTimeQuery: Nullable<WebGLQuery>;
  52065. _timeElapsedQuery: Nullable<WebGLQuery>;
  52066. _timeElapsedQueryEnded: boolean;
  52067. }
  52068. }
  52069. declare module BABYLON {
  52070. /** @hidden */
  52071. export class _OcclusionDataStorage {
  52072. /** @hidden */
  52073. occlusionInternalRetryCounter: number;
  52074. /** @hidden */
  52075. isOcclusionQueryInProgress: boolean;
  52076. /** @hidden */
  52077. isOccluded: boolean;
  52078. /** @hidden */
  52079. occlusionRetryCount: number;
  52080. /** @hidden */
  52081. occlusionType: number;
  52082. /** @hidden */
  52083. occlusionQueryAlgorithmType: number;
  52084. }
  52085. interface Engine {
  52086. /**
  52087. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52088. * @return the new query
  52089. */
  52090. createQuery(): WebGLQuery;
  52091. /**
  52092. * Delete and release a webGL query
  52093. * @param query defines the query to delete
  52094. * @return the current engine
  52095. */
  52096. deleteQuery(query: WebGLQuery): Engine;
  52097. /**
  52098. * Check if a given query has resolved and got its value
  52099. * @param query defines the query to check
  52100. * @returns true if the query got its value
  52101. */
  52102. isQueryResultAvailable(query: WebGLQuery): boolean;
  52103. /**
  52104. * Gets the value of a given query
  52105. * @param query defines the query to check
  52106. * @returns the value of the query
  52107. */
  52108. getQueryResult(query: WebGLQuery): number;
  52109. /**
  52110. * Initiates an occlusion query
  52111. * @param algorithmType defines the algorithm to use
  52112. * @param query defines the query to use
  52113. * @returns the current engine
  52114. * @see https://doc.babylonjs.com/features/occlusionquery
  52115. */
  52116. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52117. /**
  52118. * Ends an occlusion query
  52119. * @see https://doc.babylonjs.com/features/occlusionquery
  52120. * @param algorithmType defines the algorithm to use
  52121. * @returns the current engine
  52122. */
  52123. endOcclusionQuery(algorithmType: number): Engine;
  52124. /**
  52125. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52126. * Please note that only one query can be issued at a time
  52127. * @returns a time token used to track the time span
  52128. */
  52129. startTimeQuery(): Nullable<_TimeToken>;
  52130. /**
  52131. * Ends a time query
  52132. * @param token defines the token used to measure the time span
  52133. * @returns the time spent (in ns)
  52134. */
  52135. endTimeQuery(token: _TimeToken): int;
  52136. /** @hidden */
  52137. _currentNonTimestampToken: Nullable<_TimeToken>;
  52138. /** @hidden */
  52139. _createTimeQuery(): WebGLQuery;
  52140. /** @hidden */
  52141. _deleteTimeQuery(query: WebGLQuery): void;
  52142. /** @hidden */
  52143. _getGlAlgorithmType(algorithmType: number): number;
  52144. /** @hidden */
  52145. _getTimeQueryResult(query: WebGLQuery): any;
  52146. /** @hidden */
  52147. _getTimeQueryAvailability(query: WebGLQuery): any;
  52148. }
  52149. interface AbstractMesh {
  52150. /**
  52151. * Backing filed
  52152. * @hidden
  52153. */
  52154. __occlusionDataStorage: _OcclusionDataStorage;
  52155. /**
  52156. * Access property
  52157. * @hidden
  52158. */
  52159. _occlusionDataStorage: _OcclusionDataStorage;
  52160. /**
  52161. * 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.
  52162. * The default value is -1 which means don't break the query and wait till the result
  52163. * @see https://doc.babylonjs.com/features/occlusionquery
  52164. */
  52165. occlusionRetryCount: number;
  52166. /**
  52167. * 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:
  52168. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52169. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52170. * * 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.
  52171. * @see https://doc.babylonjs.com/features/occlusionquery
  52172. */
  52173. occlusionType: number;
  52174. /**
  52175. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52176. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52177. * * 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.
  52178. * @see https://doc.babylonjs.com/features/occlusionquery
  52179. */
  52180. occlusionQueryAlgorithmType: number;
  52181. /**
  52182. * 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
  52183. * @see https://doc.babylonjs.com/features/occlusionquery
  52184. */
  52185. isOccluded: boolean;
  52186. /**
  52187. * Flag to check the progress status of the query
  52188. * @see https://doc.babylonjs.com/features/occlusionquery
  52189. */
  52190. isOcclusionQueryInProgress: boolean;
  52191. }
  52192. }
  52193. declare module BABYLON {
  52194. /** @hidden */
  52195. export var _forceTransformFeedbackToBundle: boolean;
  52196. interface Engine {
  52197. /**
  52198. * Creates a webGL transform feedback object
  52199. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52200. * @returns the webGL transform feedback object
  52201. */
  52202. createTransformFeedback(): WebGLTransformFeedback;
  52203. /**
  52204. * Delete a webGL transform feedback object
  52205. * @param value defines the webGL transform feedback object to delete
  52206. */
  52207. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52208. /**
  52209. * Bind a webGL transform feedback object to the webgl context
  52210. * @param value defines the webGL transform feedback object to bind
  52211. */
  52212. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52213. /**
  52214. * Begins a transform feedback operation
  52215. * @param usePoints defines if points or triangles must be used
  52216. */
  52217. beginTransformFeedback(usePoints: boolean): void;
  52218. /**
  52219. * Ends a transform feedback operation
  52220. */
  52221. endTransformFeedback(): void;
  52222. /**
  52223. * Specify the varyings to use with transform feedback
  52224. * @param program defines the associated webGL program
  52225. * @param value defines the list of strings representing the varying names
  52226. */
  52227. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52228. /**
  52229. * Bind a webGL buffer for a transform feedback operation
  52230. * @param value defines the webGL buffer to bind
  52231. */
  52232. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52233. }
  52234. }
  52235. declare module BABYLON {
  52236. /**
  52237. * Class used to define an additional view for the engine
  52238. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52239. */
  52240. export class EngineView {
  52241. /** Defines the canvas where to render the view */
  52242. target: HTMLCanvasElement;
  52243. /** Defines an optional camera used to render the view (will use active camera else) */
  52244. camera?: Camera;
  52245. }
  52246. interface Engine {
  52247. /**
  52248. * Gets or sets the HTML element to use for attaching events
  52249. */
  52250. inputElement: Nullable<HTMLElement>;
  52251. /**
  52252. * Gets the current engine view
  52253. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52254. */
  52255. activeView: Nullable<EngineView>;
  52256. /** Gets or sets the list of views */
  52257. views: EngineView[];
  52258. /**
  52259. * Register a new child canvas
  52260. * @param canvas defines the canvas to register
  52261. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52262. * @returns the associated view
  52263. */
  52264. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52265. /**
  52266. * Remove a registered child canvas
  52267. * @param canvas defines the canvas to remove
  52268. * @returns the current engine
  52269. */
  52270. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52271. }
  52272. }
  52273. declare module BABYLON {
  52274. interface Engine {
  52275. /** @hidden */
  52276. _excludedCompressedTextures: string[];
  52277. /** @hidden */
  52278. _textureFormatInUse: string;
  52279. /**
  52280. * Gets the list of texture formats supported
  52281. */
  52282. readonly texturesSupported: Array<string>;
  52283. /**
  52284. * Gets the texture format in use
  52285. */
  52286. readonly textureFormatInUse: Nullable<string>;
  52287. /**
  52288. * Set the compressed texture extensions or file names to skip.
  52289. *
  52290. * @param skippedFiles defines the list of those texture files you want to skip
  52291. * Example: [".dds", ".env", "myfile.png"]
  52292. */
  52293. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52294. /**
  52295. * Set the compressed texture format to use, based on the formats you have, and the formats
  52296. * supported by the hardware / browser.
  52297. *
  52298. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52299. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52300. * to API arguments needed to compressed textures. This puts the burden on the container
  52301. * generator to house the arcane code for determining these for current & future formats.
  52302. *
  52303. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52304. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52305. *
  52306. * Note: The result of this call is not taken into account when a texture is base64.
  52307. *
  52308. * @param formatsAvailable defines the list of those format families you have created
  52309. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52310. *
  52311. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52312. * @returns The extension selected.
  52313. */
  52314. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52315. }
  52316. }
  52317. declare module BABYLON {
  52318. /**
  52319. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52320. */
  52321. export interface CubeMapInfo {
  52322. /**
  52323. * The pixel array for the front face.
  52324. * This is stored in format, left to right, up to down format.
  52325. */
  52326. front: Nullable<ArrayBufferView>;
  52327. /**
  52328. * The pixel array for the back face.
  52329. * This is stored in format, left to right, up to down format.
  52330. */
  52331. back: Nullable<ArrayBufferView>;
  52332. /**
  52333. * The pixel array for the left face.
  52334. * This is stored in format, left to right, up to down format.
  52335. */
  52336. left: Nullable<ArrayBufferView>;
  52337. /**
  52338. * The pixel array for the right face.
  52339. * This is stored in format, left to right, up to down format.
  52340. */
  52341. right: Nullable<ArrayBufferView>;
  52342. /**
  52343. * The pixel array for the up face.
  52344. * This is stored in format, left to right, up to down format.
  52345. */
  52346. up: Nullable<ArrayBufferView>;
  52347. /**
  52348. * The pixel array for the down face.
  52349. * This is stored in format, left to right, up to down format.
  52350. */
  52351. down: Nullable<ArrayBufferView>;
  52352. /**
  52353. * The size of the cubemap stored.
  52354. *
  52355. * Each faces will be size * size pixels.
  52356. */
  52357. size: number;
  52358. /**
  52359. * The format of the texture.
  52360. *
  52361. * RGBA, RGB.
  52362. */
  52363. format: number;
  52364. /**
  52365. * The type of the texture data.
  52366. *
  52367. * UNSIGNED_INT, FLOAT.
  52368. */
  52369. type: number;
  52370. /**
  52371. * Specifies whether the texture is in gamma space.
  52372. */
  52373. gammaSpace: boolean;
  52374. }
  52375. /**
  52376. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52377. */
  52378. export class PanoramaToCubeMapTools {
  52379. private static FACE_LEFT;
  52380. private static FACE_RIGHT;
  52381. private static FACE_FRONT;
  52382. private static FACE_BACK;
  52383. private static FACE_DOWN;
  52384. private static FACE_UP;
  52385. /**
  52386. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52387. *
  52388. * @param float32Array The source data.
  52389. * @param inputWidth The width of the input panorama.
  52390. * @param inputHeight The height of the input panorama.
  52391. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52392. * @return The cubemap data
  52393. */
  52394. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52395. private static CreateCubemapTexture;
  52396. private static CalcProjectionSpherical;
  52397. }
  52398. }
  52399. declare module BABYLON {
  52400. /**
  52401. * Helper class dealing with the extraction of spherical polynomial dataArray
  52402. * from a cube map.
  52403. */
  52404. export class CubeMapToSphericalPolynomialTools {
  52405. private static FileFaces;
  52406. /**
  52407. * Converts a texture to the according Spherical Polynomial data.
  52408. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52409. *
  52410. * @param texture The texture to extract the information from.
  52411. * @return The Spherical Polynomial data.
  52412. */
  52413. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52414. /**
  52415. * Converts a cubemap to the according Spherical Polynomial data.
  52416. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52417. *
  52418. * @param cubeInfo The Cube map to extract the information from.
  52419. * @return The Spherical Polynomial data.
  52420. */
  52421. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52422. }
  52423. }
  52424. declare module BABYLON {
  52425. interface BaseTexture {
  52426. /**
  52427. * Get the polynomial representation of the texture data.
  52428. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52429. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52430. */
  52431. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52432. }
  52433. }
  52434. declare module BABYLON {
  52435. /** @hidden */
  52436. export var rgbdEncodePixelShader: {
  52437. name: string;
  52438. shader: string;
  52439. };
  52440. }
  52441. declare module BABYLON {
  52442. /** @hidden */
  52443. export var rgbdDecodePixelShader: {
  52444. name: string;
  52445. shader: string;
  52446. };
  52447. }
  52448. declare module BABYLON {
  52449. /**
  52450. * Raw texture data and descriptor sufficient for WebGL texture upload
  52451. */
  52452. export interface EnvironmentTextureInfo {
  52453. /**
  52454. * Version of the environment map
  52455. */
  52456. version: number;
  52457. /**
  52458. * Width of image
  52459. */
  52460. width: number;
  52461. /**
  52462. * Irradiance information stored in the file.
  52463. */
  52464. irradiance: any;
  52465. /**
  52466. * Specular information stored in the file.
  52467. */
  52468. specular: any;
  52469. }
  52470. /**
  52471. * Defines One Image in the file. It requires only the position in the file
  52472. * as well as the length.
  52473. */
  52474. interface BufferImageData {
  52475. /**
  52476. * Length of the image data.
  52477. */
  52478. length: number;
  52479. /**
  52480. * Position of the data from the null terminator delimiting the end of the JSON.
  52481. */
  52482. position: number;
  52483. }
  52484. /**
  52485. * Defines the specular data enclosed in the file.
  52486. * This corresponds to the version 1 of the data.
  52487. */
  52488. export interface EnvironmentTextureSpecularInfoV1 {
  52489. /**
  52490. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52491. */
  52492. specularDataPosition?: number;
  52493. /**
  52494. * This contains all the images data needed to reconstruct the cubemap.
  52495. */
  52496. mipmaps: Array<BufferImageData>;
  52497. /**
  52498. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52499. */
  52500. lodGenerationScale: number;
  52501. }
  52502. /**
  52503. * Sets of helpers addressing the serialization and deserialization of environment texture
  52504. * stored in a BabylonJS env file.
  52505. * Those files are usually stored as .env files.
  52506. */
  52507. export class EnvironmentTextureTools {
  52508. /**
  52509. * Magic number identifying the env file.
  52510. */
  52511. private static _MagicBytes;
  52512. /**
  52513. * Gets the environment info from an env file.
  52514. * @param data The array buffer containing the .env bytes.
  52515. * @returns the environment file info (the json header) if successfully parsed.
  52516. */
  52517. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52518. /**
  52519. * Creates an environment texture from a loaded cube texture.
  52520. * @param texture defines the cube texture to convert in env file
  52521. * @return a promise containing the environment data if succesfull.
  52522. */
  52523. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52524. /**
  52525. * Creates a JSON representation of the spherical data.
  52526. * @param texture defines the texture containing the polynomials
  52527. * @return the JSON representation of the spherical info
  52528. */
  52529. private static _CreateEnvTextureIrradiance;
  52530. /**
  52531. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52532. * @param data the image data
  52533. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52534. * @return the views described by info providing access to the underlying buffer
  52535. */
  52536. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52537. /**
  52538. * Uploads the texture info contained in the env file to the GPU.
  52539. * @param texture defines the internal texture to upload to
  52540. * @param data defines the data to load
  52541. * @param info defines the texture info retrieved through the GetEnvInfo method
  52542. * @returns a promise
  52543. */
  52544. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52545. private static _OnImageReadyAsync;
  52546. /**
  52547. * Uploads the levels of image data to the GPU.
  52548. * @param texture defines the internal texture to upload to
  52549. * @param imageData defines the array buffer views of image data [mipmap][face]
  52550. * @returns a promise
  52551. */
  52552. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52553. /**
  52554. * Uploads spherical polynomials information to the texture.
  52555. * @param texture defines the texture we are trying to upload the information to
  52556. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52557. */
  52558. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52559. /** @hidden */
  52560. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52561. }
  52562. }
  52563. declare module BABYLON {
  52564. /**
  52565. * Class used to inline functions in shader code
  52566. */
  52567. export class ShaderCodeInliner {
  52568. private static readonly _RegexpFindFunctionNameAndType;
  52569. private _sourceCode;
  52570. private _functionDescr;
  52571. private _numMaxIterations;
  52572. /** Gets or sets the token used to mark the functions to inline */
  52573. inlineToken: string;
  52574. /** Gets or sets the debug mode */
  52575. debug: boolean;
  52576. /** Gets the code after the inlining process */
  52577. get code(): string;
  52578. /**
  52579. * Initializes the inliner
  52580. * @param sourceCode shader code source to inline
  52581. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52582. */
  52583. constructor(sourceCode: string, numMaxIterations?: number);
  52584. /**
  52585. * Start the processing of the shader code
  52586. */
  52587. processCode(): void;
  52588. private _collectFunctions;
  52589. private _processInlining;
  52590. private _extractBetweenMarkers;
  52591. private _skipWhitespaces;
  52592. private _removeComments;
  52593. private _replaceFunctionCallsByCode;
  52594. private _findBackward;
  52595. private _escapeRegExp;
  52596. private _replaceNames;
  52597. }
  52598. }
  52599. declare module BABYLON {
  52600. /**
  52601. * Container for accessors for natively-stored mesh data buffers.
  52602. */
  52603. class NativeDataBuffer extends DataBuffer {
  52604. /**
  52605. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52606. */
  52607. nativeIndexBuffer?: any;
  52608. /**
  52609. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52610. */
  52611. nativeVertexBuffer?: any;
  52612. }
  52613. /** @hidden */
  52614. class NativeTexture extends InternalTexture {
  52615. getInternalTexture(): InternalTexture;
  52616. getViewCount(): number;
  52617. }
  52618. /** @hidden */
  52619. export class NativeEngine extends Engine {
  52620. private readonly _native;
  52621. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52622. private readonly INVALID_HANDLE;
  52623. private _boundBuffersVertexArray;
  52624. getHardwareScalingLevel(): number;
  52625. constructor();
  52626. dispose(): void;
  52627. /**
  52628. * Can be used to override the current requestAnimationFrame requester.
  52629. * @hidden
  52630. */
  52631. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52632. /**
  52633. * Override default engine behavior.
  52634. * @param color
  52635. * @param backBuffer
  52636. * @param depth
  52637. * @param stencil
  52638. */
  52639. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52640. /**
  52641. * Gets host document
  52642. * @returns the host document object
  52643. */
  52644. getHostDocument(): Nullable<Document>;
  52645. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52646. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52647. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52648. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52649. [key: string]: VertexBuffer;
  52650. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52651. bindBuffers(vertexBuffers: {
  52652. [key: string]: VertexBuffer;
  52653. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52654. recordVertexArrayObject(vertexBuffers: {
  52655. [key: string]: VertexBuffer;
  52656. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52657. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52658. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52659. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52660. /**
  52661. * Draw a list of indexed primitives
  52662. * @param fillMode defines the primitive to use
  52663. * @param indexStart defines the starting index
  52664. * @param indexCount defines the number of index to draw
  52665. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52666. */
  52667. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52668. /**
  52669. * Draw a list of unindexed primitives
  52670. * @param fillMode defines the primitive to use
  52671. * @param verticesStart defines the index of first vertex to draw
  52672. * @param verticesCount defines the count of vertices to draw
  52673. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52674. */
  52675. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52676. createPipelineContext(): IPipelineContext;
  52677. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52678. /** @hidden */
  52679. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52680. /** @hidden */
  52681. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52682. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52683. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52684. protected _setProgram(program: WebGLProgram): void;
  52685. _releaseEffect(effect: Effect): void;
  52686. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52687. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52688. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52689. bindSamplers(effect: Effect): void;
  52690. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52691. getRenderWidth(useScreen?: boolean): number;
  52692. getRenderHeight(useScreen?: boolean): number;
  52693. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52694. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52695. /**
  52696. * Set the z offset to apply to current rendering
  52697. * @param value defines the offset to apply
  52698. */
  52699. setZOffset(value: number): void;
  52700. /**
  52701. * Gets the current value of the zOffset
  52702. * @returns the current zOffset state
  52703. */
  52704. getZOffset(): number;
  52705. /**
  52706. * Enable or disable depth buffering
  52707. * @param enable defines the state to set
  52708. */
  52709. setDepthBuffer(enable: boolean): void;
  52710. /**
  52711. * Gets a boolean indicating if depth writing is enabled
  52712. * @returns the current depth writing state
  52713. */
  52714. getDepthWrite(): boolean;
  52715. /**
  52716. * Enable or disable depth writing
  52717. * @param enable defines the state to set
  52718. */
  52719. setDepthWrite(enable: boolean): void;
  52720. /**
  52721. * Enable or disable color writing
  52722. * @param enable defines the state to set
  52723. */
  52724. setColorWrite(enable: boolean): void;
  52725. /**
  52726. * Gets a boolean indicating if color writing is enabled
  52727. * @returns the current color writing state
  52728. */
  52729. getColorWrite(): boolean;
  52730. /**
  52731. * Sets alpha constants used by some alpha blending modes
  52732. * @param r defines the red component
  52733. * @param g defines the green component
  52734. * @param b defines the blue component
  52735. * @param a defines the alpha component
  52736. */
  52737. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52738. /**
  52739. * Sets the current alpha mode
  52740. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52741. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52742. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52743. */
  52744. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52745. /**
  52746. * Gets the current alpha mode
  52747. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52748. * @returns the current alpha mode
  52749. */
  52750. getAlphaMode(): number;
  52751. setInt(uniform: WebGLUniformLocation, int: number): void;
  52752. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52753. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52754. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52755. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52756. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52757. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52758. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52759. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52760. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52761. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52762. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52763. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52764. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52765. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52766. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52767. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52768. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52769. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52770. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52771. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52772. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52773. wipeCaches(bruteForce?: boolean): void;
  52774. _createTexture(): WebGLTexture;
  52775. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52776. /**
  52777. * Usually called from Texture.ts.
  52778. * Passed information to create a WebGLTexture
  52779. * @param url defines a value which contains one of the following:
  52780. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52781. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52782. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52783. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52784. * @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)
  52785. * @param scene needed for loading to the correct scene
  52786. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52787. * @param onLoad optional callback to be called upon successful completion
  52788. * @param onError optional callback to be called upon failure
  52789. * @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
  52790. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52791. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52792. * @param forcedExtension defines the extension to use to pick the right loader
  52793. * @param mimeType defines an optional mime type
  52794. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52795. */
  52796. 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;
  52797. /**
  52798. * Creates a cube texture
  52799. * @param rootUrl defines the url where the files to load is located
  52800. * @param scene defines the current scene
  52801. * @param files defines the list of files to load (1 per face)
  52802. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52803. * @param onLoad defines an optional callback raised when the texture is loaded
  52804. * @param onError defines an optional callback raised if there is an issue to load the texture
  52805. * @param format defines the format of the data
  52806. * @param forcedExtension defines the extension to use to pick the right loader
  52807. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52808. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52809. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52810. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52811. * @returns the cube texture as an InternalTexture
  52812. */
  52813. 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;
  52814. private _getSamplingFilter;
  52815. private static _GetNativeTextureFormat;
  52816. createRenderTargetTexture(size: number | {
  52817. width: number;
  52818. height: number;
  52819. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52820. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52821. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52822. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52823. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52824. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52825. /**
  52826. * Updates a dynamic vertex buffer.
  52827. * @param vertexBuffer the vertex buffer to update
  52828. * @param data the data used to update the vertex buffer
  52829. * @param byteOffset the byte offset of the data (optional)
  52830. * @param byteLength the byte length of the data (optional)
  52831. */
  52832. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52833. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52834. private _updateAnisotropicLevel;
  52835. private _getAddressMode;
  52836. /** @hidden */
  52837. _bindTexture(channel: number, texture: InternalTexture): void;
  52838. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52839. releaseEffects(): void;
  52840. /** @hidden */
  52841. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52842. /** @hidden */
  52843. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52844. /** @hidden */
  52845. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52846. /** @hidden */
  52847. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52848. }
  52849. }
  52850. declare module BABYLON {
  52851. /**
  52852. * Gather the list of clipboard event types as constants.
  52853. */
  52854. export class ClipboardEventTypes {
  52855. /**
  52856. * The clipboard event is fired when a copy command is active (pressed).
  52857. */
  52858. static readonly COPY: number;
  52859. /**
  52860. * The clipboard event is fired when a cut command is active (pressed).
  52861. */
  52862. static readonly CUT: number;
  52863. /**
  52864. * The clipboard event is fired when a paste command is active (pressed).
  52865. */
  52866. static readonly PASTE: number;
  52867. }
  52868. /**
  52869. * This class is used to store clipboard related info for the onClipboardObservable event.
  52870. */
  52871. export class ClipboardInfo {
  52872. /**
  52873. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52874. */
  52875. type: number;
  52876. /**
  52877. * Defines the related dom event
  52878. */
  52879. event: ClipboardEvent;
  52880. /**
  52881. *Creates an instance of ClipboardInfo.
  52882. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52883. * @param event Defines the related dom event
  52884. */
  52885. constructor(
  52886. /**
  52887. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52888. */
  52889. type: number,
  52890. /**
  52891. * Defines the related dom event
  52892. */
  52893. event: ClipboardEvent);
  52894. /**
  52895. * Get the clipboard event's type from the keycode.
  52896. * @param keyCode Defines the keyCode for the current keyboard event.
  52897. * @return {number}
  52898. */
  52899. static GetTypeFromCharacter(keyCode: number): number;
  52900. }
  52901. }
  52902. declare module BABYLON {
  52903. /**
  52904. * Google Daydream controller
  52905. */
  52906. export class DaydreamController extends WebVRController {
  52907. /**
  52908. * Base Url for the controller model.
  52909. */
  52910. static MODEL_BASE_URL: string;
  52911. /**
  52912. * File name for the controller model.
  52913. */
  52914. static MODEL_FILENAME: string;
  52915. /**
  52916. * Gamepad Id prefix used to identify Daydream Controller.
  52917. */
  52918. static readonly GAMEPAD_ID_PREFIX: string;
  52919. /**
  52920. * Creates a new DaydreamController from a gamepad
  52921. * @param vrGamepad the gamepad that the controller should be created from
  52922. */
  52923. constructor(vrGamepad: any);
  52924. /**
  52925. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52926. * @param scene scene in which to add meshes
  52927. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52928. */
  52929. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52930. /**
  52931. * Called once for each button that changed state since the last frame
  52932. * @param buttonIdx Which button index changed
  52933. * @param state New state of the button
  52934. * @param changes Which properties on the state changed since last frame
  52935. */
  52936. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52937. }
  52938. }
  52939. declare module BABYLON {
  52940. /**
  52941. * Gear VR Controller
  52942. */
  52943. export class GearVRController extends WebVRController {
  52944. /**
  52945. * Base Url for the controller model.
  52946. */
  52947. static MODEL_BASE_URL: string;
  52948. /**
  52949. * File name for the controller model.
  52950. */
  52951. static MODEL_FILENAME: string;
  52952. /**
  52953. * Gamepad Id prefix used to identify this controller.
  52954. */
  52955. static readonly GAMEPAD_ID_PREFIX: string;
  52956. private readonly _buttonIndexToObservableNameMap;
  52957. /**
  52958. * Creates a new GearVRController from a gamepad
  52959. * @param vrGamepad the gamepad that the controller should be created from
  52960. */
  52961. constructor(vrGamepad: any);
  52962. /**
  52963. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52964. * @param scene scene in which to add meshes
  52965. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52966. */
  52967. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52968. /**
  52969. * Called once for each button that changed state since the last frame
  52970. * @param buttonIdx Which button index changed
  52971. * @param state New state of the button
  52972. * @param changes Which properties on the state changed since last frame
  52973. */
  52974. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52975. }
  52976. }
  52977. declare module BABYLON {
  52978. /**
  52979. * Generic Controller
  52980. */
  52981. export class GenericController extends WebVRController {
  52982. /**
  52983. * Base Url for the controller model.
  52984. */
  52985. static readonly MODEL_BASE_URL: string;
  52986. /**
  52987. * File name for the controller model.
  52988. */
  52989. static readonly MODEL_FILENAME: string;
  52990. /**
  52991. * Creates a new GenericController from a gamepad
  52992. * @param vrGamepad the gamepad that the controller should be created from
  52993. */
  52994. constructor(vrGamepad: any);
  52995. /**
  52996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52997. * @param scene scene in which to add meshes
  52998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52999. */
  53000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53001. /**
  53002. * Called once for each button that changed state since the last frame
  53003. * @param buttonIdx Which button index changed
  53004. * @param state New state of the button
  53005. * @param changes Which properties on the state changed since last frame
  53006. */
  53007. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53008. }
  53009. }
  53010. declare module BABYLON {
  53011. /**
  53012. * Oculus Touch Controller
  53013. */
  53014. export class OculusTouchController extends WebVRController {
  53015. /**
  53016. * Base Url for the controller model.
  53017. */
  53018. static MODEL_BASE_URL: string;
  53019. /**
  53020. * File name for the left controller model.
  53021. */
  53022. static MODEL_LEFT_FILENAME: string;
  53023. /**
  53024. * File name for the right controller model.
  53025. */
  53026. static MODEL_RIGHT_FILENAME: string;
  53027. /**
  53028. * Base Url for the Quest controller model.
  53029. */
  53030. static QUEST_MODEL_BASE_URL: string;
  53031. /**
  53032. * @hidden
  53033. * If the controllers are running on a device that needs the updated Quest controller models
  53034. */
  53035. static _IsQuest: boolean;
  53036. /**
  53037. * Fired when the secondary trigger on this controller is modified
  53038. */
  53039. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53040. /**
  53041. * Fired when the thumb rest on this controller is modified
  53042. */
  53043. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53044. /**
  53045. * Creates a new OculusTouchController from a gamepad
  53046. * @param vrGamepad the gamepad that the controller should be created from
  53047. */
  53048. constructor(vrGamepad: any);
  53049. /**
  53050. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53051. * @param scene scene in which to add meshes
  53052. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53053. */
  53054. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53055. /**
  53056. * Fired when the A button on this controller is modified
  53057. */
  53058. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53059. /**
  53060. * Fired when the B button on this controller is modified
  53061. */
  53062. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53063. /**
  53064. * Fired when the X button on this controller is modified
  53065. */
  53066. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53067. /**
  53068. * Fired when the Y button on this controller is modified
  53069. */
  53070. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53071. /**
  53072. * Called once for each button that changed state since the last frame
  53073. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53074. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53075. * 2) secondary trigger (same)
  53076. * 3) A (right) X (left), touch, pressed = value
  53077. * 4) B / Y
  53078. * 5) thumb rest
  53079. * @param buttonIdx Which button index changed
  53080. * @param state New state of the button
  53081. * @param changes Which properties on the state changed since last frame
  53082. */
  53083. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53084. }
  53085. }
  53086. declare module BABYLON {
  53087. /**
  53088. * Vive Controller
  53089. */
  53090. export class ViveController extends WebVRController {
  53091. /**
  53092. * Base Url for the controller model.
  53093. */
  53094. static MODEL_BASE_URL: string;
  53095. /**
  53096. * File name for the controller model.
  53097. */
  53098. static MODEL_FILENAME: string;
  53099. /**
  53100. * Creates a new ViveController from a gamepad
  53101. * @param vrGamepad the gamepad that the controller should be created from
  53102. */
  53103. constructor(vrGamepad: any);
  53104. /**
  53105. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53106. * @param scene scene in which to add meshes
  53107. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53108. */
  53109. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53110. /**
  53111. * Fired when the left button on this controller is modified
  53112. */
  53113. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53114. /**
  53115. * Fired when the right button on this controller is modified
  53116. */
  53117. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53118. /**
  53119. * Fired when the menu button on this controller is modified
  53120. */
  53121. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53122. /**
  53123. * Called once for each button that changed state since the last frame
  53124. * Vive mapping:
  53125. * 0: touchpad
  53126. * 1: trigger
  53127. * 2: left AND right buttons
  53128. * 3: menu button
  53129. * @param buttonIdx Which button index changed
  53130. * @param state New state of the button
  53131. * @param changes Which properties on the state changed since last frame
  53132. */
  53133. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53134. }
  53135. }
  53136. declare module BABYLON {
  53137. /**
  53138. * Defines the WindowsMotionController object that the state of the windows motion controller
  53139. */
  53140. export class WindowsMotionController extends WebVRController {
  53141. /**
  53142. * The base url used to load the left and right controller models
  53143. */
  53144. static MODEL_BASE_URL: string;
  53145. /**
  53146. * The name of the left controller model file
  53147. */
  53148. static MODEL_LEFT_FILENAME: string;
  53149. /**
  53150. * The name of the right controller model file
  53151. */
  53152. static MODEL_RIGHT_FILENAME: string;
  53153. /**
  53154. * The controller name prefix for this controller type
  53155. */
  53156. static readonly GAMEPAD_ID_PREFIX: string;
  53157. /**
  53158. * The controller id pattern for this controller type
  53159. */
  53160. private static readonly GAMEPAD_ID_PATTERN;
  53161. private _loadedMeshInfo;
  53162. protected readonly _mapping: {
  53163. buttons: string[];
  53164. buttonMeshNames: {
  53165. trigger: string;
  53166. menu: string;
  53167. grip: string;
  53168. thumbstick: string;
  53169. trackpad: string;
  53170. };
  53171. buttonObservableNames: {
  53172. trigger: string;
  53173. menu: string;
  53174. grip: string;
  53175. thumbstick: string;
  53176. trackpad: string;
  53177. };
  53178. axisMeshNames: string[];
  53179. pointingPoseMeshName: string;
  53180. };
  53181. /**
  53182. * Fired when the trackpad on this controller is clicked
  53183. */
  53184. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53185. /**
  53186. * Fired when the trackpad on this controller is modified
  53187. */
  53188. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53189. /**
  53190. * The current x and y values of this controller's trackpad
  53191. */
  53192. trackpad: StickValues;
  53193. /**
  53194. * Creates a new WindowsMotionController from a gamepad
  53195. * @param vrGamepad the gamepad that the controller should be created from
  53196. */
  53197. constructor(vrGamepad: any);
  53198. /**
  53199. * Fired when the trigger on this controller is modified
  53200. */
  53201. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53202. /**
  53203. * Fired when the menu button on this controller is modified
  53204. */
  53205. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53206. /**
  53207. * Fired when the grip button on this controller is modified
  53208. */
  53209. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53210. /**
  53211. * Fired when the thumbstick button on this controller is modified
  53212. */
  53213. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53214. /**
  53215. * Fired when the touchpad button on this controller is modified
  53216. */
  53217. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53218. /**
  53219. * Fired when the touchpad values on this controller are modified
  53220. */
  53221. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53222. protected _updateTrackpad(): void;
  53223. /**
  53224. * Called once per frame by the engine.
  53225. */
  53226. update(): void;
  53227. /**
  53228. * Called once for each button that changed state since the last frame
  53229. * @param buttonIdx Which button index changed
  53230. * @param state New state of the button
  53231. * @param changes Which properties on the state changed since last frame
  53232. */
  53233. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53234. /**
  53235. * Moves the buttons on the controller mesh based on their current state
  53236. * @param buttonName the name of the button to move
  53237. * @param buttonValue the value of the button which determines the buttons new position
  53238. */
  53239. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53240. /**
  53241. * Moves the axis on the controller mesh based on its current state
  53242. * @param axis the index of the axis
  53243. * @param axisValue the value of the axis which determines the meshes new position
  53244. * @hidden
  53245. */
  53246. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53247. /**
  53248. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53249. * @param scene scene in which to add meshes
  53250. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53251. */
  53252. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53253. /**
  53254. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53255. * can be transformed by button presses and axes values, based on this._mapping.
  53256. *
  53257. * @param scene scene in which the meshes exist
  53258. * @param meshes list of meshes that make up the controller model to process
  53259. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53260. */
  53261. private processModel;
  53262. private createMeshInfo;
  53263. /**
  53264. * Gets the ray of the controller in the direction the controller is pointing
  53265. * @param length the length the resulting ray should be
  53266. * @returns a ray in the direction the controller is pointing
  53267. */
  53268. getForwardRay(length?: number): Ray;
  53269. /**
  53270. * Disposes of the controller
  53271. */
  53272. dispose(): void;
  53273. }
  53274. /**
  53275. * This class represents a new windows motion controller in XR.
  53276. */
  53277. export class XRWindowsMotionController extends WindowsMotionController {
  53278. /**
  53279. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53280. */
  53281. protected readonly _mapping: {
  53282. buttons: string[];
  53283. buttonMeshNames: {
  53284. trigger: string;
  53285. menu: string;
  53286. grip: string;
  53287. thumbstick: string;
  53288. trackpad: string;
  53289. };
  53290. buttonObservableNames: {
  53291. trigger: string;
  53292. menu: string;
  53293. grip: string;
  53294. thumbstick: string;
  53295. trackpad: string;
  53296. };
  53297. axisMeshNames: string[];
  53298. pointingPoseMeshName: string;
  53299. };
  53300. /**
  53301. * Construct a new XR-Based windows motion controller
  53302. *
  53303. * @param gamepadInfo the gamepad object from the browser
  53304. */
  53305. constructor(gamepadInfo: any);
  53306. /**
  53307. * holds the thumbstick values (X,Y)
  53308. */
  53309. thumbstickValues: StickValues;
  53310. /**
  53311. * Fired when the thumbstick on this controller is clicked
  53312. */
  53313. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53314. /**
  53315. * Fired when the thumbstick on this controller is modified
  53316. */
  53317. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53318. /**
  53319. * Fired when the touchpad button on this controller is modified
  53320. */
  53321. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53322. /**
  53323. * Fired when the touchpad values on this controller are modified
  53324. */
  53325. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53326. /**
  53327. * Fired when the thumbstick button on this controller is modified
  53328. * here to prevent breaking changes
  53329. */
  53330. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53331. /**
  53332. * updating the thumbstick(!) and not the trackpad.
  53333. * This is named this way due to the difference between WebVR and XR and to avoid
  53334. * changing the parent class.
  53335. */
  53336. protected _updateTrackpad(): void;
  53337. /**
  53338. * Disposes the class with joy
  53339. */
  53340. dispose(): void;
  53341. }
  53342. }
  53343. declare module BABYLON {
  53344. /**
  53345. * Class containing static functions to help procedurally build meshes
  53346. */
  53347. export class PolyhedronBuilder {
  53348. /**
  53349. * Creates a polyhedron mesh
  53350. * * 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
  53351. * * The parameter `size` (positive float, default 1) sets the polygon size
  53352. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53353. * * 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`
  53354. * * 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
  53355. * * 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)`)
  53356. * * 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
  53357. * * 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
  53358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53359. * * 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
  53360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53361. * @param name defines the name of the mesh
  53362. * @param options defines the options used to create the mesh
  53363. * @param scene defines the hosting scene
  53364. * @returns the polyhedron mesh
  53365. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53366. */
  53367. static CreatePolyhedron(name: string, options: {
  53368. type?: number;
  53369. size?: number;
  53370. sizeX?: number;
  53371. sizeY?: number;
  53372. sizeZ?: number;
  53373. custom?: any;
  53374. faceUV?: Vector4[];
  53375. faceColors?: Color4[];
  53376. flat?: boolean;
  53377. updatable?: boolean;
  53378. sideOrientation?: number;
  53379. frontUVs?: Vector4;
  53380. backUVs?: Vector4;
  53381. }, scene?: Nullable<Scene>): Mesh;
  53382. }
  53383. }
  53384. declare module BABYLON {
  53385. /**
  53386. * Gizmo that enables scaling a mesh along 3 axis
  53387. */
  53388. export class ScaleGizmo extends Gizmo {
  53389. /**
  53390. * Internal gizmo used for interactions on the x axis
  53391. */
  53392. xGizmo: AxisScaleGizmo;
  53393. /**
  53394. * Internal gizmo used for interactions on the y axis
  53395. */
  53396. yGizmo: AxisScaleGizmo;
  53397. /**
  53398. * Internal gizmo used for interactions on the z axis
  53399. */
  53400. zGizmo: AxisScaleGizmo;
  53401. /**
  53402. * Internal gizmo used to scale all axis equally
  53403. */
  53404. uniformScaleGizmo: AxisScaleGizmo;
  53405. private _meshAttached;
  53406. private _nodeAttached;
  53407. private _snapDistance;
  53408. private _uniformScalingMesh;
  53409. private _octahedron;
  53410. private _sensitivity;
  53411. /** Fires an event when any of it's sub gizmos are dragged */
  53412. onDragStartObservable: Observable<unknown>;
  53413. /** Fires an event when any of it's sub gizmos are released from dragging */
  53414. onDragEndObservable: Observable<unknown>;
  53415. get attachedMesh(): Nullable<AbstractMesh>;
  53416. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53417. get attachedNode(): Nullable<Node>;
  53418. set attachedNode(node: Nullable<Node>);
  53419. /**
  53420. * Creates a ScaleGizmo
  53421. * @param gizmoLayer The utility layer the gizmo will be added to
  53422. * @param thickness display gizmo axis thickness
  53423. */
  53424. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53425. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53426. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53427. /**
  53428. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53429. */
  53430. set snapDistance(value: number);
  53431. get snapDistance(): number;
  53432. /**
  53433. * Ratio for the scale of the gizmo (Default: 1)
  53434. */
  53435. set scaleRatio(value: number);
  53436. get scaleRatio(): number;
  53437. /**
  53438. * Sensitivity factor for dragging (Default: 1)
  53439. */
  53440. set sensitivity(value: number);
  53441. get sensitivity(): number;
  53442. /**
  53443. * Disposes of the gizmo
  53444. */
  53445. dispose(): void;
  53446. }
  53447. }
  53448. declare module BABYLON {
  53449. /**
  53450. * Single axis scale gizmo
  53451. */
  53452. export class AxisScaleGizmo extends Gizmo {
  53453. /**
  53454. * Drag behavior responsible for the gizmos dragging interactions
  53455. */
  53456. dragBehavior: PointerDragBehavior;
  53457. private _pointerObserver;
  53458. /**
  53459. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53460. */
  53461. snapDistance: number;
  53462. /**
  53463. * Event that fires each time the gizmo snaps to a new location.
  53464. * * snapDistance is the the change in distance
  53465. */
  53466. onSnapObservable: Observable<{
  53467. snapDistance: number;
  53468. }>;
  53469. /**
  53470. * If the scaling operation should be done on all axis (default: false)
  53471. */
  53472. uniformScaling: boolean;
  53473. /**
  53474. * Custom sensitivity value for the drag strength
  53475. */
  53476. sensitivity: number;
  53477. private _isEnabled;
  53478. private _parent;
  53479. private _arrow;
  53480. private _coloredMaterial;
  53481. private _hoverMaterial;
  53482. /**
  53483. * Creates an AxisScaleGizmo
  53484. * @param gizmoLayer The utility layer the gizmo will be added to
  53485. * @param dragAxis The axis which the gizmo will be able to scale on
  53486. * @param color The color of the gizmo
  53487. * @param thickness display gizmo axis thickness
  53488. */
  53489. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53490. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53491. /**
  53492. * If the gizmo is enabled
  53493. */
  53494. set isEnabled(value: boolean);
  53495. get isEnabled(): boolean;
  53496. /**
  53497. * Disposes of the gizmo
  53498. */
  53499. dispose(): void;
  53500. /**
  53501. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53502. * @param mesh The mesh to replace the default mesh of the gizmo
  53503. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53504. */
  53505. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53506. }
  53507. }
  53508. declare module BABYLON {
  53509. /**
  53510. * Bounding box gizmo
  53511. */
  53512. export class BoundingBoxGizmo extends Gizmo {
  53513. private _lineBoundingBox;
  53514. private _rotateSpheresParent;
  53515. private _scaleBoxesParent;
  53516. private _boundingDimensions;
  53517. private _renderObserver;
  53518. private _pointerObserver;
  53519. private _scaleDragSpeed;
  53520. private _tmpQuaternion;
  53521. private _tmpVector;
  53522. private _tmpRotationMatrix;
  53523. /**
  53524. * 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)
  53525. */
  53526. ignoreChildren: boolean;
  53527. /**
  53528. * 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)
  53529. */
  53530. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53531. /**
  53532. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53533. */
  53534. rotationSphereSize: number;
  53535. /**
  53536. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53537. */
  53538. scaleBoxSize: number;
  53539. /**
  53540. * 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)
  53541. */
  53542. fixedDragMeshScreenSize: boolean;
  53543. /**
  53544. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53545. */
  53546. fixedDragMeshScreenSizeDistanceFactor: number;
  53547. /**
  53548. * Fired when a rotation sphere or scale box is dragged
  53549. */
  53550. onDragStartObservable: Observable<{}>;
  53551. /**
  53552. * Fired when a scale box is dragged
  53553. */
  53554. onScaleBoxDragObservable: Observable<{}>;
  53555. /**
  53556. * Fired when a scale box drag is ended
  53557. */
  53558. onScaleBoxDragEndObservable: Observable<{}>;
  53559. /**
  53560. * Fired when a rotation sphere is dragged
  53561. */
  53562. onRotationSphereDragObservable: Observable<{}>;
  53563. /**
  53564. * Fired when a rotation sphere drag is ended
  53565. */
  53566. onRotationSphereDragEndObservable: Observable<{}>;
  53567. /**
  53568. * 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)
  53569. */
  53570. scalePivot: Nullable<Vector3>;
  53571. /**
  53572. * Mesh used as a pivot to rotate the attached node
  53573. */
  53574. private _anchorMesh;
  53575. private _existingMeshScale;
  53576. private _dragMesh;
  53577. private pointerDragBehavior;
  53578. private coloredMaterial;
  53579. private hoverColoredMaterial;
  53580. /**
  53581. * Sets the color of the bounding box gizmo
  53582. * @param color the color to set
  53583. */
  53584. setColor(color: Color3): void;
  53585. /**
  53586. * Creates an BoundingBoxGizmo
  53587. * @param gizmoLayer The utility layer the gizmo will be added to
  53588. * @param color The color of the gizmo
  53589. */
  53590. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53591. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53592. private _selectNode;
  53593. /**
  53594. * Updates the bounding box information for the Gizmo
  53595. */
  53596. updateBoundingBox(): void;
  53597. private _updateRotationSpheres;
  53598. private _updateScaleBoxes;
  53599. /**
  53600. * Enables rotation on the specified axis and disables rotation on the others
  53601. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53602. */
  53603. setEnabledRotationAxis(axis: string): void;
  53604. /**
  53605. * Enables/disables scaling
  53606. * @param enable if scaling should be enabled
  53607. * @param homogeneousScaling defines if scaling should only be homogeneous
  53608. */
  53609. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53610. private _updateDummy;
  53611. /**
  53612. * Enables a pointer drag behavior on the bounding box of the gizmo
  53613. */
  53614. enableDragBehavior(): void;
  53615. /**
  53616. * Disposes of the gizmo
  53617. */
  53618. dispose(): void;
  53619. /**
  53620. * 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)
  53621. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53622. * @returns the bounding box mesh with the passed in mesh as a child
  53623. */
  53624. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53625. /**
  53626. * CustomMeshes are not supported by this gizmo
  53627. * @param mesh The mesh to replace the default mesh of the gizmo
  53628. */
  53629. setCustomMesh(mesh: Mesh): void;
  53630. }
  53631. }
  53632. declare module BABYLON {
  53633. /**
  53634. * Single plane rotation gizmo
  53635. */
  53636. export class PlaneRotationGizmo extends Gizmo {
  53637. /**
  53638. * Drag behavior responsible for the gizmos dragging interactions
  53639. */
  53640. dragBehavior: PointerDragBehavior;
  53641. private _pointerObserver;
  53642. /**
  53643. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53644. */
  53645. snapDistance: number;
  53646. /**
  53647. * Event that fires each time the gizmo snaps to a new location.
  53648. * * snapDistance is the the change in distance
  53649. */
  53650. onSnapObservable: Observable<{
  53651. snapDistance: number;
  53652. }>;
  53653. private _isEnabled;
  53654. private _parent;
  53655. /**
  53656. * Creates a PlaneRotationGizmo
  53657. * @param gizmoLayer The utility layer the gizmo will be added to
  53658. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53659. * @param color The color of the gizmo
  53660. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53661. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53662. * @param thickness display gizmo axis thickness
  53663. */
  53664. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53665. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53666. /**
  53667. * If the gizmo is enabled
  53668. */
  53669. set isEnabled(value: boolean);
  53670. get isEnabled(): boolean;
  53671. /**
  53672. * Disposes of the gizmo
  53673. */
  53674. dispose(): void;
  53675. }
  53676. }
  53677. declare module BABYLON {
  53678. /**
  53679. * Gizmo that enables rotating a mesh along 3 axis
  53680. */
  53681. export class RotationGizmo extends Gizmo {
  53682. /**
  53683. * Internal gizmo used for interactions on the x axis
  53684. */
  53685. xGizmo: PlaneRotationGizmo;
  53686. /**
  53687. * Internal gizmo used for interactions on the y axis
  53688. */
  53689. yGizmo: PlaneRotationGizmo;
  53690. /**
  53691. * Internal gizmo used for interactions on the z axis
  53692. */
  53693. zGizmo: PlaneRotationGizmo;
  53694. /** Fires an event when any of it's sub gizmos are dragged */
  53695. onDragStartObservable: Observable<unknown>;
  53696. /** Fires an event when any of it's sub gizmos are released from dragging */
  53697. onDragEndObservable: Observable<unknown>;
  53698. private _meshAttached;
  53699. private _nodeAttached;
  53700. get attachedMesh(): Nullable<AbstractMesh>;
  53701. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53702. get attachedNode(): Nullable<Node>;
  53703. set attachedNode(node: Nullable<Node>);
  53704. /**
  53705. * Creates a RotationGizmo
  53706. * @param gizmoLayer The utility layer the gizmo will be added to
  53707. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53708. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53709. * @param thickness display gizmo axis thickness
  53710. */
  53711. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53712. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53713. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53714. /**
  53715. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53716. */
  53717. set snapDistance(value: number);
  53718. get snapDistance(): number;
  53719. /**
  53720. * Ratio for the scale of the gizmo (Default: 1)
  53721. */
  53722. set scaleRatio(value: number);
  53723. get scaleRatio(): number;
  53724. /**
  53725. * Disposes of the gizmo
  53726. */
  53727. dispose(): void;
  53728. /**
  53729. * CustomMeshes are not supported by this gizmo
  53730. * @param mesh The mesh to replace the default mesh of the gizmo
  53731. */
  53732. setCustomMesh(mesh: Mesh): void;
  53733. }
  53734. }
  53735. declare module BABYLON {
  53736. /**
  53737. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  53738. */
  53739. export class GizmoManager implements IDisposable {
  53740. private scene;
  53741. /**
  53742. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53743. */
  53744. gizmos: {
  53745. positionGizmo: Nullable<PositionGizmo>;
  53746. rotationGizmo: Nullable<RotationGizmo>;
  53747. scaleGizmo: Nullable<ScaleGizmo>;
  53748. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53749. };
  53750. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53751. clearGizmoOnEmptyPointerEvent: boolean;
  53752. /** Fires an event when the manager is attached to a mesh */
  53753. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53754. /** Fires an event when the manager is attached to a node */
  53755. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  53756. private _gizmosEnabled;
  53757. private _pointerObserver;
  53758. private _attachedMesh;
  53759. private _attachedNode;
  53760. private _boundingBoxColor;
  53761. private _defaultUtilityLayer;
  53762. private _defaultKeepDepthUtilityLayer;
  53763. private _thickness;
  53764. /**
  53765. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53766. */
  53767. boundingBoxDragBehavior: SixDofDragBehavior;
  53768. /**
  53769. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53770. */
  53771. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53772. /**
  53773. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  53774. */
  53775. attachableNodes: Nullable<Array<Node>>;
  53776. /**
  53777. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  53778. */
  53779. usePointerToAttachGizmos: boolean;
  53780. /**
  53781. * Utility layer that the bounding box gizmo belongs to
  53782. */
  53783. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53784. /**
  53785. * Utility layer that all gizmos besides bounding box belong to
  53786. */
  53787. get utilityLayer(): UtilityLayerRenderer;
  53788. /**
  53789. * Instatiates a gizmo manager
  53790. * @param scene the scene to overlay the gizmos on top of
  53791. * @param thickness display gizmo axis thickness
  53792. */
  53793. constructor(scene: Scene, thickness?: number);
  53794. /**
  53795. * Attaches a set of gizmos to the specified mesh
  53796. * @param mesh The mesh the gizmo's should be attached to
  53797. */
  53798. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53799. /**
  53800. * Attaches a set of gizmos to the specified node
  53801. * @param node The node the gizmo's should be attached to
  53802. */
  53803. attachToNode(node: Nullable<Node>): void;
  53804. /**
  53805. * If the position gizmo is enabled
  53806. */
  53807. set positionGizmoEnabled(value: boolean);
  53808. get positionGizmoEnabled(): boolean;
  53809. /**
  53810. * If the rotation gizmo is enabled
  53811. */
  53812. set rotationGizmoEnabled(value: boolean);
  53813. get rotationGizmoEnabled(): boolean;
  53814. /**
  53815. * If the scale gizmo is enabled
  53816. */
  53817. set scaleGizmoEnabled(value: boolean);
  53818. get scaleGizmoEnabled(): boolean;
  53819. /**
  53820. * If the boundingBox gizmo is enabled
  53821. */
  53822. set boundingBoxGizmoEnabled(value: boolean);
  53823. get boundingBoxGizmoEnabled(): boolean;
  53824. /**
  53825. * Disposes of the gizmo manager
  53826. */
  53827. dispose(): void;
  53828. }
  53829. }
  53830. declare module BABYLON {
  53831. /**
  53832. * A directional light is defined by a direction (what a surprise!).
  53833. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53834. * 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.
  53835. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53836. */
  53837. export class DirectionalLight extends ShadowLight {
  53838. private _shadowFrustumSize;
  53839. /**
  53840. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53841. */
  53842. get shadowFrustumSize(): number;
  53843. /**
  53844. * Specifies a fix frustum size for the shadow generation.
  53845. */
  53846. set shadowFrustumSize(value: number);
  53847. private _shadowOrthoScale;
  53848. /**
  53849. * Gets the shadow projection scale against the optimal computed one.
  53850. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53851. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53852. */
  53853. get shadowOrthoScale(): number;
  53854. /**
  53855. * Sets the shadow projection scale against the optimal computed one.
  53856. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53857. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53858. */
  53859. set shadowOrthoScale(value: number);
  53860. /**
  53861. * Automatically compute the projection matrix to best fit (including all the casters)
  53862. * on each frame.
  53863. */
  53864. autoUpdateExtends: boolean;
  53865. /**
  53866. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53867. * on each frame. autoUpdateExtends must be set to true for this to work
  53868. */
  53869. autoCalcShadowZBounds: boolean;
  53870. private _orthoLeft;
  53871. private _orthoRight;
  53872. private _orthoTop;
  53873. private _orthoBottom;
  53874. /**
  53875. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53876. * The directional light is emitted from everywhere in the given direction.
  53877. * It can cast shadows.
  53878. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53879. * @param name The friendly name of the light
  53880. * @param direction The direction of the light
  53881. * @param scene The scene the light belongs to
  53882. */
  53883. constructor(name: string, direction: Vector3, scene: Scene);
  53884. /**
  53885. * Returns the string "DirectionalLight".
  53886. * @return The class name
  53887. */
  53888. getClassName(): string;
  53889. /**
  53890. * Returns the integer 1.
  53891. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53892. */
  53893. getTypeID(): number;
  53894. /**
  53895. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53896. * Returns the DirectionalLight Shadow projection matrix.
  53897. */
  53898. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53899. /**
  53900. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53901. * Returns the DirectionalLight Shadow projection matrix.
  53902. */
  53903. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53904. /**
  53905. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53906. * Returns the DirectionalLight Shadow projection matrix.
  53907. */
  53908. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53909. protected _buildUniformLayout(): void;
  53910. /**
  53911. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53912. * @param effect The effect to update
  53913. * @param lightIndex The index of the light in the effect to update
  53914. * @returns The directional light
  53915. */
  53916. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53917. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53918. /**
  53919. * Gets the minZ used for shadow according to both the scene and the light.
  53920. *
  53921. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53922. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53923. * @param activeCamera The camera we are returning the min for
  53924. * @returns the depth min z
  53925. */
  53926. getDepthMinZ(activeCamera: Camera): number;
  53927. /**
  53928. * Gets the maxZ used for shadow according to both the scene and the light.
  53929. *
  53930. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53931. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53932. * @param activeCamera The camera we are returning the max for
  53933. * @returns the depth max z
  53934. */
  53935. getDepthMaxZ(activeCamera: Camera): number;
  53936. /**
  53937. * Prepares the list of defines specific to the light type.
  53938. * @param defines the list of defines
  53939. * @param lightIndex defines the index of the light for the effect
  53940. */
  53941. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53942. }
  53943. }
  53944. declare module BABYLON {
  53945. /**
  53946. * Class containing static functions to help procedurally build meshes
  53947. */
  53948. export class HemisphereBuilder {
  53949. /**
  53950. * Creates a hemisphere mesh
  53951. * @param name defines the name of the mesh
  53952. * @param options defines the options used to create the mesh
  53953. * @param scene defines the hosting scene
  53954. * @returns the hemisphere mesh
  53955. */
  53956. static CreateHemisphere(name: string, options: {
  53957. segments?: number;
  53958. diameter?: number;
  53959. sideOrientation?: number;
  53960. }, scene: any): Mesh;
  53961. }
  53962. }
  53963. declare module BABYLON {
  53964. /**
  53965. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53966. * These values define a cone of light starting from the position, emitting toward the direction.
  53967. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53968. * and the exponent defines the speed of the decay of the light with distance (reach).
  53969. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53970. */
  53971. export class SpotLight extends ShadowLight {
  53972. private _angle;
  53973. private _innerAngle;
  53974. private _cosHalfAngle;
  53975. private _lightAngleScale;
  53976. private _lightAngleOffset;
  53977. /**
  53978. * Gets the cone angle of the spot light in Radians.
  53979. */
  53980. get angle(): number;
  53981. /**
  53982. * Sets the cone angle of the spot light in Radians.
  53983. */
  53984. set angle(value: number);
  53985. /**
  53986. * Only used in gltf falloff mode, this defines the angle where
  53987. * the directional falloff will start before cutting at angle which could be seen
  53988. * as outer angle.
  53989. */
  53990. get innerAngle(): number;
  53991. /**
  53992. * Only used in gltf falloff mode, this defines the angle where
  53993. * the directional falloff will start before cutting at angle which could be seen
  53994. * as outer angle.
  53995. */
  53996. set innerAngle(value: number);
  53997. private _shadowAngleScale;
  53998. /**
  53999. * Allows scaling the angle of the light for shadow generation only.
  54000. */
  54001. get shadowAngleScale(): number;
  54002. /**
  54003. * Allows scaling the angle of the light for shadow generation only.
  54004. */
  54005. set shadowAngleScale(value: number);
  54006. /**
  54007. * The light decay speed with the distance from the emission spot.
  54008. */
  54009. exponent: number;
  54010. private _projectionTextureMatrix;
  54011. /**
  54012. * Allows reading the projecton texture
  54013. */
  54014. get projectionTextureMatrix(): Matrix;
  54015. protected _projectionTextureLightNear: number;
  54016. /**
  54017. * Gets the near clip of the Spotlight for texture projection.
  54018. */
  54019. get projectionTextureLightNear(): number;
  54020. /**
  54021. * Sets the near clip of the Spotlight for texture projection.
  54022. */
  54023. set projectionTextureLightNear(value: number);
  54024. protected _projectionTextureLightFar: number;
  54025. /**
  54026. * Gets the far clip of the Spotlight for texture projection.
  54027. */
  54028. get projectionTextureLightFar(): number;
  54029. /**
  54030. * Sets the far clip of the Spotlight for texture projection.
  54031. */
  54032. set projectionTextureLightFar(value: number);
  54033. protected _projectionTextureUpDirection: Vector3;
  54034. /**
  54035. * Gets the Up vector of the Spotlight for texture projection.
  54036. */
  54037. get projectionTextureUpDirection(): Vector3;
  54038. /**
  54039. * Sets the Up vector of the Spotlight for texture projection.
  54040. */
  54041. set projectionTextureUpDirection(value: Vector3);
  54042. private _projectionTexture;
  54043. /**
  54044. * Gets the projection texture of the light.
  54045. */
  54046. get projectionTexture(): Nullable<BaseTexture>;
  54047. /**
  54048. * Sets the projection texture of the light.
  54049. */
  54050. set projectionTexture(value: Nullable<BaseTexture>);
  54051. private _projectionTextureViewLightDirty;
  54052. private _projectionTextureProjectionLightDirty;
  54053. private _projectionTextureDirty;
  54054. private _projectionTextureViewTargetVector;
  54055. private _projectionTextureViewLightMatrix;
  54056. private _projectionTextureProjectionLightMatrix;
  54057. private _projectionTextureScalingMatrix;
  54058. /**
  54059. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54060. * It can cast shadows.
  54061. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54062. * @param name The light friendly name
  54063. * @param position The position of the spot light in the scene
  54064. * @param direction The direction of the light in the scene
  54065. * @param angle The cone angle of the light in Radians
  54066. * @param exponent The light decay speed with the distance from the emission spot
  54067. * @param scene The scene the lights belongs to
  54068. */
  54069. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54070. /**
  54071. * Returns the string "SpotLight".
  54072. * @returns the class name
  54073. */
  54074. getClassName(): string;
  54075. /**
  54076. * Returns the integer 2.
  54077. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54078. */
  54079. getTypeID(): number;
  54080. /**
  54081. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54082. */
  54083. protected _setDirection(value: Vector3): void;
  54084. /**
  54085. * Overrides the position setter to recompute the projection texture view light Matrix.
  54086. */
  54087. protected _setPosition(value: Vector3): void;
  54088. /**
  54089. * 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.
  54090. * Returns the SpotLight.
  54091. */
  54092. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54093. protected _computeProjectionTextureViewLightMatrix(): void;
  54094. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54095. /**
  54096. * Main function for light texture projection matrix computing.
  54097. */
  54098. protected _computeProjectionTextureMatrix(): void;
  54099. protected _buildUniformLayout(): void;
  54100. private _computeAngleValues;
  54101. /**
  54102. * Sets the passed Effect "effect" with the Light textures.
  54103. * @param effect The effect to update
  54104. * @param lightIndex The index of the light in the effect to update
  54105. * @returns The light
  54106. */
  54107. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54108. /**
  54109. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54110. * @param effect The effect to update
  54111. * @param lightIndex The index of the light in the effect to update
  54112. * @returns The spot light
  54113. */
  54114. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54115. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54116. /**
  54117. * Disposes the light and the associated resources.
  54118. */
  54119. dispose(): void;
  54120. /**
  54121. * Prepares the list of defines specific to the light type.
  54122. * @param defines the list of defines
  54123. * @param lightIndex defines the index of the light for the effect
  54124. */
  54125. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54126. }
  54127. }
  54128. declare module BABYLON {
  54129. /**
  54130. * Gizmo that enables viewing a light
  54131. */
  54132. export class LightGizmo extends Gizmo {
  54133. private _lightMesh;
  54134. private _material;
  54135. private _cachedPosition;
  54136. private _cachedForward;
  54137. private _attachedMeshParent;
  54138. /**
  54139. * Creates a LightGizmo
  54140. * @param gizmoLayer The utility layer the gizmo will be added to
  54141. */
  54142. constructor(gizmoLayer?: UtilityLayerRenderer);
  54143. private _light;
  54144. /**
  54145. * The light that the gizmo is attached to
  54146. */
  54147. set light(light: Nullable<Light>);
  54148. get light(): Nullable<Light>;
  54149. /**
  54150. * Gets the material used to render the light gizmo
  54151. */
  54152. get material(): StandardMaterial;
  54153. /**
  54154. * @hidden
  54155. * Updates the gizmo to match the attached mesh's position/rotation
  54156. */
  54157. protected _update(): void;
  54158. private static _Scale;
  54159. /**
  54160. * Creates the lines for a light mesh
  54161. */
  54162. private static _CreateLightLines;
  54163. /**
  54164. * Disposes of the light gizmo
  54165. */
  54166. dispose(): void;
  54167. private static _CreateHemisphericLightMesh;
  54168. private static _CreatePointLightMesh;
  54169. private static _CreateSpotLightMesh;
  54170. private static _CreateDirectionalLightMesh;
  54171. }
  54172. }
  54173. declare module BABYLON {
  54174. /**
  54175. * Gizmo that enables viewing a camera
  54176. */
  54177. export class CameraGizmo extends Gizmo {
  54178. private _cameraMesh;
  54179. private _cameraLinesMesh;
  54180. private _material;
  54181. /**
  54182. * Creates a CameraGizmo
  54183. * @param gizmoLayer The utility layer the gizmo will be added to
  54184. */
  54185. constructor(gizmoLayer?: UtilityLayerRenderer);
  54186. private _camera;
  54187. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54188. get displayFrustum(): boolean;
  54189. set displayFrustum(value: boolean);
  54190. /**
  54191. * The camera that the gizmo is attached to
  54192. */
  54193. set camera(camera: Nullable<Camera>);
  54194. get camera(): Nullable<Camera>;
  54195. /**
  54196. * Gets the material used to render the camera gizmo
  54197. */
  54198. get material(): StandardMaterial;
  54199. /**
  54200. * @hidden
  54201. * Updates the gizmo to match the attached mesh's position/rotation
  54202. */
  54203. protected _update(): void;
  54204. private static _Scale;
  54205. private _invProjection;
  54206. /**
  54207. * Disposes of the camera gizmo
  54208. */
  54209. dispose(): void;
  54210. private static _CreateCameraMesh;
  54211. private static _CreateCameraFrustum;
  54212. }
  54213. }
  54214. declare module BABYLON {
  54215. /** @hidden */
  54216. export var backgroundFragmentDeclaration: {
  54217. name: string;
  54218. shader: string;
  54219. };
  54220. }
  54221. declare module BABYLON {
  54222. /** @hidden */
  54223. export var backgroundUboDeclaration: {
  54224. name: string;
  54225. shader: string;
  54226. };
  54227. }
  54228. declare module BABYLON {
  54229. /** @hidden */
  54230. export var backgroundPixelShader: {
  54231. name: string;
  54232. shader: string;
  54233. };
  54234. }
  54235. declare module BABYLON {
  54236. /** @hidden */
  54237. export var backgroundVertexDeclaration: {
  54238. name: string;
  54239. shader: string;
  54240. };
  54241. }
  54242. declare module BABYLON {
  54243. /** @hidden */
  54244. export var backgroundVertexShader: {
  54245. name: string;
  54246. shader: string;
  54247. };
  54248. }
  54249. declare module BABYLON {
  54250. /**
  54251. * Background material used to create an efficient environement around your scene.
  54252. */
  54253. export class BackgroundMaterial extends PushMaterial {
  54254. /**
  54255. * Standard reflectance value at parallel view angle.
  54256. */
  54257. static StandardReflectance0: number;
  54258. /**
  54259. * Standard reflectance value at grazing angle.
  54260. */
  54261. static StandardReflectance90: number;
  54262. protected _primaryColor: Color3;
  54263. /**
  54264. * Key light Color (multiply against the environement texture)
  54265. */
  54266. primaryColor: Color3;
  54267. protected __perceptualColor: Nullable<Color3>;
  54268. /**
  54269. * Experimental Internal Use Only.
  54270. *
  54271. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54272. * This acts as a helper to set the primary color to a more "human friendly" value.
  54273. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54274. * output color as close as possible from the chosen value.
  54275. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54276. * part of lighting setup.)
  54277. */
  54278. get _perceptualColor(): Nullable<Color3>;
  54279. set _perceptualColor(value: Nullable<Color3>);
  54280. protected _primaryColorShadowLevel: float;
  54281. /**
  54282. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54283. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54284. */
  54285. get primaryColorShadowLevel(): float;
  54286. set primaryColorShadowLevel(value: float);
  54287. protected _primaryColorHighlightLevel: float;
  54288. /**
  54289. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54290. * The primary color is used at the level chosen to define what the white area would look.
  54291. */
  54292. get primaryColorHighlightLevel(): float;
  54293. set primaryColorHighlightLevel(value: float);
  54294. protected _reflectionTexture: Nullable<BaseTexture>;
  54295. /**
  54296. * Reflection Texture used in the material.
  54297. * Should be author in a specific way for the best result (refer to the documentation).
  54298. */
  54299. reflectionTexture: Nullable<BaseTexture>;
  54300. protected _reflectionBlur: float;
  54301. /**
  54302. * Reflection Texture level of blur.
  54303. *
  54304. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54305. * texture twice.
  54306. */
  54307. reflectionBlur: float;
  54308. protected _diffuseTexture: Nullable<BaseTexture>;
  54309. /**
  54310. * Diffuse Texture used in the material.
  54311. * Should be author in a specific way for the best result (refer to the documentation).
  54312. */
  54313. diffuseTexture: Nullable<BaseTexture>;
  54314. protected _shadowLights: Nullable<IShadowLight[]>;
  54315. /**
  54316. * Specify the list of lights casting shadow on the material.
  54317. * All scene shadow lights will be included if null.
  54318. */
  54319. shadowLights: Nullable<IShadowLight[]>;
  54320. protected _shadowLevel: float;
  54321. /**
  54322. * Helps adjusting the shadow to a softer level if required.
  54323. * 0 means black shadows and 1 means no shadows.
  54324. */
  54325. shadowLevel: float;
  54326. protected _sceneCenter: Vector3;
  54327. /**
  54328. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54329. * It is usually zero but might be interesting to modify according to your setup.
  54330. */
  54331. sceneCenter: Vector3;
  54332. protected _opacityFresnel: boolean;
  54333. /**
  54334. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54335. * This helps ensuring a nice transition when the camera goes under the ground.
  54336. */
  54337. opacityFresnel: boolean;
  54338. protected _reflectionFresnel: boolean;
  54339. /**
  54340. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54341. * This helps adding a mirror texture on the ground.
  54342. */
  54343. reflectionFresnel: boolean;
  54344. protected _reflectionFalloffDistance: number;
  54345. /**
  54346. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54347. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54348. */
  54349. reflectionFalloffDistance: number;
  54350. protected _reflectionAmount: number;
  54351. /**
  54352. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54353. */
  54354. reflectionAmount: number;
  54355. protected _reflectionReflectance0: number;
  54356. /**
  54357. * This specifies the weight of the reflection at grazing angle.
  54358. */
  54359. reflectionReflectance0: number;
  54360. protected _reflectionReflectance90: number;
  54361. /**
  54362. * This specifies the weight of the reflection at a perpendicular point of view.
  54363. */
  54364. reflectionReflectance90: number;
  54365. /**
  54366. * Sets the reflection reflectance fresnel values according to the default standard
  54367. * empirically know to work well :-)
  54368. */
  54369. set reflectionStandardFresnelWeight(value: number);
  54370. protected _useRGBColor: boolean;
  54371. /**
  54372. * Helps to directly use the maps channels instead of their level.
  54373. */
  54374. useRGBColor: boolean;
  54375. protected _enableNoise: boolean;
  54376. /**
  54377. * This helps reducing the banding effect that could occur on the background.
  54378. */
  54379. enableNoise: boolean;
  54380. /**
  54381. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54382. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54383. * Recommended to be keep at 1.0 except for special cases.
  54384. */
  54385. get fovMultiplier(): number;
  54386. set fovMultiplier(value: number);
  54387. private _fovMultiplier;
  54388. /**
  54389. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54390. */
  54391. useEquirectangularFOV: boolean;
  54392. private _maxSimultaneousLights;
  54393. /**
  54394. * Number of Simultaneous lights allowed on the material.
  54395. */
  54396. maxSimultaneousLights: int;
  54397. private _shadowOnly;
  54398. /**
  54399. * Make the material only render shadows
  54400. */
  54401. shadowOnly: boolean;
  54402. /**
  54403. * Default configuration related to image processing available in the Background Material.
  54404. */
  54405. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54406. /**
  54407. * Keep track of the image processing observer to allow dispose and replace.
  54408. */
  54409. private _imageProcessingObserver;
  54410. /**
  54411. * Attaches a new image processing configuration to the PBR Material.
  54412. * @param configuration (if null the scene configuration will be use)
  54413. */
  54414. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54415. /**
  54416. * Gets the image processing configuration used either in this material.
  54417. */
  54418. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54419. /**
  54420. * Sets the Default image processing configuration used either in the this material.
  54421. *
  54422. * If sets to null, the scene one is in use.
  54423. */
  54424. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54425. /**
  54426. * Gets wether the color curves effect is enabled.
  54427. */
  54428. get cameraColorCurvesEnabled(): boolean;
  54429. /**
  54430. * Sets wether the color curves effect is enabled.
  54431. */
  54432. set cameraColorCurvesEnabled(value: boolean);
  54433. /**
  54434. * Gets wether the color grading effect is enabled.
  54435. */
  54436. get cameraColorGradingEnabled(): boolean;
  54437. /**
  54438. * Gets wether the color grading effect is enabled.
  54439. */
  54440. set cameraColorGradingEnabled(value: boolean);
  54441. /**
  54442. * Gets wether tonemapping is enabled or not.
  54443. */
  54444. get cameraToneMappingEnabled(): boolean;
  54445. /**
  54446. * Sets wether tonemapping is enabled or not
  54447. */
  54448. set cameraToneMappingEnabled(value: boolean);
  54449. /**
  54450. * The camera exposure used on this material.
  54451. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54452. * This corresponds to a photographic exposure.
  54453. */
  54454. get cameraExposure(): float;
  54455. /**
  54456. * The camera exposure used on this material.
  54457. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54458. * This corresponds to a photographic exposure.
  54459. */
  54460. set cameraExposure(value: float);
  54461. /**
  54462. * Gets The camera contrast used on this material.
  54463. */
  54464. get cameraContrast(): float;
  54465. /**
  54466. * Sets The camera contrast used on this material.
  54467. */
  54468. set cameraContrast(value: float);
  54469. /**
  54470. * Gets the Color Grading 2D Lookup Texture.
  54471. */
  54472. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54473. /**
  54474. * Sets the Color Grading 2D Lookup Texture.
  54475. */
  54476. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54477. /**
  54478. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54479. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54480. * 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;
  54481. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54482. */
  54483. get cameraColorCurves(): Nullable<ColorCurves>;
  54484. /**
  54485. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54486. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54487. * 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;
  54488. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54489. */
  54490. set cameraColorCurves(value: Nullable<ColorCurves>);
  54491. /**
  54492. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54493. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54494. */
  54495. switchToBGR: boolean;
  54496. private _renderTargets;
  54497. private _reflectionControls;
  54498. private _white;
  54499. private _primaryShadowColor;
  54500. private _primaryHighlightColor;
  54501. /**
  54502. * Instantiates a Background Material in the given scene
  54503. * @param name The friendly name of the material
  54504. * @param scene The scene to add the material to
  54505. */
  54506. constructor(name: string, scene: Scene);
  54507. /**
  54508. * Gets a boolean indicating that current material needs to register RTT
  54509. */
  54510. get hasRenderTargetTextures(): boolean;
  54511. /**
  54512. * The entire material has been created in order to prevent overdraw.
  54513. * @returns false
  54514. */
  54515. needAlphaTesting(): boolean;
  54516. /**
  54517. * The entire material has been created in order to prevent overdraw.
  54518. * @returns true if blending is enable
  54519. */
  54520. needAlphaBlending(): boolean;
  54521. /**
  54522. * Checks wether the material is ready to be rendered for a given mesh.
  54523. * @param mesh The mesh to render
  54524. * @param subMesh The submesh to check against
  54525. * @param useInstances Specify wether or not the material is used with instances
  54526. * @returns true if all the dependencies are ready (Textures, Effects...)
  54527. */
  54528. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54529. /**
  54530. * Compute the primary color according to the chosen perceptual color.
  54531. */
  54532. private _computePrimaryColorFromPerceptualColor;
  54533. /**
  54534. * Compute the highlights and shadow colors according to their chosen levels.
  54535. */
  54536. private _computePrimaryColors;
  54537. /**
  54538. * Build the uniform buffer used in the material.
  54539. */
  54540. buildUniformLayout(): void;
  54541. /**
  54542. * Unbind the material.
  54543. */
  54544. unbind(): void;
  54545. /**
  54546. * Bind only the world matrix to the material.
  54547. * @param world The world matrix to bind.
  54548. */
  54549. bindOnlyWorldMatrix(world: Matrix): void;
  54550. /**
  54551. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54552. * @param world The world matrix to bind.
  54553. * @param subMesh The submesh to bind for.
  54554. */
  54555. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54556. /**
  54557. * Checks to see if a texture is used in the material.
  54558. * @param texture - Base texture to use.
  54559. * @returns - Boolean specifying if a texture is used in the material.
  54560. */
  54561. hasTexture(texture: BaseTexture): boolean;
  54562. /**
  54563. * Dispose the material.
  54564. * @param forceDisposeEffect Force disposal of the associated effect.
  54565. * @param forceDisposeTextures Force disposal of the associated textures.
  54566. */
  54567. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54568. /**
  54569. * Clones the material.
  54570. * @param name The cloned name.
  54571. * @returns The cloned material.
  54572. */
  54573. clone(name: string): BackgroundMaterial;
  54574. /**
  54575. * Serializes the current material to its JSON representation.
  54576. * @returns The JSON representation.
  54577. */
  54578. serialize(): any;
  54579. /**
  54580. * Gets the class name of the material
  54581. * @returns "BackgroundMaterial"
  54582. */
  54583. getClassName(): string;
  54584. /**
  54585. * Parse a JSON input to create back a background material.
  54586. * @param source The JSON data to parse
  54587. * @param scene The scene to create the parsed material in
  54588. * @param rootUrl The root url of the assets the material depends upon
  54589. * @returns the instantiated BackgroundMaterial.
  54590. */
  54591. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54592. }
  54593. }
  54594. declare module BABYLON {
  54595. /**
  54596. * Represents the different options available during the creation of
  54597. * a Environment helper.
  54598. *
  54599. * This can control the default ground, skybox and image processing setup of your scene.
  54600. */
  54601. export interface IEnvironmentHelperOptions {
  54602. /**
  54603. * Specifies whether or not to create a ground.
  54604. * True by default.
  54605. */
  54606. createGround: boolean;
  54607. /**
  54608. * Specifies the ground size.
  54609. * 15 by default.
  54610. */
  54611. groundSize: number;
  54612. /**
  54613. * The texture used on the ground for the main color.
  54614. * Comes from the BabylonJS CDN by default.
  54615. *
  54616. * Remarks: Can be either a texture or a url.
  54617. */
  54618. groundTexture: string | BaseTexture;
  54619. /**
  54620. * The color mixed in the ground texture by default.
  54621. * BabylonJS clearColor by default.
  54622. */
  54623. groundColor: Color3;
  54624. /**
  54625. * Specifies the ground opacity.
  54626. * 1 by default.
  54627. */
  54628. groundOpacity: number;
  54629. /**
  54630. * Enables the ground to receive shadows.
  54631. * True by default.
  54632. */
  54633. enableGroundShadow: boolean;
  54634. /**
  54635. * Helps preventing the shadow to be fully black on the ground.
  54636. * 0.5 by default.
  54637. */
  54638. groundShadowLevel: number;
  54639. /**
  54640. * Creates a mirror texture attach to the ground.
  54641. * false by default.
  54642. */
  54643. enableGroundMirror: boolean;
  54644. /**
  54645. * Specifies the ground mirror size ratio.
  54646. * 0.3 by default as the default kernel is 64.
  54647. */
  54648. groundMirrorSizeRatio: number;
  54649. /**
  54650. * Specifies the ground mirror blur kernel size.
  54651. * 64 by default.
  54652. */
  54653. groundMirrorBlurKernel: number;
  54654. /**
  54655. * Specifies the ground mirror visibility amount.
  54656. * 1 by default
  54657. */
  54658. groundMirrorAmount: number;
  54659. /**
  54660. * Specifies the ground mirror reflectance weight.
  54661. * This uses the standard weight of the background material to setup the fresnel effect
  54662. * of the mirror.
  54663. * 1 by default.
  54664. */
  54665. groundMirrorFresnelWeight: number;
  54666. /**
  54667. * Specifies the ground mirror Falloff distance.
  54668. * This can helps reducing the size of the reflection.
  54669. * 0 by Default.
  54670. */
  54671. groundMirrorFallOffDistance: number;
  54672. /**
  54673. * Specifies the ground mirror texture type.
  54674. * Unsigned Int by Default.
  54675. */
  54676. groundMirrorTextureType: number;
  54677. /**
  54678. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54679. * the shown objects.
  54680. */
  54681. groundYBias: number;
  54682. /**
  54683. * Specifies whether or not to create a skybox.
  54684. * True by default.
  54685. */
  54686. createSkybox: boolean;
  54687. /**
  54688. * Specifies the skybox size.
  54689. * 20 by default.
  54690. */
  54691. skyboxSize: number;
  54692. /**
  54693. * The texture used on the skybox for the main color.
  54694. * Comes from the BabylonJS CDN by default.
  54695. *
  54696. * Remarks: Can be either a texture or a url.
  54697. */
  54698. skyboxTexture: string | BaseTexture;
  54699. /**
  54700. * The color mixed in the skybox texture by default.
  54701. * BabylonJS clearColor by default.
  54702. */
  54703. skyboxColor: Color3;
  54704. /**
  54705. * The background rotation around the Y axis of the scene.
  54706. * This helps aligning the key lights of your scene with the background.
  54707. * 0 by default.
  54708. */
  54709. backgroundYRotation: number;
  54710. /**
  54711. * Compute automatically the size of the elements to best fit with the scene.
  54712. */
  54713. sizeAuto: boolean;
  54714. /**
  54715. * Default position of the rootMesh if autoSize is not true.
  54716. */
  54717. rootPosition: Vector3;
  54718. /**
  54719. * Sets up the image processing in the scene.
  54720. * true by default.
  54721. */
  54722. setupImageProcessing: boolean;
  54723. /**
  54724. * The texture used as your environment texture in the scene.
  54725. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54726. *
  54727. * Remarks: Can be either a texture or a url.
  54728. */
  54729. environmentTexture: string | BaseTexture;
  54730. /**
  54731. * The value of the exposure to apply to the scene.
  54732. * 0.6 by default if setupImageProcessing is true.
  54733. */
  54734. cameraExposure: number;
  54735. /**
  54736. * The value of the contrast to apply to the scene.
  54737. * 1.6 by default if setupImageProcessing is true.
  54738. */
  54739. cameraContrast: number;
  54740. /**
  54741. * Specifies whether or not tonemapping should be enabled in the scene.
  54742. * true by default if setupImageProcessing is true.
  54743. */
  54744. toneMappingEnabled: boolean;
  54745. }
  54746. /**
  54747. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54748. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54749. * It also helps with the default setup of your imageProcessing configuration.
  54750. */
  54751. export class EnvironmentHelper {
  54752. /**
  54753. * Default ground texture URL.
  54754. */
  54755. private static _groundTextureCDNUrl;
  54756. /**
  54757. * Default skybox texture URL.
  54758. */
  54759. private static _skyboxTextureCDNUrl;
  54760. /**
  54761. * Default environment texture URL.
  54762. */
  54763. private static _environmentTextureCDNUrl;
  54764. /**
  54765. * Creates the default options for the helper.
  54766. */
  54767. private static _getDefaultOptions;
  54768. private _rootMesh;
  54769. /**
  54770. * Gets the root mesh created by the helper.
  54771. */
  54772. get rootMesh(): Mesh;
  54773. private _skybox;
  54774. /**
  54775. * Gets the skybox created by the helper.
  54776. */
  54777. get skybox(): Nullable<Mesh>;
  54778. private _skyboxTexture;
  54779. /**
  54780. * Gets the skybox texture created by the helper.
  54781. */
  54782. get skyboxTexture(): Nullable<BaseTexture>;
  54783. private _skyboxMaterial;
  54784. /**
  54785. * Gets the skybox material created by the helper.
  54786. */
  54787. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54788. private _ground;
  54789. /**
  54790. * Gets the ground mesh created by the helper.
  54791. */
  54792. get ground(): Nullable<Mesh>;
  54793. private _groundTexture;
  54794. /**
  54795. * Gets the ground texture created by the helper.
  54796. */
  54797. get groundTexture(): Nullable<BaseTexture>;
  54798. private _groundMirror;
  54799. /**
  54800. * Gets the ground mirror created by the helper.
  54801. */
  54802. get groundMirror(): Nullable<MirrorTexture>;
  54803. /**
  54804. * Gets the ground mirror render list to helps pushing the meshes
  54805. * you wish in the ground reflection.
  54806. */
  54807. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54808. private _groundMaterial;
  54809. /**
  54810. * Gets the ground material created by the helper.
  54811. */
  54812. get groundMaterial(): Nullable<BackgroundMaterial>;
  54813. /**
  54814. * Stores the creation options.
  54815. */
  54816. private readonly _scene;
  54817. private _options;
  54818. /**
  54819. * This observable will be notified with any error during the creation of the environment,
  54820. * mainly texture creation errors.
  54821. */
  54822. onErrorObservable: Observable<{
  54823. message?: string;
  54824. exception?: any;
  54825. }>;
  54826. /**
  54827. * constructor
  54828. * @param options Defines the options we want to customize the helper
  54829. * @param scene The scene to add the material to
  54830. */
  54831. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54832. /**
  54833. * Updates the background according to the new options
  54834. * @param options
  54835. */
  54836. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54837. /**
  54838. * Sets the primary color of all the available elements.
  54839. * @param color the main color to affect to the ground and the background
  54840. */
  54841. setMainColor(color: Color3): void;
  54842. /**
  54843. * Setup the image processing according to the specified options.
  54844. */
  54845. private _setupImageProcessing;
  54846. /**
  54847. * Setup the environment texture according to the specified options.
  54848. */
  54849. private _setupEnvironmentTexture;
  54850. /**
  54851. * Setup the background according to the specified options.
  54852. */
  54853. private _setupBackground;
  54854. /**
  54855. * Get the scene sizes according to the setup.
  54856. */
  54857. private _getSceneSize;
  54858. /**
  54859. * Setup the ground according to the specified options.
  54860. */
  54861. private _setupGround;
  54862. /**
  54863. * Setup the ground material according to the specified options.
  54864. */
  54865. private _setupGroundMaterial;
  54866. /**
  54867. * Setup the ground diffuse texture according to the specified options.
  54868. */
  54869. private _setupGroundDiffuseTexture;
  54870. /**
  54871. * Setup the ground mirror texture according to the specified options.
  54872. */
  54873. private _setupGroundMirrorTexture;
  54874. /**
  54875. * Setup the ground to receive the mirror texture.
  54876. */
  54877. private _setupMirrorInGroundMaterial;
  54878. /**
  54879. * Setup the skybox according to the specified options.
  54880. */
  54881. private _setupSkybox;
  54882. /**
  54883. * Setup the skybox material according to the specified options.
  54884. */
  54885. private _setupSkyboxMaterial;
  54886. /**
  54887. * Setup the skybox reflection texture according to the specified options.
  54888. */
  54889. private _setupSkyboxReflectionTexture;
  54890. private _errorHandler;
  54891. /**
  54892. * Dispose all the elements created by the Helper.
  54893. */
  54894. dispose(): void;
  54895. }
  54896. }
  54897. declare module BABYLON {
  54898. /**
  54899. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  54900. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  54901. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54902. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54903. */
  54904. export abstract class TextureDome<T extends Texture> extends TransformNode {
  54905. protected onError: Nullable<(message?: string, exception?: any) => void>;
  54906. /**
  54907. * Define the source as a Monoscopic panoramic 360/180.
  54908. */
  54909. static readonly MODE_MONOSCOPIC: number;
  54910. /**
  54911. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  54912. */
  54913. static readonly MODE_TOPBOTTOM: number;
  54914. /**
  54915. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  54916. */
  54917. static readonly MODE_SIDEBYSIDE: number;
  54918. private _halfDome;
  54919. protected _useDirectMapping: boolean;
  54920. /**
  54921. * The texture being displayed on the sphere
  54922. */
  54923. protected _texture: T;
  54924. /**
  54925. * Gets the texture being displayed on the sphere
  54926. */
  54927. get texture(): T;
  54928. /**
  54929. * Sets the texture being displayed on the sphere
  54930. */
  54931. set texture(newTexture: T);
  54932. /**
  54933. * The skybox material
  54934. */
  54935. protected _material: BackgroundMaterial;
  54936. /**
  54937. * The surface used for the dome
  54938. */
  54939. protected _mesh: Mesh;
  54940. /**
  54941. * Gets the mesh used for the dome.
  54942. */
  54943. get mesh(): Mesh;
  54944. /**
  54945. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  54946. */
  54947. private _halfDomeMask;
  54948. /**
  54949. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54950. * Also see the options.resolution property.
  54951. */
  54952. get fovMultiplier(): number;
  54953. set fovMultiplier(value: number);
  54954. protected _textureMode: number;
  54955. /**
  54956. * Gets or set the current texture mode for the texture. It can be:
  54957. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  54958. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  54959. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  54960. */
  54961. get textureMode(): number;
  54962. /**
  54963. * Sets the current texture mode for the texture. It can be:
  54964. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  54965. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  54966. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  54967. */
  54968. set textureMode(value: number);
  54969. /**
  54970. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  54971. */
  54972. get halfDome(): boolean;
  54973. /**
  54974. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54975. */
  54976. set halfDome(enabled: boolean);
  54977. /**
  54978. * Oberserver used in Stereoscopic VR Mode.
  54979. */
  54980. private _onBeforeCameraRenderObserver;
  54981. /**
  54982. * Observable raised when an error occured while loading the 360 image
  54983. */
  54984. onLoadErrorObservable: Observable<string>;
  54985. /**
  54986. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  54987. * @param name Element's name, child elements will append suffixes for their own names.
  54988. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  54989. * @param options An object containing optional or exposed sub element properties
  54990. */
  54991. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  54992. resolution?: number;
  54993. clickToPlay?: boolean;
  54994. autoPlay?: boolean;
  54995. loop?: boolean;
  54996. size?: number;
  54997. poster?: string;
  54998. faceForward?: boolean;
  54999. useDirectMapping?: boolean;
  55000. halfDomeMode?: boolean;
  55001. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55002. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55003. protected _changeTextureMode(value: number): void;
  55004. /**
  55005. * Releases resources associated with this node.
  55006. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55007. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55008. */
  55009. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55010. }
  55011. }
  55012. declare module BABYLON {
  55013. /**
  55014. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55015. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55016. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55017. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55018. */
  55019. export class PhotoDome extends TextureDome<Texture> {
  55020. /**
  55021. * Define the image as a Monoscopic panoramic 360 image.
  55022. */
  55023. static readonly MODE_MONOSCOPIC: number;
  55024. /**
  55025. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55026. */
  55027. static readonly MODE_TOPBOTTOM: number;
  55028. /**
  55029. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55030. */
  55031. static readonly MODE_SIDEBYSIDE: number;
  55032. /**
  55033. * Gets or sets the texture being displayed on the sphere
  55034. */
  55035. get photoTexture(): Texture;
  55036. /**
  55037. * sets the texture being displayed on the sphere
  55038. */
  55039. set photoTexture(value: Texture);
  55040. /**
  55041. * Gets the current video mode for the video. It can be:
  55042. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55043. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55044. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55045. */
  55046. get imageMode(): number;
  55047. /**
  55048. * Sets the current video mode for the video. It can be:
  55049. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55050. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55051. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55052. */
  55053. set imageMode(value: number);
  55054. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55055. }
  55056. }
  55057. declare module BABYLON {
  55058. /**
  55059. * Class used to host RGBD texture specific utilities
  55060. */
  55061. export class RGBDTextureTools {
  55062. /**
  55063. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55064. * @param texture the texture to expand.
  55065. */
  55066. static ExpandRGBDTexture(texture: Texture): void;
  55067. }
  55068. }
  55069. declare module BABYLON {
  55070. /**
  55071. * Class used to host texture specific utilities
  55072. */
  55073. export class BRDFTextureTools {
  55074. /**
  55075. * Prevents texture cache collision
  55076. */
  55077. private static _instanceNumber;
  55078. /**
  55079. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55080. * @param scene defines the hosting scene
  55081. * @returns the environment BRDF texture
  55082. */
  55083. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55084. private static _environmentBRDFBase64Texture;
  55085. }
  55086. }
  55087. declare module BABYLON {
  55088. /**
  55089. * @hidden
  55090. */
  55091. export interface IMaterialClearCoatDefines {
  55092. CLEARCOAT: boolean;
  55093. CLEARCOAT_DEFAULTIOR: boolean;
  55094. CLEARCOAT_TEXTURE: boolean;
  55095. CLEARCOAT_TEXTUREDIRECTUV: number;
  55096. CLEARCOAT_BUMP: boolean;
  55097. CLEARCOAT_BUMPDIRECTUV: number;
  55098. CLEARCOAT_TINT: boolean;
  55099. CLEARCOAT_TINT_TEXTURE: boolean;
  55100. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55101. /** @hidden */
  55102. _areTexturesDirty: boolean;
  55103. }
  55104. /**
  55105. * Define the code related to the clear coat parameters of the pbr material.
  55106. */
  55107. export class PBRClearCoatConfiguration {
  55108. /**
  55109. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55110. * The default fits with a polyurethane material.
  55111. */
  55112. private static readonly _DefaultIndexOfRefraction;
  55113. private _isEnabled;
  55114. /**
  55115. * Defines if the clear coat is enabled in the material.
  55116. */
  55117. isEnabled: boolean;
  55118. /**
  55119. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55120. */
  55121. intensity: number;
  55122. /**
  55123. * Defines the clear coat layer roughness.
  55124. */
  55125. roughness: number;
  55126. private _indexOfRefraction;
  55127. /**
  55128. * Defines the index of refraction of the clear coat.
  55129. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55130. * The default fits with a polyurethane material.
  55131. * Changing the default value is more performance intensive.
  55132. */
  55133. indexOfRefraction: number;
  55134. private _texture;
  55135. /**
  55136. * Stores the clear coat values in a texture.
  55137. */
  55138. texture: Nullable<BaseTexture>;
  55139. private _bumpTexture;
  55140. /**
  55141. * Define the clear coat specific bump texture.
  55142. */
  55143. bumpTexture: Nullable<BaseTexture>;
  55144. private _isTintEnabled;
  55145. /**
  55146. * Defines if the clear coat tint is enabled in the material.
  55147. */
  55148. isTintEnabled: boolean;
  55149. /**
  55150. * Defines the clear coat tint of the material.
  55151. * This is only use if tint is enabled
  55152. */
  55153. tintColor: Color3;
  55154. /**
  55155. * Defines the distance at which the tint color should be found in the
  55156. * clear coat media.
  55157. * This is only use if tint is enabled
  55158. */
  55159. tintColorAtDistance: number;
  55160. /**
  55161. * Defines the clear coat layer thickness.
  55162. * This is only use if tint is enabled
  55163. */
  55164. tintThickness: number;
  55165. private _tintTexture;
  55166. /**
  55167. * Stores the clear tint values in a texture.
  55168. * rgb is tint
  55169. * a is a thickness factor
  55170. */
  55171. tintTexture: Nullable<BaseTexture>;
  55172. /** @hidden */
  55173. private _internalMarkAllSubMeshesAsTexturesDirty;
  55174. /** @hidden */
  55175. _markAllSubMeshesAsTexturesDirty(): void;
  55176. /**
  55177. * Instantiate a new istance of clear coat configuration.
  55178. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55179. */
  55180. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55181. /**
  55182. * Gets wehter the submesh is ready to be used or not.
  55183. * @param defines the list of "defines" to update.
  55184. * @param scene defines the scene the material belongs to.
  55185. * @param engine defines the engine the material belongs to.
  55186. * @param disableBumpMap defines wether the material disables bump or not.
  55187. * @returns - boolean indicating that the submesh is ready or not.
  55188. */
  55189. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55190. /**
  55191. * Checks to see if a texture is used in the material.
  55192. * @param defines the list of "defines" to update.
  55193. * @param scene defines the scene to the material belongs to.
  55194. */
  55195. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55196. /**
  55197. * Binds the material data.
  55198. * @param uniformBuffer defines the Uniform buffer to fill in.
  55199. * @param scene defines the scene the material belongs to.
  55200. * @param engine defines the engine the material belongs to.
  55201. * @param disableBumpMap defines wether the material disables bump or not.
  55202. * @param isFrozen defines wether the material is frozen or not.
  55203. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55204. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55205. */
  55206. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55207. /**
  55208. * Checks to see if a texture is used in the material.
  55209. * @param texture - Base texture to use.
  55210. * @returns - Boolean specifying if a texture is used in the material.
  55211. */
  55212. hasTexture(texture: BaseTexture): boolean;
  55213. /**
  55214. * Returns an array of the actively used textures.
  55215. * @param activeTextures Array of BaseTextures
  55216. */
  55217. getActiveTextures(activeTextures: BaseTexture[]): void;
  55218. /**
  55219. * Returns the animatable textures.
  55220. * @param animatables Array of animatable textures.
  55221. */
  55222. getAnimatables(animatables: IAnimatable[]): void;
  55223. /**
  55224. * Disposes the resources of the material.
  55225. * @param forceDisposeTextures - Forces the disposal of all textures.
  55226. */
  55227. dispose(forceDisposeTextures?: boolean): void;
  55228. /**
  55229. * Get the current class name of the texture useful for serialization or dynamic coding.
  55230. * @returns "PBRClearCoatConfiguration"
  55231. */
  55232. getClassName(): string;
  55233. /**
  55234. * Add fallbacks to the effect fallbacks list.
  55235. * @param defines defines the Base texture to use.
  55236. * @param fallbacks defines the current fallback list.
  55237. * @param currentRank defines the current fallback rank.
  55238. * @returns the new fallback rank.
  55239. */
  55240. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55241. /**
  55242. * Add the required uniforms to the current list.
  55243. * @param uniforms defines the current uniform list.
  55244. */
  55245. static AddUniforms(uniforms: string[]): void;
  55246. /**
  55247. * Add the required samplers to the current list.
  55248. * @param samplers defines the current sampler list.
  55249. */
  55250. static AddSamplers(samplers: string[]): void;
  55251. /**
  55252. * Add the required uniforms to the current buffer.
  55253. * @param uniformBuffer defines the current uniform buffer.
  55254. */
  55255. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55256. /**
  55257. * Makes a duplicate of the current configuration into another one.
  55258. * @param clearCoatConfiguration define the config where to copy the info
  55259. */
  55260. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55261. /**
  55262. * Serializes this clear coat configuration.
  55263. * @returns - An object with the serialized config.
  55264. */
  55265. serialize(): any;
  55266. /**
  55267. * Parses a anisotropy Configuration from a serialized object.
  55268. * @param source - Serialized object.
  55269. * @param scene Defines the scene we are parsing for
  55270. * @param rootUrl Defines the rootUrl to load from
  55271. */
  55272. parse(source: any, scene: Scene, rootUrl: string): void;
  55273. }
  55274. }
  55275. declare module BABYLON {
  55276. /**
  55277. * @hidden
  55278. */
  55279. export interface IMaterialAnisotropicDefines {
  55280. ANISOTROPIC: boolean;
  55281. ANISOTROPIC_TEXTURE: boolean;
  55282. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55283. MAINUV1: boolean;
  55284. _areTexturesDirty: boolean;
  55285. _needUVs: boolean;
  55286. }
  55287. /**
  55288. * Define the code related to the anisotropic parameters of the pbr material.
  55289. */
  55290. export class PBRAnisotropicConfiguration {
  55291. private _isEnabled;
  55292. /**
  55293. * Defines if the anisotropy is enabled in the material.
  55294. */
  55295. isEnabled: boolean;
  55296. /**
  55297. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55298. */
  55299. intensity: number;
  55300. /**
  55301. * Defines if the effect is along the tangents, bitangents or in between.
  55302. * By default, the effect is "strectching" the highlights along the tangents.
  55303. */
  55304. direction: Vector2;
  55305. private _texture;
  55306. /**
  55307. * Stores the anisotropy values in a texture.
  55308. * rg is direction (like normal from -1 to 1)
  55309. * b is a intensity
  55310. */
  55311. texture: Nullable<BaseTexture>;
  55312. /** @hidden */
  55313. private _internalMarkAllSubMeshesAsTexturesDirty;
  55314. /** @hidden */
  55315. _markAllSubMeshesAsTexturesDirty(): void;
  55316. /**
  55317. * Instantiate a new istance of anisotropy configuration.
  55318. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55319. */
  55320. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55321. /**
  55322. * Specifies that the submesh is ready to be used.
  55323. * @param defines the list of "defines" to update.
  55324. * @param scene defines the scene the material belongs to.
  55325. * @returns - boolean indicating that the submesh is ready or not.
  55326. */
  55327. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55328. /**
  55329. * Checks to see if a texture is used in the material.
  55330. * @param defines the list of "defines" to update.
  55331. * @param mesh the mesh we are preparing the defines for.
  55332. * @param scene defines the scene the material belongs to.
  55333. */
  55334. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55335. /**
  55336. * Binds the material data.
  55337. * @param uniformBuffer defines the Uniform buffer to fill in.
  55338. * @param scene defines the scene the material belongs to.
  55339. * @param isFrozen defines wether the material is frozen or not.
  55340. */
  55341. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55342. /**
  55343. * Checks to see if a texture is used in the material.
  55344. * @param texture - Base texture to use.
  55345. * @returns - Boolean specifying if a texture is used in the material.
  55346. */
  55347. hasTexture(texture: BaseTexture): boolean;
  55348. /**
  55349. * Returns an array of the actively used textures.
  55350. * @param activeTextures Array of BaseTextures
  55351. */
  55352. getActiveTextures(activeTextures: BaseTexture[]): void;
  55353. /**
  55354. * Returns the animatable textures.
  55355. * @param animatables Array of animatable textures.
  55356. */
  55357. getAnimatables(animatables: IAnimatable[]): void;
  55358. /**
  55359. * Disposes the resources of the material.
  55360. * @param forceDisposeTextures - Forces the disposal of all textures.
  55361. */
  55362. dispose(forceDisposeTextures?: boolean): void;
  55363. /**
  55364. * Get the current class name of the texture useful for serialization or dynamic coding.
  55365. * @returns "PBRAnisotropicConfiguration"
  55366. */
  55367. getClassName(): string;
  55368. /**
  55369. * Add fallbacks to the effect fallbacks list.
  55370. * @param defines defines the Base texture to use.
  55371. * @param fallbacks defines the current fallback list.
  55372. * @param currentRank defines the current fallback rank.
  55373. * @returns the new fallback rank.
  55374. */
  55375. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55376. /**
  55377. * Add the required uniforms to the current list.
  55378. * @param uniforms defines the current uniform list.
  55379. */
  55380. static AddUniforms(uniforms: string[]): void;
  55381. /**
  55382. * Add the required uniforms to the current buffer.
  55383. * @param uniformBuffer defines the current uniform buffer.
  55384. */
  55385. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55386. /**
  55387. * Add the required samplers to the current list.
  55388. * @param samplers defines the current sampler list.
  55389. */
  55390. static AddSamplers(samplers: string[]): void;
  55391. /**
  55392. * Makes a duplicate of the current configuration into another one.
  55393. * @param anisotropicConfiguration define the config where to copy the info
  55394. */
  55395. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55396. /**
  55397. * Serializes this anisotropy configuration.
  55398. * @returns - An object with the serialized config.
  55399. */
  55400. serialize(): any;
  55401. /**
  55402. * Parses a anisotropy Configuration from a serialized object.
  55403. * @param source - Serialized object.
  55404. * @param scene Defines the scene we are parsing for
  55405. * @param rootUrl Defines the rootUrl to load from
  55406. */
  55407. parse(source: any, scene: Scene, rootUrl: string): void;
  55408. }
  55409. }
  55410. declare module BABYLON {
  55411. /**
  55412. * @hidden
  55413. */
  55414. export interface IMaterialBRDFDefines {
  55415. BRDF_V_HEIGHT_CORRELATED: boolean;
  55416. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55417. SPHERICAL_HARMONICS: boolean;
  55418. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55419. /** @hidden */
  55420. _areMiscDirty: boolean;
  55421. }
  55422. /**
  55423. * Define the code related to the BRDF parameters of the pbr material.
  55424. */
  55425. export class PBRBRDFConfiguration {
  55426. /**
  55427. * Default value used for the energy conservation.
  55428. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55429. */
  55430. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55431. /**
  55432. * Default value used for the Smith Visibility Height Correlated mode.
  55433. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55434. */
  55435. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55436. /**
  55437. * Default value used for the IBL diffuse part.
  55438. * This can help switching back to the polynomials mode globally which is a tiny bit
  55439. * less GPU intensive at the drawback of a lower quality.
  55440. */
  55441. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55442. /**
  55443. * Default value used for activating energy conservation for the specular workflow.
  55444. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55445. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55446. */
  55447. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55448. private _useEnergyConservation;
  55449. /**
  55450. * Defines if the material uses energy conservation.
  55451. */
  55452. useEnergyConservation: boolean;
  55453. private _useSmithVisibilityHeightCorrelated;
  55454. /**
  55455. * LEGACY Mode set to false
  55456. * Defines if the material uses height smith correlated visibility term.
  55457. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55458. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55459. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55460. * Not relying on height correlated will also disable energy conservation.
  55461. */
  55462. useSmithVisibilityHeightCorrelated: boolean;
  55463. private _useSphericalHarmonics;
  55464. /**
  55465. * LEGACY Mode set to false
  55466. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55467. * diffuse part of the IBL.
  55468. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55469. * to the ground truth.
  55470. */
  55471. useSphericalHarmonics: boolean;
  55472. private _useSpecularGlossinessInputEnergyConservation;
  55473. /**
  55474. * Defines if the material uses energy conservation, when the specular workflow is active.
  55475. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55476. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55477. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55478. */
  55479. useSpecularGlossinessInputEnergyConservation: boolean;
  55480. /** @hidden */
  55481. private _internalMarkAllSubMeshesAsMiscDirty;
  55482. /** @hidden */
  55483. _markAllSubMeshesAsMiscDirty(): void;
  55484. /**
  55485. * Instantiate a new istance of clear coat configuration.
  55486. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55487. */
  55488. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55489. /**
  55490. * Checks to see if a texture is used in the material.
  55491. * @param defines the list of "defines" to update.
  55492. */
  55493. prepareDefines(defines: IMaterialBRDFDefines): void;
  55494. /**
  55495. * Get the current class name of the texture useful for serialization or dynamic coding.
  55496. * @returns "PBRClearCoatConfiguration"
  55497. */
  55498. getClassName(): string;
  55499. /**
  55500. * Makes a duplicate of the current configuration into another one.
  55501. * @param brdfConfiguration define the config where to copy the info
  55502. */
  55503. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55504. /**
  55505. * Serializes this BRDF configuration.
  55506. * @returns - An object with the serialized config.
  55507. */
  55508. serialize(): any;
  55509. /**
  55510. * Parses a anisotropy Configuration from a serialized object.
  55511. * @param source - Serialized object.
  55512. * @param scene Defines the scene we are parsing for
  55513. * @param rootUrl Defines the rootUrl to load from
  55514. */
  55515. parse(source: any, scene: Scene, rootUrl: string): void;
  55516. }
  55517. }
  55518. declare module BABYLON {
  55519. /**
  55520. * @hidden
  55521. */
  55522. export interface IMaterialSheenDefines {
  55523. SHEEN: boolean;
  55524. SHEEN_TEXTURE: boolean;
  55525. SHEEN_TEXTUREDIRECTUV: number;
  55526. SHEEN_LINKWITHALBEDO: boolean;
  55527. SHEEN_ROUGHNESS: boolean;
  55528. SHEEN_ALBEDOSCALING: boolean;
  55529. /** @hidden */
  55530. _areTexturesDirty: boolean;
  55531. }
  55532. /**
  55533. * Define the code related to the Sheen parameters of the pbr material.
  55534. */
  55535. export class PBRSheenConfiguration {
  55536. private _isEnabled;
  55537. /**
  55538. * Defines if the material uses sheen.
  55539. */
  55540. isEnabled: boolean;
  55541. private _linkSheenWithAlbedo;
  55542. /**
  55543. * Defines if the sheen is linked to the sheen color.
  55544. */
  55545. linkSheenWithAlbedo: boolean;
  55546. /**
  55547. * Defines the sheen intensity.
  55548. */
  55549. intensity: number;
  55550. /**
  55551. * Defines the sheen color.
  55552. */
  55553. color: Color3;
  55554. private _texture;
  55555. /**
  55556. * Stores the sheen tint values in a texture.
  55557. * rgb is tint
  55558. * a is a intensity or roughness if roughness has been defined
  55559. */
  55560. texture: Nullable<BaseTexture>;
  55561. private _roughness;
  55562. /**
  55563. * Defines the sheen roughness.
  55564. * It is not taken into account if linkSheenWithAlbedo is true.
  55565. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55566. */
  55567. roughness: Nullable<number>;
  55568. private _albedoScaling;
  55569. /**
  55570. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55571. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55572. * making it easier to setup and tweak the effect
  55573. */
  55574. albedoScaling: boolean;
  55575. /** @hidden */
  55576. private _internalMarkAllSubMeshesAsTexturesDirty;
  55577. /** @hidden */
  55578. _markAllSubMeshesAsTexturesDirty(): void;
  55579. /**
  55580. * Instantiate a new istance of clear coat configuration.
  55581. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55582. */
  55583. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55584. /**
  55585. * Specifies that the submesh is ready to be used.
  55586. * @param defines the list of "defines" to update.
  55587. * @param scene defines the scene the material belongs to.
  55588. * @returns - boolean indicating that the submesh is ready or not.
  55589. */
  55590. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55591. /**
  55592. * Checks to see if a texture is used in the material.
  55593. * @param defines the list of "defines" to update.
  55594. * @param scene defines the scene the material belongs to.
  55595. */
  55596. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55597. /**
  55598. * Binds the material data.
  55599. * @param uniformBuffer defines the Uniform buffer to fill in.
  55600. * @param scene defines the scene the material belongs to.
  55601. * @param isFrozen defines wether the material is frozen or not.
  55602. */
  55603. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55604. /**
  55605. * Checks to see if a texture is used in the material.
  55606. * @param texture - Base texture to use.
  55607. * @returns - Boolean specifying if a texture is used in the material.
  55608. */
  55609. hasTexture(texture: BaseTexture): boolean;
  55610. /**
  55611. * Returns an array of the actively used textures.
  55612. * @param activeTextures Array of BaseTextures
  55613. */
  55614. getActiveTextures(activeTextures: BaseTexture[]): void;
  55615. /**
  55616. * Returns the animatable textures.
  55617. * @param animatables Array of animatable textures.
  55618. */
  55619. getAnimatables(animatables: IAnimatable[]): void;
  55620. /**
  55621. * Disposes the resources of the material.
  55622. * @param forceDisposeTextures - Forces the disposal of all textures.
  55623. */
  55624. dispose(forceDisposeTextures?: boolean): void;
  55625. /**
  55626. * Get the current class name of the texture useful for serialization or dynamic coding.
  55627. * @returns "PBRSheenConfiguration"
  55628. */
  55629. getClassName(): string;
  55630. /**
  55631. * Add fallbacks to the effect fallbacks list.
  55632. * @param defines defines the Base texture to use.
  55633. * @param fallbacks defines the current fallback list.
  55634. * @param currentRank defines the current fallback rank.
  55635. * @returns the new fallback rank.
  55636. */
  55637. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55638. /**
  55639. * Add the required uniforms to the current list.
  55640. * @param uniforms defines the current uniform list.
  55641. */
  55642. static AddUniforms(uniforms: string[]): void;
  55643. /**
  55644. * Add the required uniforms to the current buffer.
  55645. * @param uniformBuffer defines the current uniform buffer.
  55646. */
  55647. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55648. /**
  55649. * Add the required samplers to the current list.
  55650. * @param samplers defines the current sampler list.
  55651. */
  55652. static AddSamplers(samplers: string[]): void;
  55653. /**
  55654. * Makes a duplicate of the current configuration into another one.
  55655. * @param sheenConfiguration define the config where to copy the info
  55656. */
  55657. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55658. /**
  55659. * Serializes this BRDF configuration.
  55660. * @returns - An object with the serialized config.
  55661. */
  55662. serialize(): any;
  55663. /**
  55664. * Parses a anisotropy Configuration from a serialized object.
  55665. * @param source - Serialized object.
  55666. * @param scene Defines the scene we are parsing for
  55667. * @param rootUrl Defines the rootUrl to load from
  55668. */
  55669. parse(source: any, scene: Scene, rootUrl: string): void;
  55670. }
  55671. }
  55672. declare module BABYLON {
  55673. /**
  55674. * @hidden
  55675. */
  55676. export interface IMaterialSubSurfaceDefines {
  55677. SUBSURFACE: boolean;
  55678. SS_REFRACTION: boolean;
  55679. SS_TRANSLUCENCY: boolean;
  55680. SS_SCATTERING: boolean;
  55681. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55682. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55683. SS_REFRACTIONMAP_3D: boolean;
  55684. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55685. SS_LODINREFRACTIONALPHA: boolean;
  55686. SS_GAMMAREFRACTION: boolean;
  55687. SS_RGBDREFRACTION: boolean;
  55688. SS_LINEARSPECULARREFRACTION: boolean;
  55689. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55690. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55691. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55692. /** @hidden */
  55693. _areTexturesDirty: boolean;
  55694. }
  55695. /**
  55696. * Define the code related to the sub surface parameters of the pbr material.
  55697. */
  55698. export class PBRSubSurfaceConfiguration {
  55699. private _isRefractionEnabled;
  55700. /**
  55701. * Defines if the refraction is enabled in the material.
  55702. */
  55703. isRefractionEnabled: boolean;
  55704. private _isTranslucencyEnabled;
  55705. /**
  55706. * Defines if the translucency is enabled in the material.
  55707. */
  55708. isTranslucencyEnabled: boolean;
  55709. private _isScatteringEnabled;
  55710. /**
  55711. * Defines if the sub surface scattering is enabled in the material.
  55712. */
  55713. isScatteringEnabled: boolean;
  55714. private _scatteringDiffusionProfileIndex;
  55715. /**
  55716. * Diffusion profile for subsurface scattering.
  55717. * Useful for better scattering in the skins or foliages.
  55718. */
  55719. get scatteringDiffusionProfile(): Nullable<Color3>;
  55720. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55721. /**
  55722. * Defines the refraction intensity of the material.
  55723. * The refraction when enabled replaces the Diffuse part of the material.
  55724. * The intensity helps transitionning between diffuse and refraction.
  55725. */
  55726. refractionIntensity: number;
  55727. /**
  55728. * Defines the translucency intensity of the material.
  55729. * When translucency has been enabled, this defines how much of the "translucency"
  55730. * is addded to the diffuse part of the material.
  55731. */
  55732. translucencyIntensity: number;
  55733. /**
  55734. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55735. */
  55736. useAlbedoToTintRefraction: boolean;
  55737. private _thicknessTexture;
  55738. /**
  55739. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55740. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55741. * 0 would mean minimumThickness
  55742. * 1 would mean maximumThickness
  55743. * The other channels might be use as a mask to vary the different effects intensity.
  55744. */
  55745. thicknessTexture: Nullable<BaseTexture>;
  55746. private _refractionTexture;
  55747. /**
  55748. * Defines the texture to use for refraction.
  55749. */
  55750. refractionTexture: Nullable<BaseTexture>;
  55751. private _indexOfRefraction;
  55752. /**
  55753. * Index of refraction of the material base layer.
  55754. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55755. *
  55756. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55757. *
  55758. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55759. */
  55760. indexOfRefraction: number;
  55761. private _volumeIndexOfRefraction;
  55762. /**
  55763. * Index of refraction of the material's volume.
  55764. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55765. *
  55766. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55767. * the volume will use the same IOR as the surface.
  55768. */
  55769. get volumeIndexOfRefraction(): number;
  55770. set volumeIndexOfRefraction(value: number);
  55771. private _invertRefractionY;
  55772. /**
  55773. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55774. */
  55775. invertRefractionY: boolean;
  55776. private _linkRefractionWithTransparency;
  55777. /**
  55778. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55779. * Materials half opaque for instance using refraction could benefit from this control.
  55780. */
  55781. linkRefractionWithTransparency: boolean;
  55782. /**
  55783. * Defines the minimum thickness stored in the thickness map.
  55784. * If no thickness map is defined, this value will be used to simulate thickness.
  55785. */
  55786. minimumThickness: number;
  55787. /**
  55788. * Defines the maximum thickness stored in the thickness map.
  55789. */
  55790. maximumThickness: number;
  55791. /**
  55792. * Defines the volume tint of the material.
  55793. * This is used for both translucency and scattering.
  55794. */
  55795. tintColor: Color3;
  55796. /**
  55797. * Defines the distance at which the tint color should be found in the media.
  55798. * This is used for refraction only.
  55799. */
  55800. tintColorAtDistance: number;
  55801. /**
  55802. * Defines how far each channel transmit through the media.
  55803. * It is defined as a color to simplify it selection.
  55804. */
  55805. diffusionDistance: Color3;
  55806. private _useMaskFromThicknessTexture;
  55807. /**
  55808. * Stores the intensity of the different subsurface effects in the thickness texture.
  55809. * * the green channel is the translucency intensity.
  55810. * * the blue channel is the scattering intensity.
  55811. * * the alpha channel is the refraction intensity.
  55812. */
  55813. useMaskFromThicknessTexture: boolean;
  55814. private _scene;
  55815. /** @hidden */
  55816. private _internalMarkAllSubMeshesAsTexturesDirty;
  55817. private _internalMarkScenePrePassDirty;
  55818. /** @hidden */
  55819. _markAllSubMeshesAsTexturesDirty(): void;
  55820. /** @hidden */
  55821. _markScenePrePassDirty(): void;
  55822. /**
  55823. * Instantiate a new istance of sub surface configuration.
  55824. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55825. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55826. * @param scene The scene
  55827. */
  55828. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55829. /**
  55830. * Gets wehter the submesh is ready to be used or not.
  55831. * @param defines the list of "defines" to update.
  55832. * @param scene defines the scene the material belongs to.
  55833. * @returns - boolean indicating that the submesh is ready or not.
  55834. */
  55835. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55836. /**
  55837. * Checks to see if a texture is used in the material.
  55838. * @param defines the list of "defines" to update.
  55839. * @param scene defines the scene to the material belongs to.
  55840. */
  55841. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55842. /**
  55843. * Binds the material data.
  55844. * @param uniformBuffer defines the Uniform buffer to fill in.
  55845. * @param scene defines the scene the material belongs to.
  55846. * @param engine defines the engine the material belongs to.
  55847. * @param isFrozen defines whether the material is frozen or not.
  55848. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55849. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55850. */
  55851. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55852. /**
  55853. * Unbinds the material from the mesh.
  55854. * @param activeEffect defines the effect that should be unbound from.
  55855. * @returns true if unbound, otherwise false
  55856. */
  55857. unbind(activeEffect: Effect): boolean;
  55858. /**
  55859. * Returns the texture used for refraction or null if none is used.
  55860. * @param scene defines the scene the material belongs to.
  55861. * @returns - Refraction texture if present. If no refraction texture and refraction
  55862. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55863. */
  55864. private _getRefractionTexture;
  55865. /**
  55866. * Returns true if alpha blending should be disabled.
  55867. */
  55868. get disableAlphaBlending(): boolean;
  55869. /**
  55870. * Fills the list of render target textures.
  55871. * @param renderTargets the list of render targets to update
  55872. */
  55873. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55874. /**
  55875. * Checks to see if a texture is used in the material.
  55876. * @param texture - Base texture to use.
  55877. * @returns - Boolean specifying if a texture is used in the material.
  55878. */
  55879. hasTexture(texture: BaseTexture): boolean;
  55880. /**
  55881. * Gets a boolean indicating that current material needs to register RTT
  55882. * @returns true if this uses a render target otherwise false.
  55883. */
  55884. hasRenderTargetTextures(): boolean;
  55885. /**
  55886. * Returns an array of the actively used textures.
  55887. * @param activeTextures Array of BaseTextures
  55888. */
  55889. getActiveTextures(activeTextures: BaseTexture[]): void;
  55890. /**
  55891. * Returns the animatable textures.
  55892. * @param animatables Array of animatable textures.
  55893. */
  55894. getAnimatables(animatables: IAnimatable[]): void;
  55895. /**
  55896. * Disposes the resources of the material.
  55897. * @param forceDisposeTextures - Forces the disposal of all textures.
  55898. */
  55899. dispose(forceDisposeTextures?: boolean): void;
  55900. /**
  55901. * Get the current class name of the texture useful for serialization or dynamic coding.
  55902. * @returns "PBRSubSurfaceConfiguration"
  55903. */
  55904. getClassName(): string;
  55905. /**
  55906. * Add fallbacks to the effect fallbacks list.
  55907. * @param defines defines the Base texture to use.
  55908. * @param fallbacks defines the current fallback list.
  55909. * @param currentRank defines the current fallback rank.
  55910. * @returns the new fallback rank.
  55911. */
  55912. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55913. /**
  55914. * Add the required uniforms to the current list.
  55915. * @param uniforms defines the current uniform list.
  55916. */
  55917. static AddUniforms(uniforms: string[]): void;
  55918. /**
  55919. * Add the required samplers to the current list.
  55920. * @param samplers defines the current sampler list.
  55921. */
  55922. static AddSamplers(samplers: string[]): void;
  55923. /**
  55924. * Add the required uniforms to the current buffer.
  55925. * @param uniformBuffer defines the current uniform buffer.
  55926. */
  55927. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55928. /**
  55929. * Makes a duplicate of the current configuration into another one.
  55930. * @param configuration define the config where to copy the info
  55931. */
  55932. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55933. /**
  55934. * Serializes this Sub Surface configuration.
  55935. * @returns - An object with the serialized config.
  55936. */
  55937. serialize(): any;
  55938. /**
  55939. * Parses a anisotropy Configuration from a serialized object.
  55940. * @param source - Serialized object.
  55941. * @param scene Defines the scene we are parsing for
  55942. * @param rootUrl Defines the rootUrl to load from
  55943. */
  55944. parse(source: any, scene: Scene, rootUrl: string): void;
  55945. }
  55946. }
  55947. declare module BABYLON {
  55948. /** @hidden */
  55949. export var pbrFragmentDeclaration: {
  55950. name: string;
  55951. shader: string;
  55952. };
  55953. }
  55954. declare module BABYLON {
  55955. /** @hidden */
  55956. export var pbrUboDeclaration: {
  55957. name: string;
  55958. shader: string;
  55959. };
  55960. }
  55961. declare module BABYLON {
  55962. /** @hidden */
  55963. export var pbrFragmentExtraDeclaration: {
  55964. name: string;
  55965. shader: string;
  55966. };
  55967. }
  55968. declare module BABYLON {
  55969. /** @hidden */
  55970. export var pbrFragmentSamplersDeclaration: {
  55971. name: string;
  55972. shader: string;
  55973. };
  55974. }
  55975. declare module BABYLON {
  55976. /** @hidden */
  55977. export var importanceSampling: {
  55978. name: string;
  55979. shader: string;
  55980. };
  55981. }
  55982. declare module BABYLON {
  55983. /** @hidden */
  55984. export var pbrHelperFunctions: {
  55985. name: string;
  55986. shader: string;
  55987. };
  55988. }
  55989. declare module BABYLON {
  55990. /** @hidden */
  55991. export var harmonicsFunctions: {
  55992. name: string;
  55993. shader: string;
  55994. };
  55995. }
  55996. declare module BABYLON {
  55997. /** @hidden */
  55998. export var pbrDirectLightingSetupFunctions: {
  55999. name: string;
  56000. shader: string;
  56001. };
  56002. }
  56003. declare module BABYLON {
  56004. /** @hidden */
  56005. export var pbrDirectLightingFalloffFunctions: {
  56006. name: string;
  56007. shader: string;
  56008. };
  56009. }
  56010. declare module BABYLON {
  56011. /** @hidden */
  56012. export var pbrBRDFFunctions: {
  56013. name: string;
  56014. shader: string;
  56015. };
  56016. }
  56017. declare module BABYLON {
  56018. /** @hidden */
  56019. export var hdrFilteringFunctions: {
  56020. name: string;
  56021. shader: string;
  56022. };
  56023. }
  56024. declare module BABYLON {
  56025. /** @hidden */
  56026. export var pbrDirectLightingFunctions: {
  56027. name: string;
  56028. shader: string;
  56029. };
  56030. }
  56031. declare module BABYLON {
  56032. /** @hidden */
  56033. export var pbrIBLFunctions: {
  56034. name: string;
  56035. shader: string;
  56036. };
  56037. }
  56038. declare module BABYLON {
  56039. /** @hidden */
  56040. export var pbrBlockAlbedoOpacity: {
  56041. name: string;
  56042. shader: string;
  56043. };
  56044. }
  56045. declare module BABYLON {
  56046. /** @hidden */
  56047. export var pbrBlockReflectivity: {
  56048. name: string;
  56049. shader: string;
  56050. };
  56051. }
  56052. declare module BABYLON {
  56053. /** @hidden */
  56054. export var pbrBlockAmbientOcclusion: {
  56055. name: string;
  56056. shader: string;
  56057. };
  56058. }
  56059. declare module BABYLON {
  56060. /** @hidden */
  56061. export var pbrBlockAlphaFresnel: {
  56062. name: string;
  56063. shader: string;
  56064. };
  56065. }
  56066. declare module BABYLON {
  56067. /** @hidden */
  56068. export var pbrBlockAnisotropic: {
  56069. name: string;
  56070. shader: string;
  56071. };
  56072. }
  56073. declare module BABYLON {
  56074. /** @hidden */
  56075. export var pbrBlockReflection: {
  56076. name: string;
  56077. shader: string;
  56078. };
  56079. }
  56080. declare module BABYLON {
  56081. /** @hidden */
  56082. export var pbrBlockSheen: {
  56083. name: string;
  56084. shader: string;
  56085. };
  56086. }
  56087. declare module BABYLON {
  56088. /** @hidden */
  56089. export var pbrBlockClearcoat: {
  56090. name: string;
  56091. shader: string;
  56092. };
  56093. }
  56094. declare module BABYLON {
  56095. /** @hidden */
  56096. export var pbrBlockSubSurface: {
  56097. name: string;
  56098. shader: string;
  56099. };
  56100. }
  56101. declare module BABYLON {
  56102. /** @hidden */
  56103. export var pbrBlockNormalGeometric: {
  56104. name: string;
  56105. shader: string;
  56106. };
  56107. }
  56108. declare module BABYLON {
  56109. /** @hidden */
  56110. export var pbrBlockNormalFinal: {
  56111. name: string;
  56112. shader: string;
  56113. };
  56114. }
  56115. declare module BABYLON {
  56116. /** @hidden */
  56117. export var pbrBlockLightmapInit: {
  56118. name: string;
  56119. shader: string;
  56120. };
  56121. }
  56122. declare module BABYLON {
  56123. /** @hidden */
  56124. export var pbrBlockGeometryInfo: {
  56125. name: string;
  56126. shader: string;
  56127. };
  56128. }
  56129. declare module BABYLON {
  56130. /** @hidden */
  56131. export var pbrBlockReflectance0: {
  56132. name: string;
  56133. shader: string;
  56134. };
  56135. }
  56136. declare module BABYLON {
  56137. /** @hidden */
  56138. export var pbrBlockReflectance: {
  56139. name: string;
  56140. shader: string;
  56141. };
  56142. }
  56143. declare module BABYLON {
  56144. /** @hidden */
  56145. export var pbrBlockDirectLighting: {
  56146. name: string;
  56147. shader: string;
  56148. };
  56149. }
  56150. declare module BABYLON {
  56151. /** @hidden */
  56152. export var pbrBlockFinalLitComponents: {
  56153. name: string;
  56154. shader: string;
  56155. };
  56156. }
  56157. declare module BABYLON {
  56158. /** @hidden */
  56159. export var pbrBlockFinalUnlitComponents: {
  56160. name: string;
  56161. shader: string;
  56162. };
  56163. }
  56164. declare module BABYLON {
  56165. /** @hidden */
  56166. export var pbrBlockFinalColorComposition: {
  56167. name: string;
  56168. shader: string;
  56169. };
  56170. }
  56171. declare module BABYLON {
  56172. /** @hidden */
  56173. export var pbrBlockImageProcessing: {
  56174. name: string;
  56175. shader: string;
  56176. };
  56177. }
  56178. declare module BABYLON {
  56179. /** @hidden */
  56180. export var pbrDebug: {
  56181. name: string;
  56182. shader: string;
  56183. };
  56184. }
  56185. declare module BABYLON {
  56186. /** @hidden */
  56187. export var pbrPixelShader: {
  56188. name: string;
  56189. shader: string;
  56190. };
  56191. }
  56192. declare module BABYLON {
  56193. /** @hidden */
  56194. export var pbrVertexDeclaration: {
  56195. name: string;
  56196. shader: string;
  56197. };
  56198. }
  56199. declare module BABYLON {
  56200. /** @hidden */
  56201. export var pbrVertexShader: {
  56202. name: string;
  56203. shader: string;
  56204. };
  56205. }
  56206. declare module BABYLON {
  56207. /**
  56208. * Manages the defines for the PBR Material.
  56209. * @hidden
  56210. */
  56211. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56212. PBR: boolean;
  56213. NUM_SAMPLES: string;
  56214. REALTIME_FILTERING: boolean;
  56215. MAINUV1: boolean;
  56216. MAINUV2: boolean;
  56217. UV1: boolean;
  56218. UV2: boolean;
  56219. ALBEDO: boolean;
  56220. GAMMAALBEDO: boolean;
  56221. ALBEDODIRECTUV: number;
  56222. VERTEXCOLOR: boolean;
  56223. DETAIL: boolean;
  56224. DETAILDIRECTUV: number;
  56225. DETAIL_NORMALBLENDMETHOD: number;
  56226. AMBIENT: boolean;
  56227. AMBIENTDIRECTUV: number;
  56228. AMBIENTINGRAYSCALE: boolean;
  56229. OPACITY: boolean;
  56230. VERTEXALPHA: boolean;
  56231. OPACITYDIRECTUV: number;
  56232. OPACITYRGB: boolean;
  56233. ALPHATEST: boolean;
  56234. DEPTHPREPASS: boolean;
  56235. ALPHABLEND: boolean;
  56236. ALPHAFROMALBEDO: boolean;
  56237. ALPHATESTVALUE: string;
  56238. SPECULAROVERALPHA: boolean;
  56239. RADIANCEOVERALPHA: boolean;
  56240. ALPHAFRESNEL: boolean;
  56241. LINEARALPHAFRESNEL: boolean;
  56242. PREMULTIPLYALPHA: boolean;
  56243. EMISSIVE: boolean;
  56244. EMISSIVEDIRECTUV: number;
  56245. REFLECTIVITY: boolean;
  56246. REFLECTIVITYDIRECTUV: number;
  56247. SPECULARTERM: boolean;
  56248. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56249. MICROSURFACEAUTOMATIC: boolean;
  56250. LODBASEDMICROSFURACE: boolean;
  56251. MICROSURFACEMAP: boolean;
  56252. MICROSURFACEMAPDIRECTUV: number;
  56253. METALLICWORKFLOW: boolean;
  56254. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56255. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56256. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56257. AOSTOREINMETALMAPRED: boolean;
  56258. METALLIC_REFLECTANCE: boolean;
  56259. METALLIC_REFLECTANCEDIRECTUV: number;
  56260. ENVIRONMENTBRDF: boolean;
  56261. ENVIRONMENTBRDF_RGBD: boolean;
  56262. NORMAL: boolean;
  56263. TANGENT: boolean;
  56264. BUMP: boolean;
  56265. BUMPDIRECTUV: number;
  56266. OBJECTSPACE_NORMALMAP: boolean;
  56267. PARALLAX: boolean;
  56268. PARALLAXOCCLUSION: boolean;
  56269. NORMALXYSCALE: boolean;
  56270. LIGHTMAP: boolean;
  56271. LIGHTMAPDIRECTUV: number;
  56272. USELIGHTMAPASSHADOWMAP: boolean;
  56273. GAMMALIGHTMAP: boolean;
  56274. RGBDLIGHTMAP: boolean;
  56275. REFLECTION: boolean;
  56276. REFLECTIONMAP_3D: boolean;
  56277. REFLECTIONMAP_SPHERICAL: boolean;
  56278. REFLECTIONMAP_PLANAR: boolean;
  56279. REFLECTIONMAP_CUBIC: boolean;
  56280. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56281. REFLECTIONMAP_PROJECTION: boolean;
  56282. REFLECTIONMAP_SKYBOX: boolean;
  56283. REFLECTIONMAP_EXPLICIT: boolean;
  56284. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56285. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56286. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56287. INVERTCUBICMAP: boolean;
  56288. USESPHERICALFROMREFLECTIONMAP: boolean;
  56289. USEIRRADIANCEMAP: boolean;
  56290. SPHERICAL_HARMONICS: boolean;
  56291. USESPHERICALINVERTEX: boolean;
  56292. REFLECTIONMAP_OPPOSITEZ: boolean;
  56293. LODINREFLECTIONALPHA: boolean;
  56294. GAMMAREFLECTION: boolean;
  56295. RGBDREFLECTION: boolean;
  56296. LINEARSPECULARREFLECTION: boolean;
  56297. RADIANCEOCCLUSION: boolean;
  56298. HORIZONOCCLUSION: boolean;
  56299. INSTANCES: boolean;
  56300. THIN_INSTANCES: boolean;
  56301. PREPASS: boolean;
  56302. SCENE_MRT_COUNT: number;
  56303. NUM_BONE_INFLUENCERS: number;
  56304. BonesPerMesh: number;
  56305. BONETEXTURE: boolean;
  56306. NONUNIFORMSCALING: boolean;
  56307. MORPHTARGETS: boolean;
  56308. MORPHTARGETS_NORMAL: boolean;
  56309. MORPHTARGETS_TANGENT: boolean;
  56310. MORPHTARGETS_UV: boolean;
  56311. NUM_MORPH_INFLUENCERS: number;
  56312. IMAGEPROCESSING: boolean;
  56313. VIGNETTE: boolean;
  56314. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56315. VIGNETTEBLENDMODEOPAQUE: boolean;
  56316. TONEMAPPING: boolean;
  56317. TONEMAPPING_ACES: boolean;
  56318. CONTRAST: boolean;
  56319. COLORCURVES: boolean;
  56320. COLORGRADING: boolean;
  56321. COLORGRADING3D: boolean;
  56322. SAMPLER3DGREENDEPTH: boolean;
  56323. SAMPLER3DBGRMAP: boolean;
  56324. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56325. EXPOSURE: boolean;
  56326. MULTIVIEW: boolean;
  56327. USEPHYSICALLIGHTFALLOFF: boolean;
  56328. USEGLTFLIGHTFALLOFF: boolean;
  56329. TWOSIDEDLIGHTING: boolean;
  56330. SHADOWFLOAT: boolean;
  56331. CLIPPLANE: boolean;
  56332. CLIPPLANE2: boolean;
  56333. CLIPPLANE3: boolean;
  56334. CLIPPLANE4: boolean;
  56335. CLIPPLANE5: boolean;
  56336. CLIPPLANE6: boolean;
  56337. POINTSIZE: boolean;
  56338. FOG: boolean;
  56339. LOGARITHMICDEPTH: boolean;
  56340. FORCENORMALFORWARD: boolean;
  56341. SPECULARAA: boolean;
  56342. CLEARCOAT: boolean;
  56343. CLEARCOAT_DEFAULTIOR: boolean;
  56344. CLEARCOAT_TEXTURE: boolean;
  56345. CLEARCOAT_TEXTUREDIRECTUV: number;
  56346. CLEARCOAT_BUMP: boolean;
  56347. CLEARCOAT_BUMPDIRECTUV: number;
  56348. CLEARCOAT_TINT: boolean;
  56349. CLEARCOAT_TINT_TEXTURE: boolean;
  56350. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56351. ANISOTROPIC: boolean;
  56352. ANISOTROPIC_TEXTURE: boolean;
  56353. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56354. BRDF_V_HEIGHT_CORRELATED: boolean;
  56355. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56356. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56357. SHEEN: boolean;
  56358. SHEEN_TEXTURE: boolean;
  56359. SHEEN_TEXTUREDIRECTUV: number;
  56360. SHEEN_LINKWITHALBEDO: boolean;
  56361. SHEEN_ROUGHNESS: boolean;
  56362. SHEEN_ALBEDOSCALING: boolean;
  56363. SUBSURFACE: boolean;
  56364. SS_REFRACTION: boolean;
  56365. SS_TRANSLUCENCY: boolean;
  56366. SS_SCATTERING: boolean;
  56367. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56368. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56369. SS_REFRACTIONMAP_3D: boolean;
  56370. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56371. SS_LODINREFRACTIONALPHA: boolean;
  56372. SS_GAMMAREFRACTION: boolean;
  56373. SS_RGBDREFRACTION: boolean;
  56374. SS_LINEARSPECULARREFRACTION: boolean;
  56375. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56376. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56377. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56378. UNLIT: boolean;
  56379. DEBUGMODE: number;
  56380. /**
  56381. * Initializes the PBR Material defines.
  56382. */
  56383. constructor();
  56384. /**
  56385. * Resets the PBR Material defines.
  56386. */
  56387. reset(): void;
  56388. }
  56389. /**
  56390. * The Physically based material base class of BJS.
  56391. *
  56392. * This offers the main features of a standard PBR material.
  56393. * For more information, please refer to the documentation :
  56394. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56395. */
  56396. export abstract class PBRBaseMaterial extends PushMaterial {
  56397. /**
  56398. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56399. */
  56400. static readonly PBRMATERIAL_OPAQUE: number;
  56401. /**
  56402. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56403. */
  56404. static readonly PBRMATERIAL_ALPHATEST: number;
  56405. /**
  56406. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56407. */
  56408. static readonly PBRMATERIAL_ALPHABLEND: number;
  56409. /**
  56410. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56411. * They are also discarded below the alpha cutoff threshold to improve performances.
  56412. */
  56413. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56414. /**
  56415. * Defines the default value of how much AO map is occluding the analytical lights
  56416. * (point spot...).
  56417. */
  56418. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56419. /**
  56420. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56421. */
  56422. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56423. /**
  56424. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56425. * to enhance interoperability with other engines.
  56426. */
  56427. static readonly LIGHTFALLOFF_GLTF: number;
  56428. /**
  56429. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56430. * to enhance interoperability with other materials.
  56431. */
  56432. static readonly LIGHTFALLOFF_STANDARD: number;
  56433. /**
  56434. * Intensity of the direct lights e.g. the four lights available in your scene.
  56435. * This impacts both the direct diffuse and specular highlights.
  56436. */
  56437. protected _directIntensity: number;
  56438. /**
  56439. * Intensity of the emissive part of the material.
  56440. * This helps controlling the emissive effect without modifying the emissive color.
  56441. */
  56442. protected _emissiveIntensity: number;
  56443. /**
  56444. * Intensity of the environment e.g. how much the environment will light the object
  56445. * either through harmonics for rough material or through the refelction for shiny ones.
  56446. */
  56447. protected _environmentIntensity: number;
  56448. /**
  56449. * This is a special control allowing the reduction of the specular highlights coming from the
  56450. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56451. */
  56452. protected _specularIntensity: number;
  56453. /**
  56454. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56455. */
  56456. private _lightingInfos;
  56457. /**
  56458. * Debug Control allowing disabling the bump map on this material.
  56459. */
  56460. protected _disableBumpMap: boolean;
  56461. /**
  56462. * AKA Diffuse Texture in standard nomenclature.
  56463. */
  56464. protected _albedoTexture: Nullable<BaseTexture>;
  56465. /**
  56466. * AKA Occlusion Texture in other nomenclature.
  56467. */
  56468. protected _ambientTexture: Nullable<BaseTexture>;
  56469. /**
  56470. * AKA Occlusion Texture Intensity in other nomenclature.
  56471. */
  56472. protected _ambientTextureStrength: number;
  56473. /**
  56474. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56475. * 1 means it completely occludes it
  56476. * 0 mean it has no impact
  56477. */
  56478. protected _ambientTextureImpactOnAnalyticalLights: number;
  56479. /**
  56480. * Stores the alpha values in a texture.
  56481. */
  56482. protected _opacityTexture: Nullable<BaseTexture>;
  56483. /**
  56484. * Stores the reflection values in a texture.
  56485. */
  56486. protected _reflectionTexture: Nullable<BaseTexture>;
  56487. /**
  56488. * Stores the emissive values in a texture.
  56489. */
  56490. protected _emissiveTexture: Nullable<BaseTexture>;
  56491. /**
  56492. * AKA Specular texture in other nomenclature.
  56493. */
  56494. protected _reflectivityTexture: Nullable<BaseTexture>;
  56495. /**
  56496. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56497. */
  56498. protected _metallicTexture: Nullable<BaseTexture>;
  56499. /**
  56500. * Specifies the metallic scalar of the metallic/roughness workflow.
  56501. * Can also be used to scale the metalness values of the metallic texture.
  56502. */
  56503. protected _metallic: Nullable<number>;
  56504. /**
  56505. * Specifies the roughness scalar of the metallic/roughness workflow.
  56506. * Can also be used to scale the roughness values of the metallic texture.
  56507. */
  56508. protected _roughness: Nullable<number>;
  56509. /**
  56510. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56511. * By default the indexOfrefraction is used to compute F0;
  56512. *
  56513. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56514. *
  56515. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56516. * F90 = metallicReflectanceColor;
  56517. */
  56518. protected _metallicF0Factor: number;
  56519. /**
  56520. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56521. * By default the F90 is always 1;
  56522. *
  56523. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56524. *
  56525. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56526. * F90 = metallicReflectanceColor;
  56527. */
  56528. protected _metallicReflectanceColor: Color3;
  56529. /**
  56530. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56531. * This is multiply against the scalar values defined in the material.
  56532. */
  56533. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56534. /**
  56535. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56536. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56537. */
  56538. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56539. /**
  56540. * Stores surface normal data used to displace a mesh in a texture.
  56541. */
  56542. protected _bumpTexture: Nullable<BaseTexture>;
  56543. /**
  56544. * Stores the pre-calculated light information of a mesh in a texture.
  56545. */
  56546. protected _lightmapTexture: Nullable<BaseTexture>;
  56547. /**
  56548. * The color of a material in ambient lighting.
  56549. */
  56550. protected _ambientColor: Color3;
  56551. /**
  56552. * AKA Diffuse Color in other nomenclature.
  56553. */
  56554. protected _albedoColor: Color3;
  56555. /**
  56556. * AKA Specular Color in other nomenclature.
  56557. */
  56558. protected _reflectivityColor: Color3;
  56559. /**
  56560. * The color applied when light is reflected from a material.
  56561. */
  56562. protected _reflectionColor: Color3;
  56563. /**
  56564. * The color applied when light is emitted from a material.
  56565. */
  56566. protected _emissiveColor: Color3;
  56567. /**
  56568. * AKA Glossiness in other nomenclature.
  56569. */
  56570. protected _microSurface: number;
  56571. /**
  56572. * Specifies that the material will use the light map as a show map.
  56573. */
  56574. protected _useLightmapAsShadowmap: boolean;
  56575. /**
  56576. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56577. * makes the reflect vector face the model (under horizon).
  56578. */
  56579. protected _useHorizonOcclusion: boolean;
  56580. /**
  56581. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56582. * too much the area relying on ambient texture to define their ambient occlusion.
  56583. */
  56584. protected _useRadianceOcclusion: boolean;
  56585. /**
  56586. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56587. */
  56588. protected _useAlphaFromAlbedoTexture: boolean;
  56589. /**
  56590. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56591. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56592. */
  56593. protected _useSpecularOverAlpha: boolean;
  56594. /**
  56595. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56596. */
  56597. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56598. /**
  56599. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56600. */
  56601. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56602. /**
  56603. * Specifies if the metallic texture contains the roughness information in its green channel.
  56604. */
  56605. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56606. /**
  56607. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56608. */
  56609. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56610. /**
  56611. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56612. */
  56613. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56614. /**
  56615. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56616. */
  56617. protected _useAmbientInGrayScale: boolean;
  56618. /**
  56619. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56620. * The material will try to infer what glossiness each pixel should be.
  56621. */
  56622. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56623. /**
  56624. * Defines the falloff type used in this material.
  56625. * It by default is Physical.
  56626. */
  56627. protected _lightFalloff: number;
  56628. /**
  56629. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56630. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56631. */
  56632. protected _useRadianceOverAlpha: boolean;
  56633. /**
  56634. * Allows using an object space normal map (instead of tangent space).
  56635. */
  56636. protected _useObjectSpaceNormalMap: boolean;
  56637. /**
  56638. * Allows using the bump map in parallax mode.
  56639. */
  56640. protected _useParallax: boolean;
  56641. /**
  56642. * Allows using the bump map in parallax occlusion mode.
  56643. */
  56644. protected _useParallaxOcclusion: boolean;
  56645. /**
  56646. * Controls the scale bias of the parallax mode.
  56647. */
  56648. protected _parallaxScaleBias: number;
  56649. /**
  56650. * If sets to true, disables all the lights affecting the material.
  56651. */
  56652. protected _disableLighting: boolean;
  56653. /**
  56654. * Number of Simultaneous lights allowed on the material.
  56655. */
  56656. protected _maxSimultaneousLights: number;
  56657. /**
  56658. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56659. */
  56660. protected _invertNormalMapX: boolean;
  56661. /**
  56662. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56663. */
  56664. protected _invertNormalMapY: boolean;
  56665. /**
  56666. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56667. */
  56668. protected _twoSidedLighting: boolean;
  56669. /**
  56670. * Defines the alpha limits in alpha test mode.
  56671. */
  56672. protected _alphaCutOff: number;
  56673. /**
  56674. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56675. */
  56676. protected _forceAlphaTest: boolean;
  56677. /**
  56678. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56679. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56680. */
  56681. protected _useAlphaFresnel: boolean;
  56682. /**
  56683. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56684. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56685. */
  56686. protected _useLinearAlphaFresnel: boolean;
  56687. /**
  56688. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56689. * from cos thetav and roughness:
  56690. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56691. */
  56692. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56693. /**
  56694. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56695. */
  56696. protected _forceIrradianceInFragment: boolean;
  56697. private _realTimeFiltering;
  56698. /**
  56699. * Enables realtime filtering on the texture.
  56700. */
  56701. get realTimeFiltering(): boolean;
  56702. set realTimeFiltering(b: boolean);
  56703. private _realTimeFilteringQuality;
  56704. /**
  56705. * Quality switch for realtime filtering
  56706. */
  56707. get realTimeFilteringQuality(): number;
  56708. set realTimeFilteringQuality(n: number);
  56709. /**
  56710. * Can this material render to several textures at once
  56711. */
  56712. get canRenderToMRT(): boolean;
  56713. /**
  56714. * Force normal to face away from face.
  56715. */
  56716. protected _forceNormalForward: boolean;
  56717. /**
  56718. * Enables specular anti aliasing in the PBR shader.
  56719. * It will both interacts on the Geometry for analytical and IBL lighting.
  56720. * It also prefilter the roughness map based on the bump values.
  56721. */
  56722. protected _enableSpecularAntiAliasing: boolean;
  56723. /**
  56724. * Default configuration related to image processing available in the PBR Material.
  56725. */
  56726. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56727. /**
  56728. * Keep track of the image processing observer to allow dispose and replace.
  56729. */
  56730. private _imageProcessingObserver;
  56731. /**
  56732. * Attaches a new image processing configuration to the PBR Material.
  56733. * @param configuration
  56734. */
  56735. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56736. /**
  56737. * Stores the available render targets.
  56738. */
  56739. private _renderTargets;
  56740. /**
  56741. * Sets the global ambient color for the material used in lighting calculations.
  56742. */
  56743. private _globalAmbientColor;
  56744. /**
  56745. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56746. */
  56747. private _useLogarithmicDepth;
  56748. /**
  56749. * If set to true, no lighting calculations will be applied.
  56750. */
  56751. private _unlit;
  56752. private _debugMode;
  56753. /**
  56754. * @hidden
  56755. * This is reserved for the inspector.
  56756. * Defines the material debug mode.
  56757. * It helps seeing only some components of the material while troubleshooting.
  56758. */
  56759. debugMode: number;
  56760. /**
  56761. * @hidden
  56762. * This is reserved for the inspector.
  56763. * Specify from where on screen the debug mode should start.
  56764. * The value goes from -1 (full screen) to 1 (not visible)
  56765. * It helps with side by side comparison against the final render
  56766. * This defaults to -1
  56767. */
  56768. private debugLimit;
  56769. /**
  56770. * @hidden
  56771. * This is reserved for the inspector.
  56772. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56773. * You can use the factor to better multiply the final value.
  56774. */
  56775. private debugFactor;
  56776. /**
  56777. * Defines the clear coat layer parameters for the material.
  56778. */
  56779. readonly clearCoat: PBRClearCoatConfiguration;
  56780. /**
  56781. * Defines the anisotropic parameters for the material.
  56782. */
  56783. readonly anisotropy: PBRAnisotropicConfiguration;
  56784. /**
  56785. * Defines the BRDF parameters for the material.
  56786. */
  56787. readonly brdf: PBRBRDFConfiguration;
  56788. /**
  56789. * Defines the Sheen parameters for the material.
  56790. */
  56791. readonly sheen: PBRSheenConfiguration;
  56792. /**
  56793. * Defines the SubSurface parameters for the material.
  56794. */
  56795. readonly subSurface: PBRSubSurfaceConfiguration;
  56796. /**
  56797. * Defines the detail map parameters for the material.
  56798. */
  56799. readonly detailMap: DetailMapConfiguration;
  56800. protected _rebuildInParallel: boolean;
  56801. /**
  56802. * Instantiates a new PBRMaterial instance.
  56803. *
  56804. * @param name The material name
  56805. * @param scene The scene the material will be use in.
  56806. */
  56807. constructor(name: string, scene: Scene);
  56808. /**
  56809. * Gets a boolean indicating that current material needs to register RTT
  56810. */
  56811. get hasRenderTargetTextures(): boolean;
  56812. /**
  56813. * Gets the name of the material class.
  56814. */
  56815. getClassName(): string;
  56816. /**
  56817. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56818. */
  56819. get useLogarithmicDepth(): boolean;
  56820. /**
  56821. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56822. */
  56823. set useLogarithmicDepth(value: boolean);
  56824. /**
  56825. * Returns true if alpha blending should be disabled.
  56826. */
  56827. protected get _disableAlphaBlending(): boolean;
  56828. /**
  56829. * Specifies whether or not this material should be rendered in alpha blend mode.
  56830. */
  56831. needAlphaBlending(): boolean;
  56832. /**
  56833. * Specifies whether or not this material should be rendered in alpha test mode.
  56834. */
  56835. needAlphaTesting(): boolean;
  56836. /**
  56837. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56838. */
  56839. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56840. /**
  56841. * Gets the texture used for the alpha test.
  56842. */
  56843. getAlphaTestTexture(): Nullable<BaseTexture>;
  56844. /**
  56845. * Specifies that the submesh is ready to be used.
  56846. * @param mesh - BJS mesh.
  56847. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56848. * @param useInstances - Specifies that instances should be used.
  56849. * @returns - boolean indicating that the submesh is ready or not.
  56850. */
  56851. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56852. /**
  56853. * Specifies if the material uses metallic roughness workflow.
  56854. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56855. */
  56856. isMetallicWorkflow(): boolean;
  56857. private _prepareEffect;
  56858. private _prepareDefines;
  56859. /**
  56860. * Force shader compilation
  56861. */
  56862. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56863. /**
  56864. * Initializes the uniform buffer layout for the shader.
  56865. */
  56866. buildUniformLayout(): void;
  56867. /**
  56868. * Unbinds the material from the mesh
  56869. */
  56870. unbind(): void;
  56871. /**
  56872. * Binds the submesh data.
  56873. * @param world - The world matrix.
  56874. * @param mesh - The BJS mesh.
  56875. * @param subMesh - A submesh of the BJS mesh.
  56876. */
  56877. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56878. /**
  56879. * Returns the animatable textures.
  56880. * @returns - Array of animatable textures.
  56881. */
  56882. getAnimatables(): IAnimatable[];
  56883. /**
  56884. * Returns the texture used for reflections.
  56885. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56886. */
  56887. private _getReflectionTexture;
  56888. /**
  56889. * Returns an array of the actively used textures.
  56890. * @returns - Array of BaseTextures
  56891. */
  56892. getActiveTextures(): BaseTexture[];
  56893. /**
  56894. * Checks to see if a texture is used in the material.
  56895. * @param texture - Base texture to use.
  56896. * @returns - Boolean specifying if a texture is used in the material.
  56897. */
  56898. hasTexture(texture: BaseTexture): boolean;
  56899. /**
  56900. * Sets the required values to the prepass renderer.
  56901. * @param prePassRenderer defines the prepass renderer to setup
  56902. */
  56903. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56904. /**
  56905. * Disposes the resources of the material.
  56906. * @param forceDisposeEffect - Forces the disposal of effects.
  56907. * @param forceDisposeTextures - Forces the disposal of all textures.
  56908. */
  56909. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56910. }
  56911. }
  56912. declare module BABYLON {
  56913. /**
  56914. * The Physically based material of BJS.
  56915. *
  56916. * This offers the main features of a standard PBR material.
  56917. * For more information, please refer to the documentation :
  56918. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56919. */
  56920. export class PBRMaterial extends PBRBaseMaterial {
  56921. /**
  56922. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56923. */
  56924. static readonly PBRMATERIAL_OPAQUE: number;
  56925. /**
  56926. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56927. */
  56928. static readonly PBRMATERIAL_ALPHATEST: number;
  56929. /**
  56930. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56931. */
  56932. static readonly PBRMATERIAL_ALPHABLEND: number;
  56933. /**
  56934. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56935. * They are also discarded below the alpha cutoff threshold to improve performances.
  56936. */
  56937. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56938. /**
  56939. * Defines the default value of how much AO map is occluding the analytical lights
  56940. * (point spot...).
  56941. */
  56942. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56943. /**
  56944. * Intensity of the direct lights e.g. the four lights available in your scene.
  56945. * This impacts both the direct diffuse and specular highlights.
  56946. */
  56947. directIntensity: number;
  56948. /**
  56949. * Intensity of the emissive part of the material.
  56950. * This helps controlling the emissive effect without modifying the emissive color.
  56951. */
  56952. emissiveIntensity: number;
  56953. /**
  56954. * Intensity of the environment e.g. how much the environment will light the object
  56955. * either through harmonics for rough material or through the refelction for shiny ones.
  56956. */
  56957. environmentIntensity: number;
  56958. /**
  56959. * This is a special control allowing the reduction of the specular highlights coming from the
  56960. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56961. */
  56962. specularIntensity: number;
  56963. /**
  56964. * Debug Control allowing disabling the bump map on this material.
  56965. */
  56966. disableBumpMap: boolean;
  56967. /**
  56968. * AKA Diffuse Texture in standard nomenclature.
  56969. */
  56970. albedoTexture: BaseTexture;
  56971. /**
  56972. * AKA Occlusion Texture in other nomenclature.
  56973. */
  56974. ambientTexture: BaseTexture;
  56975. /**
  56976. * AKA Occlusion Texture Intensity in other nomenclature.
  56977. */
  56978. ambientTextureStrength: number;
  56979. /**
  56980. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56981. * 1 means it completely occludes it
  56982. * 0 mean it has no impact
  56983. */
  56984. ambientTextureImpactOnAnalyticalLights: number;
  56985. /**
  56986. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56987. */
  56988. opacityTexture: BaseTexture;
  56989. /**
  56990. * Stores the reflection values in a texture.
  56991. */
  56992. reflectionTexture: Nullable<BaseTexture>;
  56993. /**
  56994. * Stores the emissive values in a texture.
  56995. */
  56996. emissiveTexture: BaseTexture;
  56997. /**
  56998. * AKA Specular texture in other nomenclature.
  56999. */
  57000. reflectivityTexture: BaseTexture;
  57001. /**
  57002. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57003. */
  57004. metallicTexture: BaseTexture;
  57005. /**
  57006. * Specifies the metallic scalar of the metallic/roughness workflow.
  57007. * Can also be used to scale the metalness values of the metallic texture.
  57008. */
  57009. metallic: Nullable<number>;
  57010. /**
  57011. * Specifies the roughness scalar of the metallic/roughness workflow.
  57012. * Can also be used to scale the roughness values of the metallic texture.
  57013. */
  57014. roughness: Nullable<number>;
  57015. /**
  57016. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57017. * By default the indexOfrefraction is used to compute F0;
  57018. *
  57019. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57020. *
  57021. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57022. * F90 = metallicReflectanceColor;
  57023. */
  57024. metallicF0Factor: number;
  57025. /**
  57026. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57027. * By default the F90 is always 1;
  57028. *
  57029. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57030. *
  57031. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57032. * F90 = metallicReflectanceColor;
  57033. */
  57034. metallicReflectanceColor: Color3;
  57035. /**
  57036. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57037. * This is multiply against the scalar values defined in the material.
  57038. */
  57039. metallicReflectanceTexture: Nullable<BaseTexture>;
  57040. /**
  57041. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57042. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57043. */
  57044. microSurfaceTexture: BaseTexture;
  57045. /**
  57046. * Stores surface normal data used to displace a mesh in a texture.
  57047. */
  57048. bumpTexture: BaseTexture;
  57049. /**
  57050. * Stores the pre-calculated light information of a mesh in a texture.
  57051. */
  57052. lightmapTexture: BaseTexture;
  57053. /**
  57054. * Stores the refracted light information in a texture.
  57055. */
  57056. get refractionTexture(): Nullable<BaseTexture>;
  57057. set refractionTexture(value: Nullable<BaseTexture>);
  57058. /**
  57059. * The color of a material in ambient lighting.
  57060. */
  57061. ambientColor: Color3;
  57062. /**
  57063. * AKA Diffuse Color in other nomenclature.
  57064. */
  57065. albedoColor: Color3;
  57066. /**
  57067. * AKA Specular Color in other nomenclature.
  57068. */
  57069. reflectivityColor: Color3;
  57070. /**
  57071. * The color reflected from the material.
  57072. */
  57073. reflectionColor: Color3;
  57074. /**
  57075. * The color emitted from the material.
  57076. */
  57077. emissiveColor: Color3;
  57078. /**
  57079. * AKA Glossiness in other nomenclature.
  57080. */
  57081. microSurface: number;
  57082. /**
  57083. * Index of refraction of the material base layer.
  57084. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57085. *
  57086. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57087. *
  57088. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57089. */
  57090. get indexOfRefraction(): number;
  57091. set indexOfRefraction(value: number);
  57092. /**
  57093. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57094. */
  57095. get invertRefractionY(): boolean;
  57096. set invertRefractionY(value: boolean);
  57097. /**
  57098. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57099. * Materials half opaque for instance using refraction could benefit from this control.
  57100. */
  57101. get linkRefractionWithTransparency(): boolean;
  57102. set linkRefractionWithTransparency(value: boolean);
  57103. /**
  57104. * If true, the light map contains occlusion information instead of lighting info.
  57105. */
  57106. useLightmapAsShadowmap: boolean;
  57107. /**
  57108. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57109. */
  57110. useAlphaFromAlbedoTexture: boolean;
  57111. /**
  57112. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57113. */
  57114. forceAlphaTest: boolean;
  57115. /**
  57116. * Defines the alpha limits in alpha test mode.
  57117. */
  57118. alphaCutOff: number;
  57119. /**
  57120. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57121. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57122. */
  57123. useSpecularOverAlpha: boolean;
  57124. /**
  57125. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57126. */
  57127. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57128. /**
  57129. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57130. */
  57131. useRoughnessFromMetallicTextureAlpha: boolean;
  57132. /**
  57133. * Specifies if the metallic texture contains the roughness information in its green channel.
  57134. */
  57135. useRoughnessFromMetallicTextureGreen: boolean;
  57136. /**
  57137. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57138. */
  57139. useMetallnessFromMetallicTextureBlue: boolean;
  57140. /**
  57141. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57142. */
  57143. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57144. /**
  57145. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57146. */
  57147. useAmbientInGrayScale: boolean;
  57148. /**
  57149. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57150. * The material will try to infer what glossiness each pixel should be.
  57151. */
  57152. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57153. /**
  57154. * BJS is using an harcoded light falloff based on a manually sets up range.
  57155. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57156. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57157. */
  57158. get usePhysicalLightFalloff(): boolean;
  57159. /**
  57160. * BJS is using an harcoded light falloff based on a manually sets up range.
  57161. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57162. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57163. */
  57164. set usePhysicalLightFalloff(value: boolean);
  57165. /**
  57166. * In order to support the falloff compatibility with gltf, a special mode has been added
  57167. * to reproduce the gltf light falloff.
  57168. */
  57169. get useGLTFLightFalloff(): boolean;
  57170. /**
  57171. * In order to support the falloff compatibility with gltf, a special mode has been added
  57172. * to reproduce the gltf light falloff.
  57173. */
  57174. set useGLTFLightFalloff(value: boolean);
  57175. /**
  57176. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57177. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57178. */
  57179. useRadianceOverAlpha: boolean;
  57180. /**
  57181. * Allows using an object space normal map (instead of tangent space).
  57182. */
  57183. useObjectSpaceNormalMap: boolean;
  57184. /**
  57185. * Allows using the bump map in parallax mode.
  57186. */
  57187. useParallax: boolean;
  57188. /**
  57189. * Allows using the bump map in parallax occlusion mode.
  57190. */
  57191. useParallaxOcclusion: boolean;
  57192. /**
  57193. * Controls the scale bias of the parallax mode.
  57194. */
  57195. parallaxScaleBias: number;
  57196. /**
  57197. * If sets to true, disables all the lights affecting the material.
  57198. */
  57199. disableLighting: boolean;
  57200. /**
  57201. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57202. */
  57203. forceIrradianceInFragment: boolean;
  57204. /**
  57205. * Number of Simultaneous lights allowed on the material.
  57206. */
  57207. maxSimultaneousLights: number;
  57208. /**
  57209. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57210. */
  57211. invertNormalMapX: boolean;
  57212. /**
  57213. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57214. */
  57215. invertNormalMapY: boolean;
  57216. /**
  57217. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57218. */
  57219. twoSidedLighting: boolean;
  57220. /**
  57221. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57222. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57223. */
  57224. useAlphaFresnel: boolean;
  57225. /**
  57226. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57227. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57228. */
  57229. useLinearAlphaFresnel: boolean;
  57230. /**
  57231. * Let user defines the brdf lookup texture used for IBL.
  57232. * A default 8bit version is embedded but you could point at :
  57233. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57234. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57235. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57236. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57237. */
  57238. environmentBRDFTexture: Nullable<BaseTexture>;
  57239. /**
  57240. * Force normal to face away from face.
  57241. */
  57242. forceNormalForward: boolean;
  57243. /**
  57244. * Enables specular anti aliasing in the PBR shader.
  57245. * It will both interacts on the Geometry for analytical and IBL lighting.
  57246. * It also prefilter the roughness map based on the bump values.
  57247. */
  57248. enableSpecularAntiAliasing: boolean;
  57249. /**
  57250. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57251. * makes the reflect vector face the model (under horizon).
  57252. */
  57253. useHorizonOcclusion: boolean;
  57254. /**
  57255. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57256. * too much the area relying on ambient texture to define their ambient occlusion.
  57257. */
  57258. useRadianceOcclusion: boolean;
  57259. /**
  57260. * If set to true, no lighting calculations will be applied.
  57261. */
  57262. unlit: boolean;
  57263. /**
  57264. * Gets the image processing configuration used either in this material.
  57265. */
  57266. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57267. /**
  57268. * Sets the Default image processing configuration used either in the this material.
  57269. *
  57270. * If sets to null, the scene one is in use.
  57271. */
  57272. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57273. /**
  57274. * Gets wether the color curves effect is enabled.
  57275. */
  57276. get cameraColorCurvesEnabled(): boolean;
  57277. /**
  57278. * Sets wether the color curves effect is enabled.
  57279. */
  57280. set cameraColorCurvesEnabled(value: boolean);
  57281. /**
  57282. * Gets wether the color grading effect is enabled.
  57283. */
  57284. get cameraColorGradingEnabled(): boolean;
  57285. /**
  57286. * Gets wether the color grading effect is enabled.
  57287. */
  57288. set cameraColorGradingEnabled(value: boolean);
  57289. /**
  57290. * Gets wether tonemapping is enabled or not.
  57291. */
  57292. get cameraToneMappingEnabled(): boolean;
  57293. /**
  57294. * Sets wether tonemapping is enabled or not
  57295. */
  57296. set cameraToneMappingEnabled(value: boolean);
  57297. /**
  57298. * The camera exposure used on this material.
  57299. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57300. * This corresponds to a photographic exposure.
  57301. */
  57302. get cameraExposure(): number;
  57303. /**
  57304. * The camera exposure used on this material.
  57305. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57306. * This corresponds to a photographic exposure.
  57307. */
  57308. set cameraExposure(value: number);
  57309. /**
  57310. * Gets The camera contrast used on this material.
  57311. */
  57312. get cameraContrast(): number;
  57313. /**
  57314. * Sets The camera contrast used on this material.
  57315. */
  57316. set cameraContrast(value: number);
  57317. /**
  57318. * Gets the Color Grading 2D Lookup Texture.
  57319. */
  57320. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57321. /**
  57322. * Sets the Color Grading 2D Lookup Texture.
  57323. */
  57324. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57325. /**
  57326. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57327. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57328. * 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;
  57329. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57330. */
  57331. get cameraColorCurves(): Nullable<ColorCurves>;
  57332. /**
  57333. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57334. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57335. * 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;
  57336. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57337. */
  57338. set cameraColorCurves(value: Nullable<ColorCurves>);
  57339. /**
  57340. * Instantiates a new PBRMaterial instance.
  57341. *
  57342. * @param name The material name
  57343. * @param scene The scene the material will be use in.
  57344. */
  57345. constructor(name: string, scene: Scene);
  57346. /**
  57347. * Returns the name of this material class.
  57348. */
  57349. getClassName(): string;
  57350. /**
  57351. * Makes a duplicate of the current material.
  57352. * @param name - name to use for the new material.
  57353. */
  57354. clone(name: string): PBRMaterial;
  57355. /**
  57356. * Serializes this PBR Material.
  57357. * @returns - An object with the serialized material.
  57358. */
  57359. serialize(): any;
  57360. /**
  57361. * Parses a PBR Material from a serialized object.
  57362. * @param source - Serialized object.
  57363. * @param scene - BJS scene instance.
  57364. * @param rootUrl - url for the scene object
  57365. * @returns - PBRMaterial
  57366. */
  57367. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57368. }
  57369. }
  57370. declare module BABYLON {
  57371. /**
  57372. * Direct draw surface info
  57373. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57374. */
  57375. export interface DDSInfo {
  57376. /**
  57377. * Width of the texture
  57378. */
  57379. width: number;
  57380. /**
  57381. * Width of the texture
  57382. */
  57383. height: number;
  57384. /**
  57385. * Number of Mipmaps for the texture
  57386. * @see https://en.wikipedia.org/wiki/Mipmap
  57387. */
  57388. mipmapCount: number;
  57389. /**
  57390. * If the textures format is a known fourCC format
  57391. * @see https://www.fourcc.org/
  57392. */
  57393. isFourCC: boolean;
  57394. /**
  57395. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57396. */
  57397. isRGB: boolean;
  57398. /**
  57399. * If the texture is a lumincance format
  57400. */
  57401. isLuminance: boolean;
  57402. /**
  57403. * If this is a cube texture
  57404. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57405. */
  57406. isCube: boolean;
  57407. /**
  57408. * If the texture is a compressed format eg. FOURCC_DXT1
  57409. */
  57410. isCompressed: boolean;
  57411. /**
  57412. * The dxgiFormat of the texture
  57413. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57414. */
  57415. dxgiFormat: number;
  57416. /**
  57417. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57418. */
  57419. textureType: number;
  57420. /**
  57421. * Sphericle polynomial created for the dds texture
  57422. */
  57423. sphericalPolynomial?: SphericalPolynomial;
  57424. }
  57425. /**
  57426. * Class used to provide DDS decompression tools
  57427. */
  57428. export class DDSTools {
  57429. /**
  57430. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57431. */
  57432. static StoreLODInAlphaChannel: boolean;
  57433. /**
  57434. * Gets DDS information from an array buffer
  57435. * @param data defines the array buffer view to read data from
  57436. * @returns the DDS information
  57437. */
  57438. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57439. private static _FloatView;
  57440. private static _Int32View;
  57441. private static _ToHalfFloat;
  57442. private static _FromHalfFloat;
  57443. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57444. private static _GetHalfFloatRGBAArrayBuffer;
  57445. private static _GetFloatRGBAArrayBuffer;
  57446. private static _GetFloatAsUIntRGBAArrayBuffer;
  57447. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57448. private static _GetRGBAArrayBuffer;
  57449. private static _ExtractLongWordOrder;
  57450. private static _GetRGBArrayBuffer;
  57451. private static _GetLuminanceArrayBuffer;
  57452. /**
  57453. * Uploads DDS Levels to a Babylon Texture
  57454. * @hidden
  57455. */
  57456. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57457. }
  57458. interface ThinEngine {
  57459. /**
  57460. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57461. * @param rootUrl defines the url where the file to load is located
  57462. * @param scene defines the current scene
  57463. * @param lodScale defines scale to apply to the mip map selection
  57464. * @param lodOffset defines offset to apply to the mip map selection
  57465. * @param onLoad defines an optional callback raised when the texture is loaded
  57466. * @param onError defines an optional callback raised if there is an issue to load the texture
  57467. * @param format defines the format of the data
  57468. * @param forcedExtension defines the extension to use to pick the right loader
  57469. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57470. * @returns the cube texture as an InternalTexture
  57471. */
  57472. 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;
  57473. }
  57474. }
  57475. declare module BABYLON {
  57476. /**
  57477. * Implementation of the DDS Texture Loader.
  57478. * @hidden
  57479. */
  57480. export class _DDSTextureLoader implements IInternalTextureLoader {
  57481. /**
  57482. * Defines wether the loader supports cascade loading the different faces.
  57483. */
  57484. readonly supportCascades: boolean;
  57485. /**
  57486. * This returns if the loader support the current file information.
  57487. * @param extension defines the file extension of the file being loaded
  57488. * @returns true if the loader can load the specified file
  57489. */
  57490. canLoad(extension: string): boolean;
  57491. /**
  57492. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57493. * @param data contains the texture data
  57494. * @param texture defines the BabylonJS internal texture
  57495. * @param createPolynomials will be true if polynomials have been requested
  57496. * @param onLoad defines the callback to trigger once the texture is ready
  57497. * @param onError defines the callback to trigger in case of error
  57498. */
  57499. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57500. /**
  57501. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57502. * @param data contains the texture data
  57503. * @param texture defines the BabylonJS internal texture
  57504. * @param callback defines the method to call once ready to upload
  57505. */
  57506. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57507. }
  57508. }
  57509. declare module BABYLON {
  57510. /**
  57511. * Implementation of the ENV Texture Loader.
  57512. * @hidden
  57513. */
  57514. export class _ENVTextureLoader implements IInternalTextureLoader {
  57515. /**
  57516. * Defines wether the loader supports cascade loading the different faces.
  57517. */
  57518. readonly supportCascades: boolean;
  57519. /**
  57520. * This returns if the loader support the current file information.
  57521. * @param extension defines the file extension of the file being loaded
  57522. * @returns true if the loader can load the specified file
  57523. */
  57524. canLoad(extension: string): boolean;
  57525. /**
  57526. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57527. * @param data contains the texture data
  57528. * @param texture defines the BabylonJS internal texture
  57529. * @param createPolynomials will be true if polynomials have been requested
  57530. * @param onLoad defines the callback to trigger once the texture is ready
  57531. * @param onError defines the callback to trigger in case of error
  57532. */
  57533. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57534. /**
  57535. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57536. * @param data contains the texture data
  57537. * @param texture defines the BabylonJS internal texture
  57538. * @param callback defines the method to call once ready to upload
  57539. */
  57540. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57541. }
  57542. }
  57543. declare module BABYLON {
  57544. /**
  57545. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57546. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57547. */
  57548. export class KhronosTextureContainer {
  57549. /** contents of the KTX container file */
  57550. data: ArrayBufferView;
  57551. private static HEADER_LEN;
  57552. private static COMPRESSED_2D;
  57553. private static COMPRESSED_3D;
  57554. private static TEX_2D;
  57555. private static TEX_3D;
  57556. /**
  57557. * Gets the openGL type
  57558. */
  57559. glType: number;
  57560. /**
  57561. * Gets the openGL type size
  57562. */
  57563. glTypeSize: number;
  57564. /**
  57565. * Gets the openGL format
  57566. */
  57567. glFormat: number;
  57568. /**
  57569. * Gets the openGL internal format
  57570. */
  57571. glInternalFormat: number;
  57572. /**
  57573. * Gets the base internal format
  57574. */
  57575. glBaseInternalFormat: number;
  57576. /**
  57577. * Gets image width in pixel
  57578. */
  57579. pixelWidth: number;
  57580. /**
  57581. * Gets image height in pixel
  57582. */
  57583. pixelHeight: number;
  57584. /**
  57585. * Gets image depth in pixels
  57586. */
  57587. pixelDepth: number;
  57588. /**
  57589. * Gets the number of array elements
  57590. */
  57591. numberOfArrayElements: number;
  57592. /**
  57593. * Gets the number of faces
  57594. */
  57595. numberOfFaces: number;
  57596. /**
  57597. * Gets the number of mipmap levels
  57598. */
  57599. numberOfMipmapLevels: number;
  57600. /**
  57601. * Gets the bytes of key value data
  57602. */
  57603. bytesOfKeyValueData: number;
  57604. /**
  57605. * Gets the load type
  57606. */
  57607. loadType: number;
  57608. /**
  57609. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57610. */
  57611. isInvalid: boolean;
  57612. /**
  57613. * Creates a new KhronosTextureContainer
  57614. * @param data contents of the KTX container file
  57615. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57616. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57617. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57618. */
  57619. constructor(
  57620. /** contents of the KTX container file */
  57621. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57622. /**
  57623. * Uploads KTX content to a Babylon Texture.
  57624. * It is assumed that the texture has already been created & is currently bound
  57625. * @hidden
  57626. */
  57627. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57628. private _upload2DCompressedLevels;
  57629. /**
  57630. * Checks if the given data starts with a KTX file identifier.
  57631. * @param data the data to check
  57632. * @returns true if the data is a KTX file or false otherwise
  57633. */
  57634. static IsValid(data: ArrayBufferView): boolean;
  57635. }
  57636. }
  57637. declare module BABYLON {
  57638. /**
  57639. * Class for loading KTX2 files
  57640. * !!! Experimental Extension Subject to Changes !!!
  57641. * @hidden
  57642. */
  57643. export class KhronosTextureContainer2 {
  57644. private static _ModulePromise;
  57645. private static _TranscodeFormat;
  57646. constructor(engine: ThinEngine);
  57647. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57648. private _determineTranscodeFormat;
  57649. /**
  57650. * Checks if the given data starts with a KTX2 file identifier.
  57651. * @param data the data to check
  57652. * @returns true if the data is a KTX2 file or false otherwise
  57653. */
  57654. static IsValid(data: ArrayBufferView): boolean;
  57655. }
  57656. }
  57657. declare module BABYLON {
  57658. /**
  57659. * Implementation of the KTX Texture Loader.
  57660. * @hidden
  57661. */
  57662. export class _KTXTextureLoader implements IInternalTextureLoader {
  57663. /**
  57664. * Defines wether the loader supports cascade loading the different faces.
  57665. */
  57666. readonly supportCascades: boolean;
  57667. /**
  57668. * This returns if the loader support the current file information.
  57669. * @param extension defines the file extension of the file being loaded
  57670. * @param mimeType defines the optional mime type of the file being loaded
  57671. * @returns true if the loader can load the specified file
  57672. */
  57673. canLoad(extension: string, mimeType?: string): boolean;
  57674. /**
  57675. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57676. * @param data contains the texture data
  57677. * @param texture defines the BabylonJS internal texture
  57678. * @param createPolynomials will be true if polynomials have been requested
  57679. * @param onLoad defines the callback to trigger once the texture is ready
  57680. * @param onError defines the callback to trigger in case of error
  57681. */
  57682. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57683. /**
  57684. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57685. * @param data contains the texture data
  57686. * @param texture defines the BabylonJS internal texture
  57687. * @param callback defines the method to call once ready to upload
  57688. */
  57689. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57690. }
  57691. }
  57692. declare module BABYLON {
  57693. /** @hidden */
  57694. export var _forceSceneHelpersToBundle: boolean;
  57695. interface Scene {
  57696. /**
  57697. * Creates a default light for the scene.
  57698. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57699. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57700. */
  57701. createDefaultLight(replace?: boolean): void;
  57702. /**
  57703. * Creates a default camera for the scene.
  57704. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57705. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57706. * @param replace has default false, when true replaces the active camera in the scene
  57707. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57708. */
  57709. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57710. /**
  57711. * Creates a default camera and a default light.
  57712. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57713. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57714. * @param replace has the default false, when true replaces the active camera/light in the scene
  57715. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57716. */
  57717. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57718. /**
  57719. * Creates a new sky box
  57720. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57721. * @param environmentTexture defines the texture to use as environment texture
  57722. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57723. * @param scale defines the overall scale of the skybox
  57724. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57725. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57726. * @returns a new mesh holding the sky box
  57727. */
  57728. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57729. /**
  57730. * Creates a new environment
  57731. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57732. * @param options defines the options you can use to configure the environment
  57733. * @returns the new EnvironmentHelper
  57734. */
  57735. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57736. /**
  57737. * Creates a new VREXperienceHelper
  57738. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57739. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57740. * @returns a new VREXperienceHelper
  57741. */
  57742. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57743. /**
  57744. * Creates a new WebXRDefaultExperience
  57745. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57746. * @param options experience options
  57747. * @returns a promise for a new WebXRDefaultExperience
  57748. */
  57749. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57750. }
  57751. }
  57752. declare module BABYLON {
  57753. /**
  57754. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57755. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57756. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57757. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57758. */
  57759. export class VideoDome extends TextureDome<VideoTexture> {
  57760. /**
  57761. * Define the video source as a Monoscopic panoramic 360 video.
  57762. */
  57763. static readonly MODE_MONOSCOPIC: number;
  57764. /**
  57765. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57766. */
  57767. static readonly MODE_TOPBOTTOM: number;
  57768. /**
  57769. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57770. */
  57771. static readonly MODE_SIDEBYSIDE: number;
  57772. /**
  57773. * Get the video texture associated with this video dome
  57774. */
  57775. get videoTexture(): VideoTexture;
  57776. /**
  57777. * Get the video mode of this dome
  57778. */
  57779. get videoMode(): number;
  57780. /**
  57781. * Set the video mode of this dome.
  57782. * @see textureMode
  57783. */
  57784. set videoMode(value: number);
  57785. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  57786. }
  57787. }
  57788. declare module BABYLON {
  57789. /**
  57790. * This class can be used to get instrumentation data from a Babylon engine
  57791. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57792. */
  57793. export class EngineInstrumentation implements IDisposable {
  57794. /**
  57795. * Define the instrumented engine.
  57796. */
  57797. engine: Engine;
  57798. private _captureGPUFrameTime;
  57799. private _gpuFrameTimeToken;
  57800. private _gpuFrameTime;
  57801. private _captureShaderCompilationTime;
  57802. private _shaderCompilationTime;
  57803. private _onBeginFrameObserver;
  57804. private _onEndFrameObserver;
  57805. private _onBeforeShaderCompilationObserver;
  57806. private _onAfterShaderCompilationObserver;
  57807. /**
  57808. * Gets the perf counter used for GPU frame time
  57809. */
  57810. get gpuFrameTimeCounter(): PerfCounter;
  57811. /**
  57812. * Gets the GPU frame time capture status
  57813. */
  57814. get captureGPUFrameTime(): boolean;
  57815. /**
  57816. * Enable or disable the GPU frame time capture
  57817. */
  57818. set captureGPUFrameTime(value: boolean);
  57819. /**
  57820. * Gets the perf counter used for shader compilation time
  57821. */
  57822. get shaderCompilationTimeCounter(): PerfCounter;
  57823. /**
  57824. * Gets the shader compilation time capture status
  57825. */
  57826. get captureShaderCompilationTime(): boolean;
  57827. /**
  57828. * Enable or disable the shader compilation time capture
  57829. */
  57830. set captureShaderCompilationTime(value: boolean);
  57831. /**
  57832. * Instantiates a new engine instrumentation.
  57833. * This class can be used to get instrumentation data from a Babylon engine
  57834. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57835. * @param engine Defines the engine to instrument
  57836. */
  57837. constructor(
  57838. /**
  57839. * Define the instrumented engine.
  57840. */
  57841. engine: Engine);
  57842. /**
  57843. * Dispose and release associated resources.
  57844. */
  57845. dispose(): void;
  57846. }
  57847. }
  57848. declare module BABYLON {
  57849. /**
  57850. * This class can be used to get instrumentation data from a Babylon engine
  57851. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57852. */
  57853. export class SceneInstrumentation implements IDisposable {
  57854. /**
  57855. * Defines the scene to instrument
  57856. */
  57857. scene: Scene;
  57858. private _captureActiveMeshesEvaluationTime;
  57859. private _activeMeshesEvaluationTime;
  57860. private _captureRenderTargetsRenderTime;
  57861. private _renderTargetsRenderTime;
  57862. private _captureFrameTime;
  57863. private _frameTime;
  57864. private _captureRenderTime;
  57865. private _renderTime;
  57866. private _captureInterFrameTime;
  57867. private _interFrameTime;
  57868. private _captureParticlesRenderTime;
  57869. private _particlesRenderTime;
  57870. private _captureSpritesRenderTime;
  57871. private _spritesRenderTime;
  57872. private _capturePhysicsTime;
  57873. private _physicsTime;
  57874. private _captureAnimationsTime;
  57875. private _animationsTime;
  57876. private _captureCameraRenderTime;
  57877. private _cameraRenderTime;
  57878. private _onBeforeActiveMeshesEvaluationObserver;
  57879. private _onAfterActiveMeshesEvaluationObserver;
  57880. private _onBeforeRenderTargetsRenderObserver;
  57881. private _onAfterRenderTargetsRenderObserver;
  57882. private _onAfterRenderObserver;
  57883. private _onBeforeDrawPhaseObserver;
  57884. private _onAfterDrawPhaseObserver;
  57885. private _onBeforeAnimationsObserver;
  57886. private _onBeforeParticlesRenderingObserver;
  57887. private _onAfterParticlesRenderingObserver;
  57888. private _onBeforeSpritesRenderingObserver;
  57889. private _onAfterSpritesRenderingObserver;
  57890. private _onBeforePhysicsObserver;
  57891. private _onAfterPhysicsObserver;
  57892. private _onAfterAnimationsObserver;
  57893. private _onBeforeCameraRenderObserver;
  57894. private _onAfterCameraRenderObserver;
  57895. /**
  57896. * Gets the perf counter used for active meshes evaluation time
  57897. */
  57898. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57899. /**
  57900. * Gets the active meshes evaluation time capture status
  57901. */
  57902. get captureActiveMeshesEvaluationTime(): boolean;
  57903. /**
  57904. * Enable or disable the active meshes evaluation time capture
  57905. */
  57906. set captureActiveMeshesEvaluationTime(value: boolean);
  57907. /**
  57908. * Gets the perf counter used for render targets render time
  57909. */
  57910. get renderTargetsRenderTimeCounter(): PerfCounter;
  57911. /**
  57912. * Gets the render targets render time capture status
  57913. */
  57914. get captureRenderTargetsRenderTime(): boolean;
  57915. /**
  57916. * Enable or disable the render targets render time capture
  57917. */
  57918. set captureRenderTargetsRenderTime(value: boolean);
  57919. /**
  57920. * Gets the perf counter used for particles render time
  57921. */
  57922. get particlesRenderTimeCounter(): PerfCounter;
  57923. /**
  57924. * Gets the particles render time capture status
  57925. */
  57926. get captureParticlesRenderTime(): boolean;
  57927. /**
  57928. * Enable or disable the particles render time capture
  57929. */
  57930. set captureParticlesRenderTime(value: boolean);
  57931. /**
  57932. * Gets the perf counter used for sprites render time
  57933. */
  57934. get spritesRenderTimeCounter(): PerfCounter;
  57935. /**
  57936. * Gets the sprites render time capture status
  57937. */
  57938. get captureSpritesRenderTime(): boolean;
  57939. /**
  57940. * Enable or disable the sprites render time capture
  57941. */
  57942. set captureSpritesRenderTime(value: boolean);
  57943. /**
  57944. * Gets the perf counter used for physics time
  57945. */
  57946. get physicsTimeCounter(): PerfCounter;
  57947. /**
  57948. * Gets the physics time capture status
  57949. */
  57950. get capturePhysicsTime(): boolean;
  57951. /**
  57952. * Enable or disable the physics time capture
  57953. */
  57954. set capturePhysicsTime(value: boolean);
  57955. /**
  57956. * Gets the perf counter used for animations time
  57957. */
  57958. get animationsTimeCounter(): PerfCounter;
  57959. /**
  57960. * Gets the animations time capture status
  57961. */
  57962. get captureAnimationsTime(): boolean;
  57963. /**
  57964. * Enable or disable the animations time capture
  57965. */
  57966. set captureAnimationsTime(value: boolean);
  57967. /**
  57968. * Gets the perf counter used for frame time capture
  57969. */
  57970. get frameTimeCounter(): PerfCounter;
  57971. /**
  57972. * Gets the frame time capture status
  57973. */
  57974. get captureFrameTime(): boolean;
  57975. /**
  57976. * Enable or disable the frame time capture
  57977. */
  57978. set captureFrameTime(value: boolean);
  57979. /**
  57980. * Gets the perf counter used for inter-frames time capture
  57981. */
  57982. get interFrameTimeCounter(): PerfCounter;
  57983. /**
  57984. * Gets the inter-frames time capture status
  57985. */
  57986. get captureInterFrameTime(): boolean;
  57987. /**
  57988. * Enable or disable the inter-frames time capture
  57989. */
  57990. set captureInterFrameTime(value: boolean);
  57991. /**
  57992. * Gets the perf counter used for render time capture
  57993. */
  57994. get renderTimeCounter(): PerfCounter;
  57995. /**
  57996. * Gets the render time capture status
  57997. */
  57998. get captureRenderTime(): boolean;
  57999. /**
  58000. * Enable or disable the render time capture
  58001. */
  58002. set captureRenderTime(value: boolean);
  58003. /**
  58004. * Gets the perf counter used for camera render time capture
  58005. */
  58006. get cameraRenderTimeCounter(): PerfCounter;
  58007. /**
  58008. * Gets the camera render time capture status
  58009. */
  58010. get captureCameraRenderTime(): boolean;
  58011. /**
  58012. * Enable or disable the camera render time capture
  58013. */
  58014. set captureCameraRenderTime(value: boolean);
  58015. /**
  58016. * Gets the perf counter used for draw calls
  58017. */
  58018. get drawCallsCounter(): PerfCounter;
  58019. /**
  58020. * Instantiates a new scene instrumentation.
  58021. * This class can be used to get instrumentation data from a Babylon engine
  58022. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58023. * @param scene Defines the scene to instrument
  58024. */
  58025. constructor(
  58026. /**
  58027. * Defines the scene to instrument
  58028. */
  58029. scene: Scene);
  58030. /**
  58031. * Dispose and release associated resources.
  58032. */
  58033. dispose(): void;
  58034. }
  58035. }
  58036. declare module BABYLON {
  58037. /** @hidden */
  58038. export var glowMapGenerationPixelShader: {
  58039. name: string;
  58040. shader: string;
  58041. };
  58042. }
  58043. declare module BABYLON {
  58044. /** @hidden */
  58045. export var glowMapGenerationVertexShader: {
  58046. name: string;
  58047. shader: string;
  58048. };
  58049. }
  58050. declare module BABYLON {
  58051. /**
  58052. * Effect layer options. This helps customizing the behaviour
  58053. * of the effect layer.
  58054. */
  58055. export interface IEffectLayerOptions {
  58056. /**
  58057. * Multiplication factor apply to the canvas size to compute the render target size
  58058. * used to generated the objects (the smaller the faster).
  58059. */
  58060. mainTextureRatio: number;
  58061. /**
  58062. * Enforces a fixed size texture to ensure effect stability across devices.
  58063. */
  58064. mainTextureFixedSize?: number;
  58065. /**
  58066. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58067. */
  58068. alphaBlendingMode: number;
  58069. /**
  58070. * The camera attached to the layer.
  58071. */
  58072. camera: Nullable<Camera>;
  58073. /**
  58074. * The rendering group to draw the layer in.
  58075. */
  58076. renderingGroupId: number;
  58077. }
  58078. /**
  58079. * The effect layer Helps adding post process effect blended with the main pass.
  58080. *
  58081. * This can be for instance use to generate glow or higlight effects on the scene.
  58082. *
  58083. * The effect layer class can not be used directly and is intented to inherited from to be
  58084. * customized per effects.
  58085. */
  58086. export abstract class EffectLayer {
  58087. private _vertexBuffers;
  58088. private _indexBuffer;
  58089. private _cachedDefines;
  58090. private _effectLayerMapGenerationEffect;
  58091. private _effectLayerOptions;
  58092. private _mergeEffect;
  58093. protected _scene: Scene;
  58094. protected _engine: Engine;
  58095. protected _maxSize: number;
  58096. protected _mainTextureDesiredSize: ISize;
  58097. protected _mainTexture: RenderTargetTexture;
  58098. protected _shouldRender: boolean;
  58099. protected _postProcesses: PostProcess[];
  58100. protected _textures: BaseTexture[];
  58101. protected _emissiveTextureAndColor: {
  58102. texture: Nullable<BaseTexture>;
  58103. color: Color4;
  58104. };
  58105. /**
  58106. * The name of the layer
  58107. */
  58108. name: string;
  58109. /**
  58110. * The clear color of the texture used to generate the glow map.
  58111. */
  58112. neutralColor: Color4;
  58113. /**
  58114. * Specifies whether the highlight layer is enabled or not.
  58115. */
  58116. isEnabled: boolean;
  58117. /**
  58118. * Gets the camera attached to the layer.
  58119. */
  58120. get camera(): Nullable<Camera>;
  58121. /**
  58122. * Gets the rendering group id the layer should render in.
  58123. */
  58124. get renderingGroupId(): number;
  58125. set renderingGroupId(renderingGroupId: number);
  58126. /**
  58127. * An event triggered when the effect layer has been disposed.
  58128. */
  58129. onDisposeObservable: Observable<EffectLayer>;
  58130. /**
  58131. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58132. */
  58133. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58134. /**
  58135. * An event triggered when the generated texture is being merged in the scene.
  58136. */
  58137. onBeforeComposeObservable: Observable<EffectLayer>;
  58138. /**
  58139. * An event triggered when the mesh is rendered into the effect render target.
  58140. */
  58141. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58142. /**
  58143. * An event triggered after the mesh has been rendered into the effect render target.
  58144. */
  58145. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58146. /**
  58147. * An event triggered when the generated texture has been merged in the scene.
  58148. */
  58149. onAfterComposeObservable: Observable<EffectLayer>;
  58150. /**
  58151. * An event triggered when the efffect layer changes its size.
  58152. */
  58153. onSizeChangedObservable: Observable<EffectLayer>;
  58154. /** @hidden */
  58155. static _SceneComponentInitialization: (scene: Scene) => void;
  58156. /**
  58157. * Instantiates a new effect Layer and references it in the scene.
  58158. * @param name The name of the layer
  58159. * @param scene The scene to use the layer in
  58160. */
  58161. constructor(
  58162. /** The Friendly of the effect in the scene */
  58163. name: string, scene: Scene);
  58164. /**
  58165. * Get the effect name of the layer.
  58166. * @return The effect name
  58167. */
  58168. abstract getEffectName(): string;
  58169. /**
  58170. * Checks for the readiness of the element composing the layer.
  58171. * @param subMesh the mesh to check for
  58172. * @param useInstances specify whether or not to use instances to render the mesh
  58173. * @return true if ready otherwise, false
  58174. */
  58175. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58176. /**
  58177. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58178. * @returns true if the effect requires stencil during the main canvas render pass.
  58179. */
  58180. abstract needStencil(): boolean;
  58181. /**
  58182. * Create the merge effect. This is the shader use to blit the information back
  58183. * to the main canvas at the end of the scene rendering.
  58184. * @returns The effect containing the shader used to merge the effect on the main canvas
  58185. */
  58186. protected abstract _createMergeEffect(): Effect;
  58187. /**
  58188. * Creates the render target textures and post processes used in the effect layer.
  58189. */
  58190. protected abstract _createTextureAndPostProcesses(): void;
  58191. /**
  58192. * Implementation specific of rendering the generating effect on the main canvas.
  58193. * @param effect The effect used to render through
  58194. */
  58195. protected abstract _internalRender(effect: Effect): void;
  58196. /**
  58197. * Sets the required values for both the emissive texture and and the main color.
  58198. */
  58199. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58200. /**
  58201. * Free any resources and references associated to a mesh.
  58202. * Internal use
  58203. * @param mesh The mesh to free.
  58204. */
  58205. abstract _disposeMesh(mesh: Mesh): void;
  58206. /**
  58207. * Serializes this layer (Glow or Highlight for example)
  58208. * @returns a serialized layer object
  58209. */
  58210. abstract serialize?(): any;
  58211. /**
  58212. * Initializes the effect layer with the required options.
  58213. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58214. */
  58215. protected _init(options: Partial<IEffectLayerOptions>): void;
  58216. /**
  58217. * Generates the index buffer of the full screen quad blending to the main canvas.
  58218. */
  58219. private _generateIndexBuffer;
  58220. /**
  58221. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58222. */
  58223. private _generateVertexBuffer;
  58224. /**
  58225. * Sets the main texture desired size which is the closest power of two
  58226. * of the engine canvas size.
  58227. */
  58228. private _setMainTextureSize;
  58229. /**
  58230. * Creates the main texture for the effect layer.
  58231. */
  58232. protected _createMainTexture(): void;
  58233. /**
  58234. * Adds specific effects defines.
  58235. * @param defines The defines to add specifics to.
  58236. */
  58237. protected _addCustomEffectDefines(defines: string[]): void;
  58238. /**
  58239. * Checks for the readiness of the element composing the layer.
  58240. * @param subMesh the mesh to check for
  58241. * @param useInstances specify whether or not to use instances to render the mesh
  58242. * @param emissiveTexture the associated emissive texture used to generate the glow
  58243. * @return true if ready otherwise, false
  58244. */
  58245. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58246. /**
  58247. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58248. */
  58249. render(): void;
  58250. /**
  58251. * Determine if a given mesh will be used in the current effect.
  58252. * @param mesh mesh to test
  58253. * @returns true if the mesh will be used
  58254. */
  58255. hasMesh(mesh: AbstractMesh): boolean;
  58256. /**
  58257. * Returns true if the layer contains information to display, otherwise false.
  58258. * @returns true if the glow layer should be rendered
  58259. */
  58260. shouldRender(): boolean;
  58261. /**
  58262. * Returns true if the mesh should render, otherwise false.
  58263. * @param mesh The mesh to render
  58264. * @returns true if it should render otherwise false
  58265. */
  58266. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58267. /**
  58268. * Returns true if the mesh can be rendered, otherwise false.
  58269. * @param mesh The mesh to render
  58270. * @param material The material used on the mesh
  58271. * @returns true if it can be rendered otherwise false
  58272. */
  58273. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58274. /**
  58275. * Returns true if the mesh should render, otherwise false.
  58276. * @param mesh The mesh to render
  58277. * @returns true if it should render otherwise false
  58278. */
  58279. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58280. /**
  58281. * Renders the submesh passed in parameter to the generation map.
  58282. */
  58283. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58284. /**
  58285. * Defines whether the current material of the mesh should be use to render the effect.
  58286. * @param mesh defines the current mesh to render
  58287. */
  58288. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58289. /**
  58290. * Rebuild the required buffers.
  58291. * @hidden Internal use only.
  58292. */
  58293. _rebuild(): void;
  58294. /**
  58295. * Dispose only the render target textures and post process.
  58296. */
  58297. private _disposeTextureAndPostProcesses;
  58298. /**
  58299. * Dispose the highlight layer and free resources.
  58300. */
  58301. dispose(): void;
  58302. /**
  58303. * Gets the class name of the effect layer
  58304. * @returns the string with the class name of the effect layer
  58305. */
  58306. getClassName(): string;
  58307. /**
  58308. * Creates an effect layer from parsed effect layer data
  58309. * @param parsedEffectLayer defines effect layer data
  58310. * @param scene defines the current scene
  58311. * @param rootUrl defines the root URL containing the effect layer information
  58312. * @returns a parsed effect Layer
  58313. */
  58314. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58315. }
  58316. }
  58317. declare module BABYLON {
  58318. interface AbstractScene {
  58319. /**
  58320. * The list of effect layers (highlights/glow) added to the scene
  58321. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58322. * @see https://doc.babylonjs.com/how_to/glow_layer
  58323. */
  58324. effectLayers: Array<EffectLayer>;
  58325. /**
  58326. * Removes the given effect layer from this scene.
  58327. * @param toRemove defines the effect layer to remove
  58328. * @returns the index of the removed effect layer
  58329. */
  58330. removeEffectLayer(toRemove: EffectLayer): number;
  58331. /**
  58332. * Adds the given effect layer to this scene
  58333. * @param newEffectLayer defines the effect layer to add
  58334. */
  58335. addEffectLayer(newEffectLayer: EffectLayer): void;
  58336. }
  58337. /**
  58338. * Defines the layer scene component responsible to manage any effect layers
  58339. * in a given scene.
  58340. */
  58341. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58342. /**
  58343. * The component name helpfull to identify the component in the list of scene components.
  58344. */
  58345. readonly name: string;
  58346. /**
  58347. * The scene the component belongs to.
  58348. */
  58349. scene: Scene;
  58350. private _engine;
  58351. private _renderEffects;
  58352. private _needStencil;
  58353. private _previousStencilState;
  58354. /**
  58355. * Creates a new instance of the component for the given scene
  58356. * @param scene Defines the scene to register the component in
  58357. */
  58358. constructor(scene: Scene);
  58359. /**
  58360. * Registers the component in a given scene
  58361. */
  58362. register(): void;
  58363. /**
  58364. * Rebuilds the elements related to this component in case of
  58365. * context lost for instance.
  58366. */
  58367. rebuild(): void;
  58368. /**
  58369. * Serializes the component data to the specified json object
  58370. * @param serializationObject The object to serialize to
  58371. */
  58372. serialize(serializationObject: any): void;
  58373. /**
  58374. * Adds all the elements from the container to the scene
  58375. * @param container the container holding the elements
  58376. */
  58377. addFromContainer(container: AbstractScene): void;
  58378. /**
  58379. * Removes all the elements in the container from the scene
  58380. * @param container contains the elements to remove
  58381. * @param dispose if the removed element should be disposed (default: false)
  58382. */
  58383. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58384. /**
  58385. * Disposes the component and the associated ressources.
  58386. */
  58387. dispose(): void;
  58388. private _isReadyForMesh;
  58389. private _renderMainTexture;
  58390. private _setStencil;
  58391. private _setStencilBack;
  58392. private _draw;
  58393. private _drawCamera;
  58394. private _drawRenderingGroup;
  58395. }
  58396. }
  58397. declare module BABYLON {
  58398. /** @hidden */
  58399. export var glowMapMergePixelShader: {
  58400. name: string;
  58401. shader: string;
  58402. };
  58403. }
  58404. declare module BABYLON {
  58405. /** @hidden */
  58406. export var glowMapMergeVertexShader: {
  58407. name: string;
  58408. shader: string;
  58409. };
  58410. }
  58411. declare module BABYLON {
  58412. interface AbstractScene {
  58413. /**
  58414. * Return a the first highlight layer of the scene with a given name.
  58415. * @param name The name of the highlight layer to look for.
  58416. * @return The highlight layer if found otherwise null.
  58417. */
  58418. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58419. }
  58420. /**
  58421. * Glow layer options. This helps customizing the behaviour
  58422. * of the glow layer.
  58423. */
  58424. export interface IGlowLayerOptions {
  58425. /**
  58426. * Multiplication factor apply to the canvas size to compute the render target size
  58427. * used to generated the glowing objects (the smaller the faster).
  58428. */
  58429. mainTextureRatio: number;
  58430. /**
  58431. * Enforces a fixed size texture to ensure resize independant blur.
  58432. */
  58433. mainTextureFixedSize?: number;
  58434. /**
  58435. * How big is the kernel of the blur texture.
  58436. */
  58437. blurKernelSize: number;
  58438. /**
  58439. * The camera attached to the layer.
  58440. */
  58441. camera: Nullable<Camera>;
  58442. /**
  58443. * Enable MSAA by chosing the number of samples.
  58444. */
  58445. mainTextureSamples?: number;
  58446. /**
  58447. * The rendering group to draw the layer in.
  58448. */
  58449. renderingGroupId: number;
  58450. }
  58451. /**
  58452. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58453. *
  58454. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58455. *
  58456. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58457. */
  58458. export class GlowLayer extends EffectLayer {
  58459. /**
  58460. * Effect Name of the layer.
  58461. */
  58462. static readonly EffectName: string;
  58463. /**
  58464. * The default blur kernel size used for the glow.
  58465. */
  58466. static DefaultBlurKernelSize: number;
  58467. /**
  58468. * The default texture size ratio used for the glow.
  58469. */
  58470. static DefaultTextureRatio: number;
  58471. /**
  58472. * Sets the kernel size of the blur.
  58473. */
  58474. set blurKernelSize(value: number);
  58475. /**
  58476. * Gets the kernel size of the blur.
  58477. */
  58478. get blurKernelSize(): number;
  58479. /**
  58480. * Sets the glow intensity.
  58481. */
  58482. set intensity(value: number);
  58483. /**
  58484. * Gets the glow intensity.
  58485. */
  58486. get intensity(): number;
  58487. private _options;
  58488. private _intensity;
  58489. private _horizontalBlurPostprocess1;
  58490. private _verticalBlurPostprocess1;
  58491. private _horizontalBlurPostprocess2;
  58492. private _verticalBlurPostprocess2;
  58493. private _blurTexture1;
  58494. private _blurTexture2;
  58495. private _postProcesses1;
  58496. private _postProcesses2;
  58497. private _includedOnlyMeshes;
  58498. private _excludedMeshes;
  58499. private _meshesUsingTheirOwnMaterials;
  58500. /**
  58501. * Callback used to let the user override the color selection on a per mesh basis
  58502. */
  58503. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58504. /**
  58505. * Callback used to let the user override the texture selection on a per mesh basis
  58506. */
  58507. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58508. /**
  58509. * Instantiates a new glow Layer and references it to the scene.
  58510. * @param name The name of the layer
  58511. * @param scene The scene to use the layer in
  58512. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58513. */
  58514. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58515. /**
  58516. * Get the effect name of the layer.
  58517. * @return The effect name
  58518. */
  58519. getEffectName(): string;
  58520. /**
  58521. * Create the merge effect. This is the shader use to blit the information back
  58522. * to the main canvas at the end of the scene rendering.
  58523. */
  58524. protected _createMergeEffect(): Effect;
  58525. /**
  58526. * Creates the render target textures and post processes used in the glow layer.
  58527. */
  58528. protected _createTextureAndPostProcesses(): void;
  58529. /**
  58530. * Checks for the readiness of the element composing the layer.
  58531. * @param subMesh the mesh to check for
  58532. * @param useInstances specify wether or not to use instances to render the mesh
  58533. * @param emissiveTexture the associated emissive texture used to generate the glow
  58534. * @return true if ready otherwise, false
  58535. */
  58536. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58537. /**
  58538. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58539. */
  58540. needStencil(): boolean;
  58541. /**
  58542. * Returns true if the mesh can be rendered, otherwise false.
  58543. * @param mesh The mesh to render
  58544. * @param material The material used on the mesh
  58545. * @returns true if it can be rendered otherwise false
  58546. */
  58547. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58548. /**
  58549. * Implementation specific of rendering the generating effect on the main canvas.
  58550. * @param effect The effect used to render through
  58551. */
  58552. protected _internalRender(effect: Effect): void;
  58553. /**
  58554. * Sets the required values for both the emissive texture and and the main color.
  58555. */
  58556. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58557. /**
  58558. * Returns true if the mesh should render, otherwise false.
  58559. * @param mesh The mesh to render
  58560. * @returns true if it should render otherwise false
  58561. */
  58562. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58563. /**
  58564. * Adds specific effects defines.
  58565. * @param defines The defines to add specifics to.
  58566. */
  58567. protected _addCustomEffectDefines(defines: string[]): void;
  58568. /**
  58569. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58570. * @param mesh The mesh to exclude from the glow layer
  58571. */
  58572. addExcludedMesh(mesh: Mesh): void;
  58573. /**
  58574. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58575. * @param mesh The mesh to remove
  58576. */
  58577. removeExcludedMesh(mesh: Mesh): void;
  58578. /**
  58579. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58580. * @param mesh The mesh to include in the glow layer
  58581. */
  58582. addIncludedOnlyMesh(mesh: Mesh): void;
  58583. /**
  58584. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58585. * @param mesh The mesh to remove
  58586. */
  58587. removeIncludedOnlyMesh(mesh: Mesh): void;
  58588. /**
  58589. * Determine if a given mesh will be used in the glow layer
  58590. * @param mesh The mesh to test
  58591. * @returns true if the mesh will be highlighted by the current glow layer
  58592. */
  58593. hasMesh(mesh: AbstractMesh): boolean;
  58594. /**
  58595. * Defines whether the current material of the mesh should be use to render the effect.
  58596. * @param mesh defines the current mesh to render
  58597. */
  58598. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58599. /**
  58600. * Add a mesh to be rendered through its own material and not with emissive only.
  58601. * @param mesh The mesh for which we need to use its material
  58602. */
  58603. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58604. /**
  58605. * Remove a mesh from being rendered through its own material and not with emissive only.
  58606. * @param mesh The mesh for which we need to not use its material
  58607. */
  58608. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58609. /**
  58610. * Free any resources and references associated to a mesh.
  58611. * Internal use
  58612. * @param mesh The mesh to free.
  58613. * @hidden
  58614. */
  58615. _disposeMesh(mesh: Mesh): void;
  58616. /**
  58617. * Gets the class name of the effect layer
  58618. * @returns the string with the class name of the effect layer
  58619. */
  58620. getClassName(): string;
  58621. /**
  58622. * Serializes this glow layer
  58623. * @returns a serialized glow layer object
  58624. */
  58625. serialize(): any;
  58626. /**
  58627. * Creates a Glow Layer from parsed glow layer data
  58628. * @param parsedGlowLayer defines glow layer data
  58629. * @param scene defines the current scene
  58630. * @param rootUrl defines the root URL containing the glow layer information
  58631. * @returns a parsed Glow Layer
  58632. */
  58633. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58634. }
  58635. }
  58636. declare module BABYLON {
  58637. /** @hidden */
  58638. export var glowBlurPostProcessPixelShader: {
  58639. name: string;
  58640. shader: string;
  58641. };
  58642. }
  58643. declare module BABYLON {
  58644. interface AbstractScene {
  58645. /**
  58646. * Return a the first highlight layer of the scene with a given name.
  58647. * @param name The name of the highlight layer to look for.
  58648. * @return The highlight layer if found otherwise null.
  58649. */
  58650. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58651. }
  58652. /**
  58653. * Highlight layer options. This helps customizing the behaviour
  58654. * of the highlight layer.
  58655. */
  58656. export interface IHighlightLayerOptions {
  58657. /**
  58658. * Multiplication factor apply to the canvas size to compute the render target size
  58659. * used to generated the glowing objects (the smaller the faster).
  58660. */
  58661. mainTextureRatio: number;
  58662. /**
  58663. * Enforces a fixed size texture to ensure resize independant blur.
  58664. */
  58665. mainTextureFixedSize?: number;
  58666. /**
  58667. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58668. * of the picture to blur (the smaller the faster).
  58669. */
  58670. blurTextureSizeRatio: number;
  58671. /**
  58672. * How big in texel of the blur texture is the vertical blur.
  58673. */
  58674. blurVerticalSize: number;
  58675. /**
  58676. * How big in texel of the blur texture is the horizontal blur.
  58677. */
  58678. blurHorizontalSize: number;
  58679. /**
  58680. * Alpha blending mode used to apply the blur. Default is combine.
  58681. */
  58682. alphaBlendingMode: number;
  58683. /**
  58684. * The camera attached to the layer.
  58685. */
  58686. camera: Nullable<Camera>;
  58687. /**
  58688. * Should we display highlight as a solid stroke?
  58689. */
  58690. isStroke?: boolean;
  58691. /**
  58692. * The rendering group to draw the layer in.
  58693. */
  58694. renderingGroupId: number;
  58695. }
  58696. /**
  58697. * The highlight layer Helps adding a glow effect around a mesh.
  58698. *
  58699. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58700. * glowy meshes to your scene.
  58701. *
  58702. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58703. */
  58704. export class HighlightLayer extends EffectLayer {
  58705. name: string;
  58706. /**
  58707. * Effect Name of the highlight layer.
  58708. */
  58709. static readonly EffectName: string;
  58710. /**
  58711. * The neutral color used during the preparation of the glow effect.
  58712. * This is black by default as the blend operation is a blend operation.
  58713. */
  58714. static NeutralColor: Color4;
  58715. /**
  58716. * Stencil value used for glowing meshes.
  58717. */
  58718. static GlowingMeshStencilReference: number;
  58719. /**
  58720. * Stencil value used for the other meshes in the scene.
  58721. */
  58722. static NormalMeshStencilReference: number;
  58723. /**
  58724. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58725. */
  58726. innerGlow: boolean;
  58727. /**
  58728. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58729. */
  58730. outerGlow: boolean;
  58731. /**
  58732. * Specifies the horizontal size of the blur.
  58733. */
  58734. set blurHorizontalSize(value: number);
  58735. /**
  58736. * Specifies the vertical size of the blur.
  58737. */
  58738. set blurVerticalSize(value: number);
  58739. /**
  58740. * Gets the horizontal size of the blur.
  58741. */
  58742. get blurHorizontalSize(): number;
  58743. /**
  58744. * Gets the vertical size of the blur.
  58745. */
  58746. get blurVerticalSize(): number;
  58747. /**
  58748. * An event triggered when the highlight layer is being blurred.
  58749. */
  58750. onBeforeBlurObservable: Observable<HighlightLayer>;
  58751. /**
  58752. * An event triggered when the highlight layer has been blurred.
  58753. */
  58754. onAfterBlurObservable: Observable<HighlightLayer>;
  58755. private _instanceGlowingMeshStencilReference;
  58756. private _options;
  58757. private _downSamplePostprocess;
  58758. private _horizontalBlurPostprocess;
  58759. private _verticalBlurPostprocess;
  58760. private _blurTexture;
  58761. private _meshes;
  58762. private _excludedMeshes;
  58763. /**
  58764. * Instantiates a new highlight Layer and references it to the scene..
  58765. * @param name The name of the layer
  58766. * @param scene The scene to use the layer in
  58767. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58768. */
  58769. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58770. /**
  58771. * Get the effect name of the layer.
  58772. * @return The effect name
  58773. */
  58774. getEffectName(): string;
  58775. /**
  58776. * Create the merge effect. This is the shader use to blit the information back
  58777. * to the main canvas at the end of the scene rendering.
  58778. */
  58779. protected _createMergeEffect(): Effect;
  58780. /**
  58781. * Creates the render target textures and post processes used in the highlight layer.
  58782. */
  58783. protected _createTextureAndPostProcesses(): void;
  58784. /**
  58785. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58786. */
  58787. needStencil(): boolean;
  58788. /**
  58789. * Checks for the readiness of the element composing the layer.
  58790. * @param subMesh the mesh to check for
  58791. * @param useInstances specify wether or not to use instances to render the mesh
  58792. * @param emissiveTexture the associated emissive texture used to generate the glow
  58793. * @return true if ready otherwise, false
  58794. */
  58795. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58796. /**
  58797. * Implementation specific of rendering the generating effect on the main canvas.
  58798. * @param effect The effect used to render through
  58799. */
  58800. protected _internalRender(effect: Effect): void;
  58801. /**
  58802. * Returns true if the layer contains information to display, otherwise false.
  58803. */
  58804. shouldRender(): boolean;
  58805. /**
  58806. * Returns true if the mesh should render, otherwise false.
  58807. * @param mesh The mesh to render
  58808. * @returns true if it should render otherwise false
  58809. */
  58810. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58811. /**
  58812. * Returns true if the mesh can be rendered, otherwise false.
  58813. * @param mesh The mesh to render
  58814. * @param material The material used on the mesh
  58815. * @returns true if it can be rendered otherwise false
  58816. */
  58817. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58818. /**
  58819. * Adds specific effects defines.
  58820. * @param defines The defines to add specifics to.
  58821. */
  58822. protected _addCustomEffectDefines(defines: string[]): void;
  58823. /**
  58824. * Sets the required values for both the emissive texture and and the main color.
  58825. */
  58826. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58827. /**
  58828. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58829. * @param mesh The mesh to exclude from the highlight layer
  58830. */
  58831. addExcludedMesh(mesh: Mesh): void;
  58832. /**
  58833. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58834. * @param mesh The mesh to highlight
  58835. */
  58836. removeExcludedMesh(mesh: Mesh): void;
  58837. /**
  58838. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58839. * @param mesh mesh to test
  58840. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58841. */
  58842. hasMesh(mesh: AbstractMesh): boolean;
  58843. /**
  58844. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58845. * @param mesh The mesh to highlight
  58846. * @param color The color of the highlight
  58847. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58848. */
  58849. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58850. /**
  58851. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58852. * @param mesh The mesh to highlight
  58853. */
  58854. removeMesh(mesh: Mesh): void;
  58855. /**
  58856. * Remove all the meshes currently referenced in the highlight layer
  58857. */
  58858. removeAllMeshes(): void;
  58859. /**
  58860. * Force the stencil to the normal expected value for none glowing parts
  58861. */
  58862. private _defaultStencilReference;
  58863. /**
  58864. * Free any resources and references associated to a mesh.
  58865. * Internal use
  58866. * @param mesh The mesh to free.
  58867. * @hidden
  58868. */
  58869. _disposeMesh(mesh: Mesh): void;
  58870. /**
  58871. * Dispose the highlight layer and free resources.
  58872. */
  58873. dispose(): void;
  58874. /**
  58875. * Gets the class name of the effect layer
  58876. * @returns the string with the class name of the effect layer
  58877. */
  58878. getClassName(): string;
  58879. /**
  58880. * Serializes this Highlight layer
  58881. * @returns a serialized Highlight layer object
  58882. */
  58883. serialize(): any;
  58884. /**
  58885. * Creates a Highlight layer from parsed Highlight layer data
  58886. * @param parsedHightlightLayer defines the Highlight layer data
  58887. * @param scene defines the current scene
  58888. * @param rootUrl defines the root URL containing the Highlight layer information
  58889. * @returns a parsed Highlight layer
  58890. */
  58891. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58892. }
  58893. }
  58894. declare module BABYLON {
  58895. interface AbstractScene {
  58896. /**
  58897. * The list of layers (background and foreground) of the scene
  58898. */
  58899. layers: Array<Layer>;
  58900. }
  58901. /**
  58902. * Defines the layer scene component responsible to manage any layers
  58903. * in a given scene.
  58904. */
  58905. export class LayerSceneComponent implements ISceneComponent {
  58906. /**
  58907. * The component name helpfull to identify the component in the list of scene components.
  58908. */
  58909. readonly name: string;
  58910. /**
  58911. * The scene the component belongs to.
  58912. */
  58913. scene: Scene;
  58914. private _engine;
  58915. /**
  58916. * Creates a new instance of the component for the given scene
  58917. * @param scene Defines the scene to register the component in
  58918. */
  58919. constructor(scene: Scene);
  58920. /**
  58921. * Registers the component in a given scene
  58922. */
  58923. register(): void;
  58924. /**
  58925. * Rebuilds the elements related to this component in case of
  58926. * context lost for instance.
  58927. */
  58928. rebuild(): void;
  58929. /**
  58930. * Disposes the component and the associated ressources.
  58931. */
  58932. dispose(): void;
  58933. private _draw;
  58934. private _drawCameraPredicate;
  58935. private _drawCameraBackground;
  58936. private _drawCameraForeground;
  58937. private _drawRenderTargetPredicate;
  58938. private _drawRenderTargetBackground;
  58939. private _drawRenderTargetForeground;
  58940. /**
  58941. * Adds all the elements from the container to the scene
  58942. * @param container the container holding the elements
  58943. */
  58944. addFromContainer(container: AbstractScene): void;
  58945. /**
  58946. * Removes all the elements in the container from the scene
  58947. * @param container contains the elements to remove
  58948. * @param dispose if the removed element should be disposed (default: false)
  58949. */
  58950. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58951. }
  58952. }
  58953. declare module BABYLON {
  58954. /** @hidden */
  58955. export var layerPixelShader: {
  58956. name: string;
  58957. shader: string;
  58958. };
  58959. }
  58960. declare module BABYLON {
  58961. /** @hidden */
  58962. export var layerVertexShader: {
  58963. name: string;
  58964. shader: string;
  58965. };
  58966. }
  58967. declare module BABYLON {
  58968. /**
  58969. * This represents a full screen 2d layer.
  58970. * This can be useful to display a picture in the background of your scene for instance.
  58971. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58972. */
  58973. export class Layer {
  58974. /**
  58975. * Define the name of the layer.
  58976. */
  58977. name: string;
  58978. /**
  58979. * Define the texture the layer should display.
  58980. */
  58981. texture: Nullable<Texture>;
  58982. /**
  58983. * Is the layer in background or foreground.
  58984. */
  58985. isBackground: boolean;
  58986. /**
  58987. * Define the color of the layer (instead of texture).
  58988. */
  58989. color: Color4;
  58990. /**
  58991. * Define the scale of the layer in order to zoom in out of the texture.
  58992. */
  58993. scale: Vector2;
  58994. /**
  58995. * Define an offset for the layer in order to shift the texture.
  58996. */
  58997. offset: Vector2;
  58998. /**
  58999. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59000. */
  59001. alphaBlendingMode: number;
  59002. /**
  59003. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59004. * Alpha test will not mix with the background color in case of transparency.
  59005. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59006. */
  59007. alphaTest: boolean;
  59008. /**
  59009. * Define a mask to restrict the layer to only some of the scene cameras.
  59010. */
  59011. layerMask: number;
  59012. /**
  59013. * Define the list of render target the layer is visible into.
  59014. */
  59015. renderTargetTextures: RenderTargetTexture[];
  59016. /**
  59017. * Define if the layer is only used in renderTarget or if it also
  59018. * renders in the main frame buffer of the canvas.
  59019. */
  59020. renderOnlyInRenderTargetTextures: boolean;
  59021. private _scene;
  59022. private _vertexBuffers;
  59023. private _indexBuffer;
  59024. private _effect;
  59025. private _previousDefines;
  59026. /**
  59027. * An event triggered when the layer is disposed.
  59028. */
  59029. onDisposeObservable: Observable<Layer>;
  59030. private _onDisposeObserver;
  59031. /**
  59032. * Back compatibility with callback before the onDisposeObservable existed.
  59033. * The set callback will be triggered when the layer has been disposed.
  59034. */
  59035. set onDispose(callback: () => void);
  59036. /**
  59037. * An event triggered before rendering the scene
  59038. */
  59039. onBeforeRenderObservable: Observable<Layer>;
  59040. private _onBeforeRenderObserver;
  59041. /**
  59042. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59043. * The set callback will be triggered just before rendering the layer.
  59044. */
  59045. set onBeforeRender(callback: () => void);
  59046. /**
  59047. * An event triggered after rendering the scene
  59048. */
  59049. onAfterRenderObservable: Observable<Layer>;
  59050. private _onAfterRenderObserver;
  59051. /**
  59052. * Back compatibility with callback before the onAfterRenderObservable existed.
  59053. * The set callback will be triggered just after rendering the layer.
  59054. */
  59055. set onAfterRender(callback: () => void);
  59056. /**
  59057. * Instantiates a new layer.
  59058. * This represents a full screen 2d layer.
  59059. * This can be useful to display a picture in the background of your scene for instance.
  59060. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59061. * @param name Define the name of the layer in the scene
  59062. * @param imgUrl Define the url of the texture to display in the layer
  59063. * @param scene Define the scene the layer belongs to
  59064. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59065. * @param color Defines a color for the layer
  59066. */
  59067. constructor(
  59068. /**
  59069. * Define the name of the layer.
  59070. */
  59071. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59072. private _createIndexBuffer;
  59073. /** @hidden */
  59074. _rebuild(): void;
  59075. /**
  59076. * Renders the layer in the scene.
  59077. */
  59078. render(): void;
  59079. /**
  59080. * Disposes and releases the associated ressources.
  59081. */
  59082. dispose(): void;
  59083. }
  59084. }
  59085. declare module BABYLON {
  59086. /** @hidden */
  59087. export var lensFlarePixelShader: {
  59088. name: string;
  59089. shader: string;
  59090. };
  59091. }
  59092. declare module BABYLON {
  59093. /** @hidden */
  59094. export var lensFlareVertexShader: {
  59095. name: string;
  59096. shader: string;
  59097. };
  59098. }
  59099. declare module BABYLON {
  59100. /**
  59101. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59102. * It is usually composed of several `lensFlare`.
  59103. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59104. */
  59105. export class LensFlareSystem {
  59106. /**
  59107. * Define the name of the lens flare system
  59108. */
  59109. name: string;
  59110. /**
  59111. * List of lens flares used in this system.
  59112. */
  59113. lensFlares: LensFlare[];
  59114. /**
  59115. * Define a limit from the border the lens flare can be visible.
  59116. */
  59117. borderLimit: number;
  59118. /**
  59119. * Define a viewport border we do not want to see the lens flare in.
  59120. */
  59121. viewportBorder: number;
  59122. /**
  59123. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59124. */
  59125. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59126. /**
  59127. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59128. */
  59129. layerMask: number;
  59130. /**
  59131. * Define the id of the lens flare system in the scene.
  59132. * (equal to name by default)
  59133. */
  59134. id: string;
  59135. private _scene;
  59136. private _emitter;
  59137. private _vertexBuffers;
  59138. private _indexBuffer;
  59139. private _effect;
  59140. private _positionX;
  59141. private _positionY;
  59142. private _isEnabled;
  59143. /** @hidden */
  59144. static _SceneComponentInitialization: (scene: Scene) => void;
  59145. /**
  59146. * Instantiates a lens flare system.
  59147. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59148. * It is usually composed of several `lensFlare`.
  59149. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59150. * @param name Define the name of the lens flare system in the scene
  59151. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59152. * @param scene Define the scene the lens flare system belongs to
  59153. */
  59154. constructor(
  59155. /**
  59156. * Define the name of the lens flare system
  59157. */
  59158. name: string, emitter: any, scene: Scene);
  59159. /**
  59160. * Define if the lens flare system is enabled.
  59161. */
  59162. get isEnabled(): boolean;
  59163. set isEnabled(value: boolean);
  59164. /**
  59165. * Get the scene the effects belongs to.
  59166. * @returns the scene holding the lens flare system
  59167. */
  59168. getScene(): Scene;
  59169. /**
  59170. * Get the emitter of the lens flare system.
  59171. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59172. * @returns the emitter of the lens flare system
  59173. */
  59174. getEmitter(): any;
  59175. /**
  59176. * Set the emitter of the lens flare system.
  59177. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59178. * @param newEmitter Define the new emitter of the system
  59179. */
  59180. setEmitter(newEmitter: any): void;
  59181. /**
  59182. * Get the lens flare system emitter position.
  59183. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59184. * @returns the position
  59185. */
  59186. getEmitterPosition(): Vector3;
  59187. /**
  59188. * @hidden
  59189. */
  59190. computeEffectivePosition(globalViewport: Viewport): boolean;
  59191. /** @hidden */
  59192. _isVisible(): boolean;
  59193. /**
  59194. * @hidden
  59195. */
  59196. render(): boolean;
  59197. /**
  59198. * Dispose and release the lens flare with its associated resources.
  59199. */
  59200. dispose(): void;
  59201. /**
  59202. * Parse a lens flare system from a JSON repressentation
  59203. * @param parsedLensFlareSystem Define the JSON to parse
  59204. * @param scene Define the scene the parsed system should be instantiated in
  59205. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59206. * @returns the parsed system
  59207. */
  59208. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59209. /**
  59210. * Serialize the current Lens Flare System into a JSON representation.
  59211. * @returns the serialized JSON
  59212. */
  59213. serialize(): any;
  59214. }
  59215. }
  59216. declare module BABYLON {
  59217. /**
  59218. * This represents one of the lens effect in a `lensFlareSystem`.
  59219. * It controls one of the indiviual texture used in the effect.
  59220. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59221. */
  59222. export class LensFlare {
  59223. /**
  59224. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59225. */
  59226. size: number;
  59227. /**
  59228. * 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.
  59229. */
  59230. position: number;
  59231. /**
  59232. * Define the lens color.
  59233. */
  59234. color: Color3;
  59235. /**
  59236. * Define the lens texture.
  59237. */
  59238. texture: Nullable<Texture>;
  59239. /**
  59240. * Define the alpha mode to render this particular lens.
  59241. */
  59242. alphaMode: number;
  59243. private _system;
  59244. /**
  59245. * Creates a new Lens Flare.
  59246. * This represents one of the lens effect in a `lensFlareSystem`.
  59247. * It controls one of the indiviual texture used in the effect.
  59248. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59249. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59250. * @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.
  59251. * @param color Define the lens color
  59252. * @param imgUrl Define the lens texture url
  59253. * @param system Define the `lensFlareSystem` this flare is part of
  59254. * @returns The newly created Lens Flare
  59255. */
  59256. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59257. /**
  59258. * Instantiates a new Lens Flare.
  59259. * This represents one of the lens effect in a `lensFlareSystem`.
  59260. * It controls one of the indiviual texture used in the effect.
  59261. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59262. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59263. * @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.
  59264. * @param color Define the lens color
  59265. * @param imgUrl Define the lens texture url
  59266. * @param system Define the `lensFlareSystem` this flare is part of
  59267. */
  59268. constructor(
  59269. /**
  59270. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59271. */
  59272. size: number,
  59273. /**
  59274. * 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.
  59275. */
  59276. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59277. /**
  59278. * Dispose and release the lens flare with its associated resources.
  59279. */
  59280. dispose(): void;
  59281. }
  59282. }
  59283. declare module BABYLON {
  59284. interface AbstractScene {
  59285. /**
  59286. * The list of lens flare system added to the scene
  59287. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59288. */
  59289. lensFlareSystems: Array<LensFlareSystem>;
  59290. /**
  59291. * Removes the given lens flare system from this scene.
  59292. * @param toRemove The lens flare system to remove
  59293. * @returns The index of the removed lens flare system
  59294. */
  59295. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59296. /**
  59297. * Adds the given lens flare system to this scene
  59298. * @param newLensFlareSystem The lens flare system to add
  59299. */
  59300. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59301. /**
  59302. * Gets a lens flare system using its name
  59303. * @param name defines the name to look for
  59304. * @returns the lens flare system or null if not found
  59305. */
  59306. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59307. /**
  59308. * Gets a lens flare system using its id
  59309. * @param id defines the id to look for
  59310. * @returns the lens flare system or null if not found
  59311. */
  59312. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59313. }
  59314. /**
  59315. * Defines the lens flare scene component responsible to manage any lens flares
  59316. * in a given scene.
  59317. */
  59318. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59319. /**
  59320. * The component name helpfull to identify the component in the list of scene components.
  59321. */
  59322. readonly name: string;
  59323. /**
  59324. * The scene the component belongs to.
  59325. */
  59326. scene: Scene;
  59327. /**
  59328. * Creates a new instance of the component for the given scene
  59329. * @param scene Defines the scene to register the component in
  59330. */
  59331. constructor(scene: Scene);
  59332. /**
  59333. * Registers the component in a given scene
  59334. */
  59335. register(): void;
  59336. /**
  59337. * Rebuilds the elements related to this component in case of
  59338. * context lost for instance.
  59339. */
  59340. rebuild(): void;
  59341. /**
  59342. * Adds all the elements from the container to the scene
  59343. * @param container the container holding the elements
  59344. */
  59345. addFromContainer(container: AbstractScene): void;
  59346. /**
  59347. * Removes all the elements in the container from the scene
  59348. * @param container contains the elements to remove
  59349. * @param dispose if the removed element should be disposed (default: false)
  59350. */
  59351. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59352. /**
  59353. * Serializes the component data to the specified json object
  59354. * @param serializationObject The object to serialize to
  59355. */
  59356. serialize(serializationObject: any): void;
  59357. /**
  59358. * Disposes the component and the associated ressources.
  59359. */
  59360. dispose(): void;
  59361. private _draw;
  59362. }
  59363. }
  59364. declare module BABYLON {
  59365. /** @hidden */
  59366. export var depthPixelShader: {
  59367. name: string;
  59368. shader: string;
  59369. };
  59370. }
  59371. declare module BABYLON {
  59372. /** @hidden */
  59373. export var depthVertexShader: {
  59374. name: string;
  59375. shader: string;
  59376. };
  59377. }
  59378. declare module BABYLON {
  59379. /**
  59380. * This represents a depth renderer in Babylon.
  59381. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59382. */
  59383. export class DepthRenderer {
  59384. private _scene;
  59385. private _depthMap;
  59386. private _effect;
  59387. private readonly _storeNonLinearDepth;
  59388. private readonly _clearColor;
  59389. /** Get if the depth renderer is using packed depth or not */
  59390. readonly isPacked: boolean;
  59391. private _cachedDefines;
  59392. private _camera;
  59393. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59394. enabled: boolean;
  59395. /**
  59396. * Specifiess that the depth renderer will only be used within
  59397. * the camera it is created for.
  59398. * This can help forcing its rendering during the camera processing.
  59399. */
  59400. useOnlyInActiveCamera: boolean;
  59401. /** @hidden */
  59402. static _SceneComponentInitialization: (scene: Scene) => void;
  59403. /**
  59404. * Instantiates a depth renderer
  59405. * @param scene The scene the renderer belongs to
  59406. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59407. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59408. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59409. */
  59410. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59411. /**
  59412. * Creates the depth rendering effect and checks if the effect is ready.
  59413. * @param subMesh The submesh to be used to render the depth map of
  59414. * @param useInstances If multiple world instances should be used
  59415. * @returns if the depth renderer is ready to render the depth map
  59416. */
  59417. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59418. /**
  59419. * Gets the texture which the depth map will be written to.
  59420. * @returns The depth map texture
  59421. */
  59422. getDepthMap(): RenderTargetTexture;
  59423. /**
  59424. * Disposes of the depth renderer.
  59425. */
  59426. dispose(): void;
  59427. }
  59428. }
  59429. declare module BABYLON {
  59430. /** @hidden */
  59431. export var minmaxReduxPixelShader: {
  59432. name: string;
  59433. shader: string;
  59434. };
  59435. }
  59436. declare module BABYLON {
  59437. /**
  59438. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59439. * and maximum values from all values of the texture.
  59440. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59441. * The source values are read from the red channel of the texture.
  59442. */
  59443. export class MinMaxReducer {
  59444. /**
  59445. * Observable triggered when the computation has been performed
  59446. */
  59447. onAfterReductionPerformed: Observable<{
  59448. min: number;
  59449. max: number;
  59450. }>;
  59451. protected _camera: Camera;
  59452. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59453. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59454. protected _postProcessManager: PostProcessManager;
  59455. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59456. protected _forceFullscreenViewport: boolean;
  59457. /**
  59458. * Creates a min/max reducer
  59459. * @param camera The camera to use for the post processes
  59460. */
  59461. constructor(camera: Camera);
  59462. /**
  59463. * Gets the texture used to read the values from.
  59464. */
  59465. get sourceTexture(): Nullable<RenderTargetTexture>;
  59466. /**
  59467. * Sets the source texture to read the values from.
  59468. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59469. * because in such textures '1' value must not be taken into account to compute the maximum
  59470. * as this value is used to clear the texture.
  59471. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59472. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59473. * @param depthRedux Indicates if the texture is a depth texture or not
  59474. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59475. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59476. */
  59477. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59478. /**
  59479. * Defines the refresh rate of the computation.
  59480. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59481. */
  59482. get refreshRate(): number;
  59483. set refreshRate(value: number);
  59484. protected _activated: boolean;
  59485. /**
  59486. * Gets the activation status of the reducer
  59487. */
  59488. get activated(): boolean;
  59489. /**
  59490. * Activates the reduction computation.
  59491. * When activated, the observers registered in onAfterReductionPerformed are
  59492. * called after the compuation is performed
  59493. */
  59494. activate(): void;
  59495. /**
  59496. * Deactivates the reduction computation.
  59497. */
  59498. deactivate(): void;
  59499. /**
  59500. * Disposes the min/max reducer
  59501. * @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.
  59502. */
  59503. dispose(disposeAll?: boolean): void;
  59504. }
  59505. }
  59506. declare module BABYLON {
  59507. /**
  59508. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59509. */
  59510. export class DepthReducer extends MinMaxReducer {
  59511. private _depthRenderer;
  59512. private _depthRendererId;
  59513. /**
  59514. * Gets the depth renderer used for the computation.
  59515. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59516. */
  59517. get depthRenderer(): Nullable<DepthRenderer>;
  59518. /**
  59519. * Creates a depth reducer
  59520. * @param camera The camera used to render the depth texture
  59521. */
  59522. constructor(camera: Camera);
  59523. /**
  59524. * Sets the depth renderer to use to generate the depth map
  59525. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59526. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59527. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59528. */
  59529. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59530. /** @hidden */
  59531. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59532. /**
  59533. * Activates the reduction computation.
  59534. * When activated, the observers registered in onAfterReductionPerformed are
  59535. * called after the compuation is performed
  59536. */
  59537. activate(): void;
  59538. /**
  59539. * Deactivates the reduction computation.
  59540. */
  59541. deactivate(): void;
  59542. /**
  59543. * Disposes the depth reducer
  59544. * @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.
  59545. */
  59546. dispose(disposeAll?: boolean): void;
  59547. }
  59548. }
  59549. declare module BABYLON {
  59550. /**
  59551. * A CSM implementation allowing casting shadows on large scenes.
  59552. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59553. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59554. */
  59555. export class CascadedShadowGenerator extends ShadowGenerator {
  59556. private static readonly frustumCornersNDCSpace;
  59557. /**
  59558. * Name of the CSM class
  59559. */
  59560. static CLASSNAME: string;
  59561. /**
  59562. * Defines the default number of cascades used by the CSM.
  59563. */
  59564. static readonly DEFAULT_CASCADES_COUNT: number;
  59565. /**
  59566. * Defines the minimum number of cascades used by the CSM.
  59567. */
  59568. static readonly MIN_CASCADES_COUNT: number;
  59569. /**
  59570. * Defines the maximum number of cascades used by the CSM.
  59571. */
  59572. static readonly MAX_CASCADES_COUNT: number;
  59573. protected _validateFilter(filter: number): number;
  59574. /**
  59575. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59576. */
  59577. penumbraDarkness: number;
  59578. private _numCascades;
  59579. /**
  59580. * Gets or set the number of cascades used by the CSM.
  59581. */
  59582. get numCascades(): number;
  59583. set numCascades(value: number);
  59584. /**
  59585. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59586. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59587. */
  59588. stabilizeCascades: boolean;
  59589. private _freezeShadowCastersBoundingInfo;
  59590. private _freezeShadowCastersBoundingInfoObservable;
  59591. /**
  59592. * Enables or disables the shadow casters bounding info computation.
  59593. * If your shadow casters don't move, you can disable this feature.
  59594. * If it is enabled, the bounding box computation is done every frame.
  59595. */
  59596. get freezeShadowCastersBoundingInfo(): boolean;
  59597. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59598. private _scbiMin;
  59599. private _scbiMax;
  59600. protected _computeShadowCastersBoundingInfo(): void;
  59601. protected _shadowCastersBoundingInfo: BoundingInfo;
  59602. /**
  59603. * Gets or sets the shadow casters bounding info.
  59604. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59605. * so that the system won't overwrite the bounds you provide
  59606. */
  59607. get shadowCastersBoundingInfo(): BoundingInfo;
  59608. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59609. protected _breaksAreDirty: boolean;
  59610. protected _minDistance: number;
  59611. protected _maxDistance: number;
  59612. /**
  59613. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59614. *
  59615. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59616. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59617. * @param min minimal distance for the breaks (default to 0.)
  59618. * @param max maximal distance for the breaks (default to 1.)
  59619. */
  59620. setMinMaxDistance(min: number, max: number): void;
  59621. /** Gets the minimal distance used in the cascade break computation */
  59622. get minDistance(): number;
  59623. /** Gets the maximal distance used in the cascade break computation */
  59624. get maxDistance(): number;
  59625. /**
  59626. * Gets the class name of that object
  59627. * @returns "CascadedShadowGenerator"
  59628. */
  59629. getClassName(): string;
  59630. private _cascadeMinExtents;
  59631. private _cascadeMaxExtents;
  59632. /**
  59633. * Gets a cascade minimum extents
  59634. * @param cascadeIndex index of the cascade
  59635. * @returns the minimum cascade extents
  59636. */
  59637. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59638. /**
  59639. * Gets a cascade maximum extents
  59640. * @param cascadeIndex index of the cascade
  59641. * @returns the maximum cascade extents
  59642. */
  59643. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59644. private _cascades;
  59645. private _currentLayer;
  59646. private _viewSpaceFrustumsZ;
  59647. private _viewMatrices;
  59648. private _projectionMatrices;
  59649. private _transformMatrices;
  59650. private _transformMatricesAsArray;
  59651. private _frustumLengths;
  59652. private _lightSizeUVCorrection;
  59653. private _depthCorrection;
  59654. private _frustumCornersWorldSpace;
  59655. private _frustumCenter;
  59656. private _shadowCameraPos;
  59657. private _shadowMaxZ;
  59658. /**
  59659. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59660. * It defaults to camera.maxZ
  59661. */
  59662. get shadowMaxZ(): number;
  59663. /**
  59664. * Sets the shadow max z distance.
  59665. */
  59666. set shadowMaxZ(value: number);
  59667. protected _debug: boolean;
  59668. /**
  59669. * Gets or sets the debug flag.
  59670. * When enabled, the cascades are materialized by different colors on the screen.
  59671. */
  59672. get debug(): boolean;
  59673. set debug(dbg: boolean);
  59674. private _depthClamp;
  59675. /**
  59676. * Gets or sets the depth clamping value.
  59677. *
  59678. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59679. * to account for the shadow casters far away.
  59680. *
  59681. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59682. */
  59683. get depthClamp(): boolean;
  59684. set depthClamp(value: boolean);
  59685. private _cascadeBlendPercentage;
  59686. /**
  59687. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59688. * It defaults to 0.1 (10% blending).
  59689. */
  59690. get cascadeBlendPercentage(): number;
  59691. set cascadeBlendPercentage(value: number);
  59692. private _lambda;
  59693. /**
  59694. * Gets or set the lambda parameter.
  59695. * This parameter is used to split the camera frustum and create the cascades.
  59696. * 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.
  59697. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59698. */
  59699. get lambda(): number;
  59700. set lambda(value: number);
  59701. /**
  59702. * Gets the view matrix corresponding to a given cascade
  59703. * @param cascadeNum cascade to retrieve the view matrix from
  59704. * @returns the cascade view matrix
  59705. */
  59706. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59707. /**
  59708. * Gets the projection matrix corresponding to a given cascade
  59709. * @param cascadeNum cascade to retrieve the projection matrix from
  59710. * @returns the cascade projection matrix
  59711. */
  59712. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59713. /**
  59714. * Gets the transformation matrix corresponding to a given cascade
  59715. * @param cascadeNum cascade to retrieve the transformation matrix from
  59716. * @returns the cascade transformation matrix
  59717. */
  59718. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59719. private _depthRenderer;
  59720. /**
  59721. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59722. *
  59723. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59724. *
  59725. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59726. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59727. * @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
  59728. */
  59729. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59730. private _depthReducer;
  59731. private _autoCalcDepthBounds;
  59732. /**
  59733. * Gets or sets the autoCalcDepthBounds property.
  59734. *
  59735. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59736. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59737. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59738. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59739. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59740. */
  59741. get autoCalcDepthBounds(): boolean;
  59742. set autoCalcDepthBounds(value: boolean);
  59743. /**
  59744. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59745. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59746. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59747. * for setting the refresh rate on the renderer yourself!
  59748. */
  59749. get autoCalcDepthBoundsRefreshRate(): number;
  59750. set autoCalcDepthBoundsRefreshRate(value: number);
  59751. /**
  59752. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59753. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59754. * you change the camera near/far planes!
  59755. */
  59756. splitFrustum(): void;
  59757. private _splitFrustum;
  59758. private _computeMatrices;
  59759. private _computeFrustumInWorldSpace;
  59760. private _computeCascadeFrustum;
  59761. /**
  59762. * Support test.
  59763. */
  59764. static get IsSupported(): boolean;
  59765. /** @hidden */
  59766. static _SceneComponentInitialization: (scene: Scene) => void;
  59767. /**
  59768. * Creates a Cascaded Shadow Generator object.
  59769. * A ShadowGenerator is the required tool to use the shadows.
  59770. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59771. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59772. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59773. * @param light The directional light object generating the shadows.
  59774. * @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.
  59775. */
  59776. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59777. protected _initializeGenerator(): void;
  59778. protected _createTargetRenderTexture(): void;
  59779. protected _initializeShadowMap(): void;
  59780. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59781. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59782. /**
  59783. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59784. * @param defines Defines of the material we want to update
  59785. * @param lightIndex Index of the light in the enabled light list of the material
  59786. */
  59787. prepareDefines(defines: any, lightIndex: number): void;
  59788. /**
  59789. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59790. * defined in the generator but impacting the effect).
  59791. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59792. * @param effect The effect we are binfing the information for
  59793. */
  59794. bindShadowLight(lightIndex: string, effect: Effect): void;
  59795. /**
  59796. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59797. * (eq to view projection * shadow projection matrices)
  59798. * @returns The transform matrix used to create the shadow map
  59799. */
  59800. getTransformMatrix(): Matrix;
  59801. /**
  59802. * Disposes the ShadowGenerator.
  59803. * Returns nothing.
  59804. */
  59805. dispose(): void;
  59806. /**
  59807. * Serializes the shadow generator setup to a json object.
  59808. * @returns The serialized JSON object
  59809. */
  59810. serialize(): any;
  59811. /**
  59812. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59813. * @param parsedShadowGenerator The JSON object to parse
  59814. * @param scene The scene to create the shadow map for
  59815. * @returns The parsed shadow generator
  59816. */
  59817. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59818. }
  59819. }
  59820. declare module BABYLON {
  59821. /**
  59822. * Defines the shadow generator component responsible to manage any shadow generators
  59823. * in a given scene.
  59824. */
  59825. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59826. /**
  59827. * The component name helpfull to identify the component in the list of scene components.
  59828. */
  59829. readonly name: string;
  59830. /**
  59831. * The scene the component belongs to.
  59832. */
  59833. scene: Scene;
  59834. /**
  59835. * Creates a new instance of the component for the given scene
  59836. * @param scene Defines the scene to register the component in
  59837. */
  59838. constructor(scene: Scene);
  59839. /**
  59840. * Registers the component in a given scene
  59841. */
  59842. register(): void;
  59843. /**
  59844. * Rebuilds the elements related to this component in case of
  59845. * context lost for instance.
  59846. */
  59847. rebuild(): void;
  59848. /**
  59849. * Serializes the component data to the specified json object
  59850. * @param serializationObject The object to serialize to
  59851. */
  59852. serialize(serializationObject: any): void;
  59853. /**
  59854. * Adds all the elements from the container to the scene
  59855. * @param container the container holding the elements
  59856. */
  59857. addFromContainer(container: AbstractScene): void;
  59858. /**
  59859. * Removes all the elements in the container from the scene
  59860. * @param container contains the elements to remove
  59861. * @param dispose if the removed element should be disposed (default: false)
  59862. */
  59863. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59864. /**
  59865. * Rebuilds the elements related to this component in case of
  59866. * context lost for instance.
  59867. */
  59868. dispose(): void;
  59869. private _gatherRenderTargets;
  59870. }
  59871. }
  59872. declare module BABYLON {
  59873. /**
  59874. * A point light is a light defined by an unique point in world space.
  59875. * The light is emitted in every direction from this point.
  59876. * A good example of a point light is a standard light bulb.
  59877. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59878. */
  59879. export class PointLight extends ShadowLight {
  59880. private _shadowAngle;
  59881. /**
  59882. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59883. * This specifies what angle the shadow will use to be created.
  59884. *
  59885. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59886. */
  59887. get shadowAngle(): number;
  59888. /**
  59889. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59890. * This specifies what angle the shadow will use to be created.
  59891. *
  59892. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59893. */
  59894. set shadowAngle(value: number);
  59895. /**
  59896. * Gets the direction if it has been set.
  59897. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59898. */
  59899. get direction(): Vector3;
  59900. /**
  59901. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59902. */
  59903. set direction(value: Vector3);
  59904. /**
  59905. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59906. * A PointLight emits the light in every direction.
  59907. * It can cast shadows.
  59908. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59909. * ```javascript
  59910. * var pointLight = new PointLight("pl", camera.position, scene);
  59911. * ```
  59912. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59913. * @param name The light friendly name
  59914. * @param position The position of the point light in the scene
  59915. * @param scene The scene the lights belongs to
  59916. */
  59917. constructor(name: string, position: Vector3, scene: Scene);
  59918. /**
  59919. * Returns the string "PointLight"
  59920. * @returns the class name
  59921. */
  59922. getClassName(): string;
  59923. /**
  59924. * Returns the integer 0.
  59925. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59926. */
  59927. getTypeID(): number;
  59928. /**
  59929. * Specifies wether or not the shadowmap should be a cube texture.
  59930. * @returns true if the shadowmap needs to be a cube texture.
  59931. */
  59932. needCube(): boolean;
  59933. /**
  59934. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59935. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59936. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59937. */
  59938. getShadowDirection(faceIndex?: number): Vector3;
  59939. /**
  59940. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59941. * - fov = PI / 2
  59942. * - aspect ratio : 1.0
  59943. * - z-near and far equal to the active camera minZ and maxZ.
  59944. * Returns the PointLight.
  59945. */
  59946. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59947. protected _buildUniformLayout(): void;
  59948. /**
  59949. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59950. * @param effect The effect to update
  59951. * @param lightIndex The index of the light in the effect to update
  59952. * @returns The point light
  59953. */
  59954. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59955. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59956. /**
  59957. * Prepares the list of defines specific to the light type.
  59958. * @param defines the list of defines
  59959. * @param lightIndex defines the index of the light for the effect
  59960. */
  59961. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59962. }
  59963. }
  59964. declare module BABYLON {
  59965. /**
  59966. * Header information of HDR texture files.
  59967. */
  59968. export interface HDRInfo {
  59969. /**
  59970. * The height of the texture in pixels.
  59971. */
  59972. height: number;
  59973. /**
  59974. * The width of the texture in pixels.
  59975. */
  59976. width: number;
  59977. /**
  59978. * The index of the beginning of the data in the binary file.
  59979. */
  59980. dataPosition: number;
  59981. }
  59982. /**
  59983. * This groups tools to convert HDR texture to native colors array.
  59984. */
  59985. export class HDRTools {
  59986. private static Ldexp;
  59987. private static Rgbe2float;
  59988. private static readStringLine;
  59989. /**
  59990. * Reads header information from an RGBE texture stored in a native array.
  59991. * More information on this format are available here:
  59992. * https://en.wikipedia.org/wiki/RGBE_image_format
  59993. *
  59994. * @param uint8array The binary file stored in native array.
  59995. * @return The header information.
  59996. */
  59997. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59998. /**
  59999. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60000. * This RGBE texture needs to store the information as a panorama.
  60001. *
  60002. * More information on this format are available here:
  60003. * https://en.wikipedia.org/wiki/RGBE_image_format
  60004. *
  60005. * @param buffer The binary file stored in an array buffer.
  60006. * @param size The expected size of the extracted cubemap.
  60007. * @return The Cube Map information.
  60008. */
  60009. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60010. /**
  60011. * Returns the pixels data extracted from an RGBE texture.
  60012. * This pixels will be stored left to right up to down in the R G B order in one array.
  60013. *
  60014. * More information on this format are available here:
  60015. * https://en.wikipedia.org/wiki/RGBE_image_format
  60016. *
  60017. * @param uint8array The binary file stored in an array buffer.
  60018. * @param hdrInfo The header information of the file.
  60019. * @return The pixels data in RGB right to left up to down order.
  60020. */
  60021. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60022. private static RGBE_ReadPixels_RLE;
  60023. private static RGBE_ReadPixels_NOT_RLE;
  60024. }
  60025. }
  60026. declare module BABYLON {
  60027. /**
  60028. * Effect Render Options
  60029. */
  60030. export interface IEffectRendererOptions {
  60031. /**
  60032. * Defines the vertices positions.
  60033. */
  60034. positions?: number[];
  60035. /**
  60036. * Defines the indices.
  60037. */
  60038. indices?: number[];
  60039. }
  60040. /**
  60041. * Helper class to render one or more effects.
  60042. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60043. */
  60044. export class EffectRenderer {
  60045. private engine;
  60046. private static _DefaultOptions;
  60047. private _vertexBuffers;
  60048. private _indexBuffer;
  60049. private _fullscreenViewport;
  60050. /**
  60051. * Creates an effect renderer
  60052. * @param engine the engine to use for rendering
  60053. * @param options defines the options of the effect renderer
  60054. */
  60055. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60056. /**
  60057. * Sets the current viewport in normalized coordinates 0-1
  60058. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60059. */
  60060. setViewport(viewport?: Viewport): void;
  60061. /**
  60062. * Binds the embedded attributes buffer to the effect.
  60063. * @param effect Defines the effect to bind the attributes for
  60064. */
  60065. bindBuffers(effect: Effect): void;
  60066. /**
  60067. * Sets the current effect wrapper to use during draw.
  60068. * The effect needs to be ready before calling this api.
  60069. * This also sets the default full screen position attribute.
  60070. * @param effectWrapper Defines the effect to draw with
  60071. */
  60072. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60073. /**
  60074. * Restores engine states
  60075. */
  60076. restoreStates(): void;
  60077. /**
  60078. * Draws a full screen quad.
  60079. */
  60080. draw(): void;
  60081. private isRenderTargetTexture;
  60082. /**
  60083. * renders one or more effects to a specified texture
  60084. * @param effectWrapper the effect to renderer
  60085. * @param outputTexture texture to draw to, if null it will render to the screen.
  60086. */
  60087. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60088. /**
  60089. * Disposes of the effect renderer
  60090. */
  60091. dispose(): void;
  60092. }
  60093. /**
  60094. * Options to create an EffectWrapper
  60095. */
  60096. interface EffectWrapperCreationOptions {
  60097. /**
  60098. * Engine to use to create the effect
  60099. */
  60100. engine: ThinEngine;
  60101. /**
  60102. * Fragment shader for the effect
  60103. */
  60104. fragmentShader: string;
  60105. /**
  60106. * Use the shader store instead of direct source code
  60107. */
  60108. useShaderStore?: boolean;
  60109. /**
  60110. * Vertex shader for the effect
  60111. */
  60112. vertexShader?: string;
  60113. /**
  60114. * Attributes to use in the shader
  60115. */
  60116. attributeNames?: Array<string>;
  60117. /**
  60118. * Uniforms to use in the shader
  60119. */
  60120. uniformNames?: Array<string>;
  60121. /**
  60122. * Texture sampler names to use in the shader
  60123. */
  60124. samplerNames?: Array<string>;
  60125. /**
  60126. * Defines to use in the shader
  60127. */
  60128. defines?: Array<string>;
  60129. /**
  60130. * Callback when effect is compiled
  60131. */
  60132. onCompiled?: Nullable<(effect: Effect) => void>;
  60133. /**
  60134. * The friendly name of the effect displayed in Spector.
  60135. */
  60136. name?: string;
  60137. }
  60138. /**
  60139. * Wraps an effect to be used for rendering
  60140. */
  60141. export class EffectWrapper {
  60142. /**
  60143. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60144. */
  60145. onApplyObservable: Observable<{}>;
  60146. /**
  60147. * The underlying effect
  60148. */
  60149. effect: Effect;
  60150. /**
  60151. * Creates an effect to be renderer
  60152. * @param creationOptions options to create the effect
  60153. */
  60154. constructor(creationOptions: EffectWrapperCreationOptions);
  60155. /**
  60156. * Disposes of the effect wrapper
  60157. */
  60158. dispose(): void;
  60159. }
  60160. }
  60161. declare module BABYLON {
  60162. /** @hidden */
  60163. export var hdrFilteringVertexShader: {
  60164. name: string;
  60165. shader: string;
  60166. };
  60167. }
  60168. declare module BABYLON {
  60169. /** @hidden */
  60170. export var hdrFilteringPixelShader: {
  60171. name: string;
  60172. shader: string;
  60173. };
  60174. }
  60175. declare module BABYLON {
  60176. /**
  60177. * Options for texture filtering
  60178. */
  60179. interface IHDRFilteringOptions {
  60180. /**
  60181. * Scales pixel intensity for the input HDR map.
  60182. */
  60183. hdrScale?: number;
  60184. /**
  60185. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60186. */
  60187. quality?: number;
  60188. }
  60189. /**
  60190. * Filters HDR maps to get correct renderings of PBR reflections
  60191. */
  60192. export class HDRFiltering {
  60193. private _engine;
  60194. private _effectRenderer;
  60195. private _effectWrapper;
  60196. private _lodGenerationOffset;
  60197. private _lodGenerationScale;
  60198. /**
  60199. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60200. * you care about baking speed.
  60201. */
  60202. quality: number;
  60203. /**
  60204. * Scales pixel intensity for the input HDR map.
  60205. */
  60206. hdrScale: number;
  60207. /**
  60208. * Instantiates HDR filter for reflection maps
  60209. *
  60210. * @param engine Thin engine
  60211. * @param options Options
  60212. */
  60213. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60214. private _createRenderTarget;
  60215. private _prefilterInternal;
  60216. private _createEffect;
  60217. /**
  60218. * Get a value indicating if the filter is ready to be used
  60219. * @param texture Texture to filter
  60220. * @returns true if the filter is ready
  60221. */
  60222. isReady(texture: BaseTexture): boolean;
  60223. /**
  60224. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60225. * Prefiltering will be invoked at the end of next rendering pass.
  60226. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60227. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60228. * @param texture Texture to filter
  60229. * @param onFinished Callback when filtering is done
  60230. * @return Promise called when prefiltering is done
  60231. */
  60232. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60233. }
  60234. }
  60235. declare module BABYLON {
  60236. /**
  60237. * This represents a texture coming from an HDR input.
  60238. *
  60239. * The only supported format is currently panorama picture stored in RGBE format.
  60240. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60241. */
  60242. export class HDRCubeTexture extends BaseTexture {
  60243. private static _facesMapping;
  60244. private _generateHarmonics;
  60245. private _noMipmap;
  60246. private _prefilterOnLoad;
  60247. private _textureMatrix;
  60248. private _size;
  60249. private _onLoad;
  60250. private _onError;
  60251. /**
  60252. * The texture URL.
  60253. */
  60254. url: string;
  60255. protected _isBlocking: boolean;
  60256. /**
  60257. * Sets wether or not the texture is blocking during loading.
  60258. */
  60259. set isBlocking(value: boolean);
  60260. /**
  60261. * Gets wether or not the texture is blocking during loading.
  60262. */
  60263. get isBlocking(): boolean;
  60264. protected _rotationY: number;
  60265. /**
  60266. * Sets texture matrix rotation angle around Y axis in radians.
  60267. */
  60268. set rotationY(value: number);
  60269. /**
  60270. * Gets texture matrix rotation angle around Y axis radians.
  60271. */
  60272. get rotationY(): number;
  60273. /**
  60274. * Gets or sets the center of the bounding box associated with the cube texture
  60275. * It must define where the camera used to render the texture was set
  60276. */
  60277. boundingBoxPosition: Vector3;
  60278. private _boundingBoxSize;
  60279. /**
  60280. * Gets or sets the size of the bounding box associated with the cube texture
  60281. * When defined, the cubemap will switch to local mode
  60282. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60283. * @example https://www.babylonjs-playground.com/#RNASML
  60284. */
  60285. set boundingBoxSize(value: Vector3);
  60286. get boundingBoxSize(): Vector3;
  60287. /**
  60288. * Instantiates an HDRTexture from the following parameters.
  60289. *
  60290. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60291. * @param sceneOrEngine The scene or engine the texture will be used in
  60292. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60293. * @param noMipmap Forces to not generate the mipmap if true
  60294. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60295. * @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)
  60296. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60297. */
  60298. 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>);
  60299. /**
  60300. * Get the current class name of the texture useful for serialization or dynamic coding.
  60301. * @returns "HDRCubeTexture"
  60302. */
  60303. getClassName(): string;
  60304. /**
  60305. * Occurs when the file is raw .hdr file.
  60306. */
  60307. private loadTexture;
  60308. clone(): HDRCubeTexture;
  60309. delayLoad(): void;
  60310. /**
  60311. * Get the texture reflection matrix used to rotate/transform the reflection.
  60312. * @returns the reflection matrix
  60313. */
  60314. getReflectionTextureMatrix(): Matrix;
  60315. /**
  60316. * Set the texture reflection matrix used to rotate/transform the reflection.
  60317. * @param value Define the reflection matrix to set
  60318. */
  60319. setReflectionTextureMatrix(value: Matrix): void;
  60320. /**
  60321. * Parses a JSON representation of an HDR Texture in order to create the texture
  60322. * @param parsedTexture Define the JSON representation
  60323. * @param scene Define the scene the texture should be created in
  60324. * @param rootUrl Define the root url in case we need to load relative dependencies
  60325. * @returns the newly created texture after parsing
  60326. */
  60327. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60328. serialize(): any;
  60329. }
  60330. }
  60331. declare module BABYLON {
  60332. /**
  60333. * Class used to control physics engine
  60334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60335. */
  60336. export class PhysicsEngine implements IPhysicsEngine {
  60337. private _physicsPlugin;
  60338. /**
  60339. * Global value used to control the smallest number supported by the simulation
  60340. */
  60341. static Epsilon: number;
  60342. private _impostors;
  60343. private _joints;
  60344. private _subTimeStep;
  60345. /**
  60346. * Gets the gravity vector used by the simulation
  60347. */
  60348. gravity: Vector3;
  60349. /**
  60350. * Factory used to create the default physics plugin.
  60351. * @returns The default physics plugin
  60352. */
  60353. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60354. /**
  60355. * Creates a new Physics Engine
  60356. * @param gravity defines the gravity vector used by the simulation
  60357. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60358. */
  60359. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60360. /**
  60361. * Sets the gravity vector used by the simulation
  60362. * @param gravity defines the gravity vector to use
  60363. */
  60364. setGravity(gravity: Vector3): void;
  60365. /**
  60366. * Set the time step of the physics engine.
  60367. * Default is 1/60.
  60368. * To slow it down, enter 1/600 for example.
  60369. * To speed it up, 1/30
  60370. * @param newTimeStep defines the new timestep to apply to this world.
  60371. */
  60372. setTimeStep(newTimeStep?: number): void;
  60373. /**
  60374. * Get the time step of the physics engine.
  60375. * @returns the current time step
  60376. */
  60377. getTimeStep(): number;
  60378. /**
  60379. * Set the sub time step of the physics engine.
  60380. * Default is 0 meaning there is no sub steps
  60381. * To increase physics resolution precision, set a small value (like 1 ms)
  60382. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60383. */
  60384. setSubTimeStep(subTimeStep?: number): void;
  60385. /**
  60386. * Get the sub time step of the physics engine.
  60387. * @returns the current sub time step
  60388. */
  60389. getSubTimeStep(): number;
  60390. /**
  60391. * Release all resources
  60392. */
  60393. dispose(): void;
  60394. /**
  60395. * Gets the name of the current physics plugin
  60396. * @returns the name of the plugin
  60397. */
  60398. getPhysicsPluginName(): string;
  60399. /**
  60400. * Adding a new impostor for the impostor tracking.
  60401. * This will be done by the impostor itself.
  60402. * @param impostor the impostor to add
  60403. */
  60404. addImpostor(impostor: PhysicsImpostor): void;
  60405. /**
  60406. * Remove an impostor from the engine.
  60407. * This impostor and its mesh will not longer be updated by the physics engine.
  60408. * @param impostor the impostor to remove
  60409. */
  60410. removeImpostor(impostor: PhysicsImpostor): void;
  60411. /**
  60412. * Add a joint to the physics engine
  60413. * @param mainImpostor defines the main impostor to which the joint is added.
  60414. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60415. * @param joint defines the joint that will connect both impostors.
  60416. */
  60417. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60418. /**
  60419. * Removes a joint from the simulation
  60420. * @param mainImpostor defines the impostor used with the joint
  60421. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60422. * @param joint defines the joint to remove
  60423. */
  60424. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60425. /**
  60426. * Called by the scene. No need to call it.
  60427. * @param delta defines the timespam between frames
  60428. */
  60429. _step(delta: number): void;
  60430. /**
  60431. * Gets the current plugin used to run the simulation
  60432. * @returns current plugin
  60433. */
  60434. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60435. /**
  60436. * Gets the list of physic impostors
  60437. * @returns an array of PhysicsImpostor
  60438. */
  60439. getImpostors(): Array<PhysicsImpostor>;
  60440. /**
  60441. * Gets the impostor for a physics enabled object
  60442. * @param object defines the object impersonated by the impostor
  60443. * @returns the PhysicsImpostor or null if not found
  60444. */
  60445. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60446. /**
  60447. * Gets the impostor for a physics body object
  60448. * @param body defines physics body used by the impostor
  60449. * @returns the PhysicsImpostor or null if not found
  60450. */
  60451. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60452. /**
  60453. * Does a raycast in the physics world
  60454. * @param from when should the ray start?
  60455. * @param to when should the ray end?
  60456. * @returns PhysicsRaycastResult
  60457. */
  60458. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60459. }
  60460. }
  60461. declare module BABYLON {
  60462. /** @hidden */
  60463. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60464. private _useDeltaForWorldStep;
  60465. world: any;
  60466. name: string;
  60467. private _physicsMaterials;
  60468. private _fixedTimeStep;
  60469. private _cannonRaycastResult;
  60470. private _raycastResult;
  60471. private _physicsBodysToRemoveAfterStep;
  60472. private _firstFrame;
  60473. BJSCANNON: any;
  60474. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60475. setGravity(gravity: Vector3): void;
  60476. setTimeStep(timeStep: number): void;
  60477. getTimeStep(): number;
  60478. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60479. private _removeMarkedPhysicsBodiesFromWorld;
  60480. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60481. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60482. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60483. private _processChildMeshes;
  60484. removePhysicsBody(impostor: PhysicsImpostor): void;
  60485. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60486. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60487. private _addMaterial;
  60488. private _checkWithEpsilon;
  60489. private _createShape;
  60490. private _createHeightmap;
  60491. private _minus90X;
  60492. private _plus90X;
  60493. private _tmpPosition;
  60494. private _tmpDeltaPosition;
  60495. private _tmpUnityRotation;
  60496. private _updatePhysicsBodyTransformation;
  60497. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60498. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60499. isSupported(): boolean;
  60500. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60501. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60502. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60503. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60504. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60505. getBodyMass(impostor: PhysicsImpostor): number;
  60506. getBodyFriction(impostor: PhysicsImpostor): number;
  60507. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60508. getBodyRestitution(impostor: PhysicsImpostor): number;
  60509. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60510. sleepBody(impostor: PhysicsImpostor): void;
  60511. wakeUpBody(impostor: PhysicsImpostor): void;
  60512. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60513. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60514. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60515. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60516. getRadius(impostor: PhysicsImpostor): number;
  60517. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60518. dispose(): void;
  60519. private _extendNamespace;
  60520. /**
  60521. * Does a raycast in the physics world
  60522. * @param from when should the ray start?
  60523. * @param to when should the ray end?
  60524. * @returns PhysicsRaycastResult
  60525. */
  60526. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60527. }
  60528. }
  60529. declare module BABYLON {
  60530. /** @hidden */
  60531. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60532. private _useDeltaForWorldStep;
  60533. world: any;
  60534. name: string;
  60535. BJSOIMO: any;
  60536. private _raycastResult;
  60537. private _fixedTimeStep;
  60538. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60539. setGravity(gravity: Vector3): void;
  60540. setTimeStep(timeStep: number): void;
  60541. getTimeStep(): number;
  60542. private _tmpImpostorsArray;
  60543. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60544. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60545. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60546. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60547. private _tmpPositionVector;
  60548. removePhysicsBody(impostor: PhysicsImpostor): void;
  60549. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60550. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60551. isSupported(): boolean;
  60552. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60553. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60554. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60555. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60556. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60557. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60558. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60559. getBodyMass(impostor: PhysicsImpostor): number;
  60560. getBodyFriction(impostor: PhysicsImpostor): number;
  60561. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60562. getBodyRestitution(impostor: PhysicsImpostor): number;
  60563. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60564. sleepBody(impostor: PhysicsImpostor): void;
  60565. wakeUpBody(impostor: PhysicsImpostor): void;
  60566. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60567. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60568. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60569. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60570. getRadius(impostor: PhysicsImpostor): number;
  60571. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60572. dispose(): void;
  60573. /**
  60574. * Does a raycast in the physics world
  60575. * @param from when should the ray start?
  60576. * @param to when should the ray end?
  60577. * @returns PhysicsRaycastResult
  60578. */
  60579. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60580. }
  60581. }
  60582. declare module BABYLON {
  60583. /**
  60584. * AmmoJS Physics plugin
  60585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60586. * @see https://github.com/kripken/ammo.js/
  60587. */
  60588. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60589. private _useDeltaForWorldStep;
  60590. /**
  60591. * Reference to the Ammo library
  60592. */
  60593. bjsAMMO: any;
  60594. /**
  60595. * Created ammoJS world which physics bodies are added to
  60596. */
  60597. world: any;
  60598. /**
  60599. * Name of the plugin
  60600. */
  60601. name: string;
  60602. private _timeStep;
  60603. private _fixedTimeStep;
  60604. private _maxSteps;
  60605. private _tmpQuaternion;
  60606. private _tmpAmmoTransform;
  60607. private _tmpAmmoQuaternion;
  60608. private _tmpAmmoConcreteContactResultCallback;
  60609. private _collisionConfiguration;
  60610. private _dispatcher;
  60611. private _overlappingPairCache;
  60612. private _solver;
  60613. private _softBodySolver;
  60614. private _tmpAmmoVectorA;
  60615. private _tmpAmmoVectorB;
  60616. private _tmpAmmoVectorC;
  60617. private _tmpAmmoVectorD;
  60618. private _tmpContactCallbackResult;
  60619. private _tmpAmmoVectorRCA;
  60620. private _tmpAmmoVectorRCB;
  60621. private _raycastResult;
  60622. private static readonly DISABLE_COLLISION_FLAG;
  60623. private static readonly KINEMATIC_FLAG;
  60624. private static readonly DISABLE_DEACTIVATION_FLAG;
  60625. /**
  60626. * Initializes the ammoJS plugin
  60627. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60628. * @param ammoInjection can be used to inject your own ammo reference
  60629. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60630. */
  60631. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60632. /**
  60633. * Sets the gravity of the physics world (m/(s^2))
  60634. * @param gravity Gravity to set
  60635. */
  60636. setGravity(gravity: Vector3): void;
  60637. /**
  60638. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60639. * @param timeStep timestep to use in seconds
  60640. */
  60641. setTimeStep(timeStep: number): void;
  60642. /**
  60643. * 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)
  60644. * @param fixedTimeStep fixedTimeStep to use in seconds
  60645. */
  60646. setFixedTimeStep(fixedTimeStep: number): void;
  60647. /**
  60648. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60649. * @param maxSteps the maximum number of steps by the physics engine per frame
  60650. */
  60651. setMaxSteps(maxSteps: number): void;
  60652. /**
  60653. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60654. * @returns the current timestep in seconds
  60655. */
  60656. getTimeStep(): number;
  60657. /**
  60658. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60659. */
  60660. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60661. private _isImpostorInContact;
  60662. private _isImpostorPairInContact;
  60663. private _stepSimulation;
  60664. /**
  60665. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60666. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60667. * After the step the babylon meshes are set to the position of the physics imposters
  60668. * @param delta amount of time to step forward
  60669. * @param impostors array of imposters to update before/after the step
  60670. */
  60671. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60672. /**
  60673. * Update babylon mesh to match physics world object
  60674. * @param impostor imposter to match
  60675. */
  60676. private _afterSoftStep;
  60677. /**
  60678. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60679. * @param impostor imposter to match
  60680. */
  60681. private _ropeStep;
  60682. /**
  60683. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60684. * @param impostor imposter to match
  60685. */
  60686. private _softbodyOrClothStep;
  60687. private _tmpMatrix;
  60688. /**
  60689. * Applies an impulse on the imposter
  60690. * @param impostor imposter to apply impulse to
  60691. * @param force amount of force to be applied to the imposter
  60692. * @param contactPoint the location to apply the impulse on the imposter
  60693. */
  60694. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60695. /**
  60696. * Applies a force on the imposter
  60697. * @param impostor imposter to apply force
  60698. * @param force amount of force to be applied to the imposter
  60699. * @param contactPoint the location to apply the force on the imposter
  60700. */
  60701. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60702. /**
  60703. * Creates a physics body using the plugin
  60704. * @param impostor the imposter to create the physics body on
  60705. */
  60706. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60707. /**
  60708. * Removes the physics body from the imposter and disposes of the body's memory
  60709. * @param impostor imposter to remove the physics body from
  60710. */
  60711. removePhysicsBody(impostor: PhysicsImpostor): void;
  60712. /**
  60713. * Generates a joint
  60714. * @param impostorJoint the imposter joint to create the joint with
  60715. */
  60716. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60717. /**
  60718. * Removes a joint
  60719. * @param impostorJoint the imposter joint to remove the joint from
  60720. */
  60721. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60722. private _addMeshVerts;
  60723. /**
  60724. * Initialise the soft body vertices to match its object's (mesh) vertices
  60725. * Softbody vertices (nodes) are in world space and to match this
  60726. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60727. * @param impostor to create the softbody for
  60728. */
  60729. private _softVertexData;
  60730. /**
  60731. * Create an impostor's soft body
  60732. * @param impostor to create the softbody for
  60733. */
  60734. private _createSoftbody;
  60735. /**
  60736. * Create cloth for an impostor
  60737. * @param impostor to create the softbody for
  60738. */
  60739. private _createCloth;
  60740. /**
  60741. * Create rope for an impostor
  60742. * @param impostor to create the softbody for
  60743. */
  60744. private _createRope;
  60745. /**
  60746. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60747. * @param impostor to create the custom physics shape for
  60748. */
  60749. private _createCustom;
  60750. private _addHullVerts;
  60751. private _createShape;
  60752. /**
  60753. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60754. * @param impostor imposter containing the physics body and babylon object
  60755. */
  60756. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60757. /**
  60758. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60759. * @param impostor imposter containing the physics body and babylon object
  60760. * @param newPosition new position
  60761. * @param newRotation new rotation
  60762. */
  60763. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60764. /**
  60765. * If this plugin is supported
  60766. * @returns true if its supported
  60767. */
  60768. isSupported(): boolean;
  60769. /**
  60770. * Sets the linear velocity of the physics body
  60771. * @param impostor imposter to set the velocity on
  60772. * @param velocity velocity to set
  60773. */
  60774. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60775. /**
  60776. * Sets the angular velocity of the physics body
  60777. * @param impostor imposter to set the velocity on
  60778. * @param velocity velocity to set
  60779. */
  60780. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60781. /**
  60782. * gets the linear velocity
  60783. * @param impostor imposter to get linear velocity from
  60784. * @returns linear velocity
  60785. */
  60786. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60787. /**
  60788. * gets the angular velocity
  60789. * @param impostor imposter to get angular velocity from
  60790. * @returns angular velocity
  60791. */
  60792. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60793. /**
  60794. * Sets the mass of physics body
  60795. * @param impostor imposter to set the mass on
  60796. * @param mass mass to set
  60797. */
  60798. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60799. /**
  60800. * Gets the mass of the physics body
  60801. * @param impostor imposter to get the mass from
  60802. * @returns mass
  60803. */
  60804. getBodyMass(impostor: PhysicsImpostor): number;
  60805. /**
  60806. * Gets friction of the impostor
  60807. * @param impostor impostor to get friction from
  60808. * @returns friction value
  60809. */
  60810. getBodyFriction(impostor: PhysicsImpostor): number;
  60811. /**
  60812. * Sets friction of the impostor
  60813. * @param impostor impostor to set friction on
  60814. * @param friction friction value
  60815. */
  60816. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60817. /**
  60818. * Gets restitution of the impostor
  60819. * @param impostor impostor to get restitution from
  60820. * @returns restitution value
  60821. */
  60822. getBodyRestitution(impostor: PhysicsImpostor): number;
  60823. /**
  60824. * Sets resitution of the impostor
  60825. * @param impostor impostor to set resitution on
  60826. * @param restitution resitution value
  60827. */
  60828. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60829. /**
  60830. * Gets pressure inside the impostor
  60831. * @param impostor impostor to get pressure from
  60832. * @returns pressure value
  60833. */
  60834. getBodyPressure(impostor: PhysicsImpostor): number;
  60835. /**
  60836. * Sets pressure inside a soft body impostor
  60837. * Cloth and rope must remain 0 pressure
  60838. * @param impostor impostor to set pressure on
  60839. * @param pressure pressure value
  60840. */
  60841. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60842. /**
  60843. * Gets stiffness of the impostor
  60844. * @param impostor impostor to get stiffness from
  60845. * @returns pressure value
  60846. */
  60847. getBodyStiffness(impostor: PhysicsImpostor): number;
  60848. /**
  60849. * Sets stiffness of the impostor
  60850. * @param impostor impostor to set stiffness on
  60851. * @param stiffness stiffness value from 0 to 1
  60852. */
  60853. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60854. /**
  60855. * Gets velocityIterations of the impostor
  60856. * @param impostor impostor to get velocity iterations from
  60857. * @returns velocityIterations value
  60858. */
  60859. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60860. /**
  60861. * Sets velocityIterations of the impostor
  60862. * @param impostor impostor to set velocity iterations on
  60863. * @param velocityIterations velocityIterations value
  60864. */
  60865. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60866. /**
  60867. * Gets positionIterations of the impostor
  60868. * @param impostor impostor to get position iterations from
  60869. * @returns positionIterations value
  60870. */
  60871. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60872. /**
  60873. * Sets positionIterations of the impostor
  60874. * @param impostor impostor to set position on
  60875. * @param positionIterations positionIterations value
  60876. */
  60877. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60878. /**
  60879. * Append an anchor to a cloth object
  60880. * @param impostor is the cloth impostor to add anchor to
  60881. * @param otherImpostor is the rigid impostor to anchor to
  60882. * @param width ratio across width from 0 to 1
  60883. * @param height ratio up height from 0 to 1
  60884. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60885. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60886. */
  60887. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60888. /**
  60889. * Append an hook to a rope object
  60890. * @param impostor is the rope impostor to add hook to
  60891. * @param otherImpostor is the rigid impostor to hook to
  60892. * @param length ratio along the rope from 0 to 1
  60893. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60894. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60895. */
  60896. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60897. /**
  60898. * Sleeps the physics body and stops it from being active
  60899. * @param impostor impostor to sleep
  60900. */
  60901. sleepBody(impostor: PhysicsImpostor): void;
  60902. /**
  60903. * Activates the physics body
  60904. * @param impostor impostor to activate
  60905. */
  60906. wakeUpBody(impostor: PhysicsImpostor): void;
  60907. /**
  60908. * Updates the distance parameters of the joint
  60909. * @param joint joint to update
  60910. * @param maxDistance maximum distance of the joint
  60911. * @param minDistance minimum distance of the joint
  60912. */
  60913. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60914. /**
  60915. * Sets a motor on the joint
  60916. * @param joint joint to set motor on
  60917. * @param speed speed of the motor
  60918. * @param maxForce maximum force of the motor
  60919. * @param motorIndex index of the motor
  60920. */
  60921. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60922. /**
  60923. * Sets the motors limit
  60924. * @param joint joint to set limit on
  60925. * @param upperLimit upper limit
  60926. * @param lowerLimit lower limit
  60927. */
  60928. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60929. /**
  60930. * Syncs the position and rotation of a mesh with the impostor
  60931. * @param mesh mesh to sync
  60932. * @param impostor impostor to update the mesh with
  60933. */
  60934. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60935. /**
  60936. * Gets the radius of the impostor
  60937. * @param impostor impostor to get radius from
  60938. * @returns the radius
  60939. */
  60940. getRadius(impostor: PhysicsImpostor): number;
  60941. /**
  60942. * Gets the box size of the impostor
  60943. * @param impostor impostor to get box size from
  60944. * @param result the resulting box size
  60945. */
  60946. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60947. /**
  60948. * Disposes of the impostor
  60949. */
  60950. dispose(): void;
  60951. /**
  60952. * Does a raycast in the physics world
  60953. * @param from when should the ray start?
  60954. * @param to when should the ray end?
  60955. * @returns PhysicsRaycastResult
  60956. */
  60957. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60958. }
  60959. }
  60960. declare module BABYLON {
  60961. interface AbstractScene {
  60962. /**
  60963. * The list of reflection probes added to the scene
  60964. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60965. */
  60966. reflectionProbes: Array<ReflectionProbe>;
  60967. /**
  60968. * Removes the given reflection probe from this scene.
  60969. * @param toRemove The reflection probe to remove
  60970. * @returns The index of the removed reflection probe
  60971. */
  60972. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60973. /**
  60974. * Adds the given reflection probe to this scene.
  60975. * @param newReflectionProbe The reflection probe to add
  60976. */
  60977. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60978. }
  60979. /**
  60980. * Class used to generate realtime reflection / refraction cube textures
  60981. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60982. */
  60983. export class ReflectionProbe {
  60984. /** defines the name of the probe */
  60985. name: string;
  60986. private _scene;
  60987. private _renderTargetTexture;
  60988. private _projectionMatrix;
  60989. private _viewMatrix;
  60990. private _target;
  60991. private _add;
  60992. private _attachedMesh;
  60993. private _invertYAxis;
  60994. /** Gets or sets probe position (center of the cube map) */
  60995. position: Vector3;
  60996. /**
  60997. * Creates a new reflection probe
  60998. * @param name defines the name of the probe
  60999. * @param size defines the texture resolution (for each face)
  61000. * @param scene defines the hosting scene
  61001. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61002. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61003. */
  61004. constructor(
  61005. /** defines the name of the probe */
  61006. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61007. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61008. get samples(): number;
  61009. set samples(value: number);
  61010. /** Gets or sets the refresh rate to use (on every frame by default) */
  61011. get refreshRate(): number;
  61012. set refreshRate(value: number);
  61013. /**
  61014. * Gets the hosting scene
  61015. * @returns a Scene
  61016. */
  61017. getScene(): Scene;
  61018. /** Gets the internal CubeTexture used to render to */
  61019. get cubeTexture(): RenderTargetTexture;
  61020. /** Gets the list of meshes to render */
  61021. get renderList(): Nullable<AbstractMesh[]>;
  61022. /**
  61023. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61024. * @param mesh defines the mesh to attach to
  61025. */
  61026. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61027. /**
  61028. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61029. * @param renderingGroupId The rendering group id corresponding to its index
  61030. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61031. */
  61032. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61033. /**
  61034. * Clean all associated resources
  61035. */
  61036. dispose(): void;
  61037. /**
  61038. * Converts the reflection probe information to a readable string for debug purpose.
  61039. * @param fullDetails Supports for multiple levels of logging within scene loading
  61040. * @returns the human readable reflection probe info
  61041. */
  61042. toString(fullDetails?: boolean): string;
  61043. /**
  61044. * Get the class name of the relfection probe.
  61045. * @returns "ReflectionProbe"
  61046. */
  61047. getClassName(): string;
  61048. /**
  61049. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61050. * @returns The JSON representation of the texture
  61051. */
  61052. serialize(): any;
  61053. /**
  61054. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61055. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61056. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61057. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61058. * @returns The parsed reflection probe if successful
  61059. */
  61060. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61061. }
  61062. }
  61063. declare module BABYLON {
  61064. /** @hidden */
  61065. export var _BabylonLoaderRegistered: boolean;
  61066. /**
  61067. * Helps setting up some configuration for the babylon file loader.
  61068. */
  61069. export class BabylonFileLoaderConfiguration {
  61070. /**
  61071. * The loader does not allow injecting custom physix engine into the plugins.
  61072. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61073. * So you could set this variable to your engine import to make it work.
  61074. */
  61075. static LoaderInjectedPhysicsEngine: any;
  61076. }
  61077. }
  61078. declare module BABYLON {
  61079. /**
  61080. * The Physically based simple base material of BJS.
  61081. *
  61082. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61083. * It is used as the base class for both the specGloss and metalRough conventions.
  61084. */
  61085. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61086. /**
  61087. * Number of Simultaneous lights allowed on the material.
  61088. */
  61089. maxSimultaneousLights: number;
  61090. /**
  61091. * If sets to true, disables all the lights affecting the material.
  61092. */
  61093. disableLighting: boolean;
  61094. /**
  61095. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61096. */
  61097. environmentTexture: BaseTexture;
  61098. /**
  61099. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61100. */
  61101. invertNormalMapX: boolean;
  61102. /**
  61103. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61104. */
  61105. invertNormalMapY: boolean;
  61106. /**
  61107. * Normal map used in the model.
  61108. */
  61109. normalTexture: BaseTexture;
  61110. /**
  61111. * Emissivie color used to self-illuminate the model.
  61112. */
  61113. emissiveColor: Color3;
  61114. /**
  61115. * Emissivie texture used to self-illuminate the model.
  61116. */
  61117. emissiveTexture: BaseTexture;
  61118. /**
  61119. * Occlusion Channel Strenght.
  61120. */
  61121. occlusionStrength: number;
  61122. /**
  61123. * Occlusion Texture of the material (adding extra occlusion effects).
  61124. */
  61125. occlusionTexture: BaseTexture;
  61126. /**
  61127. * Defines the alpha limits in alpha test mode.
  61128. */
  61129. alphaCutOff: number;
  61130. /**
  61131. * Gets the current double sided mode.
  61132. */
  61133. get doubleSided(): boolean;
  61134. /**
  61135. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61136. */
  61137. set doubleSided(value: boolean);
  61138. /**
  61139. * Stores the pre-calculated light information of a mesh in a texture.
  61140. */
  61141. lightmapTexture: BaseTexture;
  61142. /**
  61143. * If true, the light map contains occlusion information instead of lighting info.
  61144. */
  61145. useLightmapAsShadowmap: boolean;
  61146. /**
  61147. * Instantiates a new PBRMaterial instance.
  61148. *
  61149. * @param name The material name
  61150. * @param scene The scene the material will be use in.
  61151. */
  61152. constructor(name: string, scene: Scene);
  61153. getClassName(): string;
  61154. }
  61155. }
  61156. declare module BABYLON {
  61157. /**
  61158. * The PBR material of BJS following the metal roughness convention.
  61159. *
  61160. * This fits to the PBR convention in the GLTF definition:
  61161. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61162. */
  61163. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61164. /**
  61165. * The base color has two different interpretations depending on the value of metalness.
  61166. * When the material is a metal, the base color is the specific measured reflectance value
  61167. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61168. * of the material.
  61169. */
  61170. baseColor: Color3;
  61171. /**
  61172. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61173. * well as opacity information in the alpha channel.
  61174. */
  61175. baseTexture: BaseTexture;
  61176. /**
  61177. * Specifies the metallic scalar value of the material.
  61178. * Can also be used to scale the metalness values of the metallic texture.
  61179. */
  61180. metallic: number;
  61181. /**
  61182. * Specifies the roughness scalar value of the material.
  61183. * Can also be used to scale the roughness values of the metallic texture.
  61184. */
  61185. roughness: number;
  61186. /**
  61187. * Texture containing both the metallic value in the B channel and the
  61188. * roughness value in the G channel to keep better precision.
  61189. */
  61190. metallicRoughnessTexture: BaseTexture;
  61191. /**
  61192. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61193. *
  61194. * @param name The material name
  61195. * @param scene The scene the material will be use in.
  61196. */
  61197. constructor(name: string, scene: Scene);
  61198. /**
  61199. * Return the currrent class name of the material.
  61200. */
  61201. getClassName(): string;
  61202. /**
  61203. * Makes a duplicate of the current material.
  61204. * @param name - name to use for the new material.
  61205. */
  61206. clone(name: string): PBRMetallicRoughnessMaterial;
  61207. /**
  61208. * Serialize the material to a parsable JSON object.
  61209. */
  61210. serialize(): any;
  61211. /**
  61212. * Parses a JSON object correponding to the serialize function.
  61213. */
  61214. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61215. }
  61216. }
  61217. declare module BABYLON {
  61218. /**
  61219. * The PBR material of BJS following the specular glossiness convention.
  61220. *
  61221. * This fits to the PBR convention in the GLTF definition:
  61222. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61223. */
  61224. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61225. /**
  61226. * Specifies the diffuse color of the material.
  61227. */
  61228. diffuseColor: Color3;
  61229. /**
  61230. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61231. * channel.
  61232. */
  61233. diffuseTexture: BaseTexture;
  61234. /**
  61235. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61236. */
  61237. specularColor: Color3;
  61238. /**
  61239. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61240. */
  61241. glossiness: number;
  61242. /**
  61243. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61244. */
  61245. specularGlossinessTexture: BaseTexture;
  61246. /**
  61247. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61248. *
  61249. * @param name The material name
  61250. * @param scene The scene the material will be use in.
  61251. */
  61252. constructor(name: string, scene: Scene);
  61253. /**
  61254. * Return the currrent class name of the material.
  61255. */
  61256. getClassName(): string;
  61257. /**
  61258. * Makes a duplicate of the current material.
  61259. * @param name - name to use for the new material.
  61260. */
  61261. clone(name: string): PBRSpecularGlossinessMaterial;
  61262. /**
  61263. * Serialize the material to a parsable JSON object.
  61264. */
  61265. serialize(): any;
  61266. /**
  61267. * Parses a JSON object correponding to the serialize function.
  61268. */
  61269. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61270. }
  61271. }
  61272. declare module BABYLON {
  61273. /**
  61274. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61275. * It can help converting any input color in a desired output one. This can then be used to create effects
  61276. * from sepia, black and white to sixties or futuristic rendering...
  61277. *
  61278. * The only supported format is currently 3dl.
  61279. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61280. */
  61281. export class ColorGradingTexture extends BaseTexture {
  61282. /**
  61283. * The texture URL.
  61284. */
  61285. url: string;
  61286. /**
  61287. * Empty line regex stored for GC.
  61288. */
  61289. private static _noneEmptyLineRegex;
  61290. private _textureMatrix;
  61291. private _onLoad;
  61292. /**
  61293. * Instantiates a ColorGradingTexture from the following parameters.
  61294. *
  61295. * @param url The location of the color gradind data (currently only supporting 3dl)
  61296. * @param sceneOrEngine The scene or engine the texture will be used in
  61297. * @param onLoad defines a callback triggered when the texture has been loaded
  61298. */
  61299. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61300. /**
  61301. * Fires the onload event from the constructor if requested.
  61302. */
  61303. private _triggerOnLoad;
  61304. /**
  61305. * Returns the texture matrix used in most of the material.
  61306. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61307. */
  61308. getTextureMatrix(): Matrix;
  61309. /**
  61310. * Occurs when the file being loaded is a .3dl LUT file.
  61311. */
  61312. private load3dlTexture;
  61313. /**
  61314. * Starts the loading process of the texture.
  61315. */
  61316. private loadTexture;
  61317. /**
  61318. * Clones the color gradind texture.
  61319. */
  61320. clone(): ColorGradingTexture;
  61321. /**
  61322. * Called during delayed load for textures.
  61323. */
  61324. delayLoad(): void;
  61325. /**
  61326. * Parses a color grading texture serialized by Babylon.
  61327. * @param parsedTexture The texture information being parsedTexture
  61328. * @param scene The scene to load the texture in
  61329. * @param rootUrl The root url of the data assets to load
  61330. * @return A color gradind texture
  61331. */
  61332. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61333. /**
  61334. * Serializes the LUT texture to json format.
  61335. */
  61336. serialize(): any;
  61337. }
  61338. }
  61339. declare module BABYLON {
  61340. /**
  61341. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61342. */
  61343. export class EquiRectangularCubeTexture extends BaseTexture {
  61344. /** The six faces of the cube. */
  61345. private static _FacesMapping;
  61346. private _noMipmap;
  61347. private _onLoad;
  61348. private _onError;
  61349. /** The size of the cubemap. */
  61350. private _size;
  61351. /** The buffer of the image. */
  61352. private _buffer;
  61353. /** The width of the input image. */
  61354. private _width;
  61355. /** The height of the input image. */
  61356. private _height;
  61357. /** The URL to the image. */
  61358. url: string;
  61359. /**
  61360. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61361. * @param url The location of the image
  61362. * @param scene The scene the texture will be used in
  61363. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61364. * @param noMipmap Forces to not generate the mipmap if true
  61365. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61366. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61367. * @param onLoad — defines a callback called when texture is loaded
  61368. * @param onError — defines a callback called if there is an error
  61369. */
  61370. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61371. /**
  61372. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61373. */
  61374. private loadImage;
  61375. /**
  61376. * Convert the image buffer into a cubemap and create a CubeTexture.
  61377. */
  61378. private loadTexture;
  61379. /**
  61380. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61381. * @param buffer The ArrayBuffer that should be converted.
  61382. * @returns The buffer as Float32Array.
  61383. */
  61384. private getFloat32ArrayFromArrayBuffer;
  61385. /**
  61386. * Get the current class name of the texture useful for serialization or dynamic coding.
  61387. * @returns "EquiRectangularCubeTexture"
  61388. */
  61389. getClassName(): string;
  61390. /**
  61391. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61392. * @returns A clone of the current EquiRectangularCubeTexture.
  61393. */
  61394. clone(): EquiRectangularCubeTexture;
  61395. }
  61396. }
  61397. declare module BABYLON {
  61398. /**
  61399. * Defines the options related to the creation of an HtmlElementTexture
  61400. */
  61401. export interface IHtmlElementTextureOptions {
  61402. /**
  61403. * Defines wether mip maps should be created or not.
  61404. */
  61405. generateMipMaps?: boolean;
  61406. /**
  61407. * Defines the sampling mode of the texture.
  61408. */
  61409. samplingMode?: number;
  61410. /**
  61411. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61412. */
  61413. engine: Nullable<ThinEngine>;
  61414. /**
  61415. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61416. */
  61417. scene: Nullable<Scene>;
  61418. }
  61419. /**
  61420. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61421. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61422. * is automatically managed.
  61423. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61424. * in your application.
  61425. *
  61426. * As the update is not automatic, you need to call them manually.
  61427. */
  61428. export class HtmlElementTexture extends BaseTexture {
  61429. /**
  61430. * The texture URL.
  61431. */
  61432. element: HTMLVideoElement | HTMLCanvasElement;
  61433. private static readonly DefaultOptions;
  61434. private _textureMatrix;
  61435. private _isVideo;
  61436. private _generateMipMaps;
  61437. private _samplingMode;
  61438. /**
  61439. * Instantiates a HtmlElementTexture from the following parameters.
  61440. *
  61441. * @param name Defines the name of the texture
  61442. * @param element Defines the video or canvas the texture is filled with
  61443. * @param options Defines the other none mandatory texture creation options
  61444. */
  61445. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61446. private _createInternalTexture;
  61447. /**
  61448. * Returns the texture matrix used in most of the material.
  61449. */
  61450. getTextureMatrix(): Matrix;
  61451. /**
  61452. * Updates the content of the texture.
  61453. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61454. */
  61455. update(invertY?: Nullable<boolean>): void;
  61456. }
  61457. }
  61458. declare module BABYLON {
  61459. /**
  61460. * Based on jsTGALoader - Javascript loader for TGA file
  61461. * By Vincent Thibault
  61462. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61463. */
  61464. export class TGATools {
  61465. private static _TYPE_INDEXED;
  61466. private static _TYPE_RGB;
  61467. private static _TYPE_GREY;
  61468. private static _TYPE_RLE_INDEXED;
  61469. private static _TYPE_RLE_RGB;
  61470. private static _TYPE_RLE_GREY;
  61471. private static _ORIGIN_MASK;
  61472. private static _ORIGIN_SHIFT;
  61473. private static _ORIGIN_BL;
  61474. private static _ORIGIN_BR;
  61475. private static _ORIGIN_UL;
  61476. private static _ORIGIN_UR;
  61477. /**
  61478. * Gets the header of a TGA file
  61479. * @param data defines the TGA data
  61480. * @returns the header
  61481. */
  61482. static GetTGAHeader(data: Uint8Array): any;
  61483. /**
  61484. * Uploads TGA content to a Babylon Texture
  61485. * @hidden
  61486. */
  61487. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61488. /** @hidden */
  61489. 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;
  61490. /** @hidden */
  61491. 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;
  61492. /** @hidden */
  61493. 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;
  61494. /** @hidden */
  61495. 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;
  61496. /** @hidden */
  61497. 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;
  61498. /** @hidden */
  61499. 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;
  61500. }
  61501. }
  61502. declare module BABYLON {
  61503. /**
  61504. * Implementation of the TGA Texture Loader.
  61505. * @hidden
  61506. */
  61507. export class _TGATextureLoader implements IInternalTextureLoader {
  61508. /**
  61509. * Defines wether the loader supports cascade loading the different faces.
  61510. */
  61511. readonly supportCascades: boolean;
  61512. /**
  61513. * This returns if the loader support the current file information.
  61514. * @param extension defines the file extension of the file being loaded
  61515. * @returns true if the loader can load the specified file
  61516. */
  61517. canLoad(extension: string): boolean;
  61518. /**
  61519. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61520. * @param data contains the texture data
  61521. * @param texture defines the BabylonJS internal texture
  61522. * @param createPolynomials will be true if polynomials have been requested
  61523. * @param onLoad defines the callback to trigger once the texture is ready
  61524. * @param onError defines the callback to trigger in case of error
  61525. */
  61526. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61527. /**
  61528. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61529. * @param data contains the texture data
  61530. * @param texture defines the BabylonJS internal texture
  61531. * @param callback defines the method to call once ready to upload
  61532. */
  61533. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61534. }
  61535. }
  61536. declare module BABYLON {
  61537. /**
  61538. * Info about the .basis files
  61539. */
  61540. class BasisFileInfo {
  61541. /**
  61542. * If the file has alpha
  61543. */
  61544. hasAlpha: boolean;
  61545. /**
  61546. * Info about each image of the basis file
  61547. */
  61548. images: Array<{
  61549. levels: Array<{
  61550. width: number;
  61551. height: number;
  61552. transcodedPixels: ArrayBufferView;
  61553. }>;
  61554. }>;
  61555. }
  61556. /**
  61557. * Result of transcoding a basis file
  61558. */
  61559. class TranscodeResult {
  61560. /**
  61561. * Info about the .basis file
  61562. */
  61563. fileInfo: BasisFileInfo;
  61564. /**
  61565. * Format to use when loading the file
  61566. */
  61567. format: number;
  61568. }
  61569. /**
  61570. * Configuration options for the Basis transcoder
  61571. */
  61572. export class BasisTranscodeConfiguration {
  61573. /**
  61574. * Supported compression formats used to determine the supported output format of the transcoder
  61575. */
  61576. supportedCompressionFormats?: {
  61577. /**
  61578. * etc1 compression format
  61579. */
  61580. etc1?: boolean;
  61581. /**
  61582. * s3tc compression format
  61583. */
  61584. s3tc?: boolean;
  61585. /**
  61586. * pvrtc compression format
  61587. */
  61588. pvrtc?: boolean;
  61589. /**
  61590. * etc2 compression format
  61591. */
  61592. etc2?: boolean;
  61593. };
  61594. /**
  61595. * If mipmap levels should be loaded for transcoded images (Default: true)
  61596. */
  61597. loadMipmapLevels?: boolean;
  61598. /**
  61599. * Index of a single image to load (Default: all images)
  61600. */
  61601. loadSingleImage?: number;
  61602. }
  61603. /**
  61604. * Used to load .Basis files
  61605. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61606. */
  61607. export class BasisTools {
  61608. private static _IgnoreSupportedFormats;
  61609. /**
  61610. * URL to use when loading the basis transcoder
  61611. */
  61612. static JSModuleURL: string;
  61613. /**
  61614. * URL to use when loading the wasm module for the transcoder
  61615. */
  61616. static WasmModuleURL: string;
  61617. /**
  61618. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61619. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61620. * @returns internal format corresponding to the Basis format
  61621. */
  61622. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61623. private static _WorkerPromise;
  61624. private static _Worker;
  61625. private static _actionId;
  61626. private static _CreateWorkerAsync;
  61627. /**
  61628. * Transcodes a loaded image file to compressed pixel data
  61629. * @param data image data to transcode
  61630. * @param config configuration options for the transcoding
  61631. * @returns a promise resulting in the transcoded image
  61632. */
  61633. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61634. /**
  61635. * Loads a texture from the transcode result
  61636. * @param texture texture load to
  61637. * @param transcodeResult the result of transcoding the basis file to load from
  61638. */
  61639. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61640. }
  61641. }
  61642. declare module BABYLON {
  61643. /**
  61644. * Loader for .basis file format
  61645. */
  61646. export class _BasisTextureLoader implements IInternalTextureLoader {
  61647. /**
  61648. * Defines whether the loader supports cascade loading the different faces.
  61649. */
  61650. readonly supportCascades: boolean;
  61651. /**
  61652. * This returns if the loader support the current file information.
  61653. * @param extension defines the file extension of the file being loaded
  61654. * @returns true if the loader can load the specified file
  61655. */
  61656. canLoad(extension: string): boolean;
  61657. /**
  61658. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61659. * @param data contains the texture data
  61660. * @param texture defines the BabylonJS internal texture
  61661. * @param createPolynomials will be true if polynomials have been requested
  61662. * @param onLoad defines the callback to trigger once the texture is ready
  61663. * @param onError defines the callback to trigger in case of error
  61664. */
  61665. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61666. /**
  61667. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61668. * @param data contains the texture data
  61669. * @param texture defines the BabylonJS internal texture
  61670. * @param callback defines the method to call once ready to upload
  61671. */
  61672. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61673. }
  61674. }
  61675. declare module BABYLON {
  61676. /**
  61677. * Defines the basic options interface of a TexturePacker Frame
  61678. */
  61679. export interface ITexturePackerFrame {
  61680. /**
  61681. * The frame ID
  61682. */
  61683. id: number;
  61684. /**
  61685. * The frames Scale
  61686. */
  61687. scale: Vector2;
  61688. /**
  61689. * The Frames offset
  61690. */
  61691. offset: Vector2;
  61692. }
  61693. /**
  61694. * This is a support class for frame Data on texture packer sets.
  61695. */
  61696. export class TexturePackerFrame implements ITexturePackerFrame {
  61697. /**
  61698. * The frame ID
  61699. */
  61700. id: number;
  61701. /**
  61702. * The frames Scale
  61703. */
  61704. scale: Vector2;
  61705. /**
  61706. * The Frames offset
  61707. */
  61708. offset: Vector2;
  61709. /**
  61710. * Initializes a texture package frame.
  61711. * @param id The numerical frame identifier
  61712. * @param scale Scalar Vector2 for UV frame
  61713. * @param offset Vector2 for the frame position in UV units.
  61714. * @returns TexturePackerFrame
  61715. */
  61716. constructor(id: number, scale: Vector2, offset: Vector2);
  61717. }
  61718. }
  61719. declare module BABYLON {
  61720. /**
  61721. * Defines the basic options interface of a TexturePacker
  61722. */
  61723. export interface ITexturePackerOptions {
  61724. /**
  61725. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61726. */
  61727. map?: string[];
  61728. /**
  61729. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61730. */
  61731. uvsIn?: string;
  61732. /**
  61733. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61734. */
  61735. uvsOut?: string;
  61736. /**
  61737. * number representing the layout style. Defaults to LAYOUT_STRIP
  61738. */
  61739. layout?: number;
  61740. /**
  61741. * number of columns if using custom column count layout(2). This defaults to 4.
  61742. */
  61743. colnum?: number;
  61744. /**
  61745. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61746. */
  61747. updateInputMeshes?: boolean;
  61748. /**
  61749. * boolean flag to dispose all the source textures. Defaults to true.
  61750. */
  61751. disposeSources?: boolean;
  61752. /**
  61753. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61754. */
  61755. fillBlanks?: boolean;
  61756. /**
  61757. * string value representing the context fill style color. Defaults to 'black'.
  61758. */
  61759. customFillColor?: string;
  61760. /**
  61761. * Width and Height Value of each Frame in the TexturePacker Sets
  61762. */
  61763. frameSize?: number;
  61764. /**
  61765. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61766. */
  61767. paddingRatio?: number;
  61768. /**
  61769. * Number that declares the fill method for the padding gutter.
  61770. */
  61771. paddingMode?: number;
  61772. /**
  61773. * If in SUBUV_COLOR padding mode what color to use.
  61774. */
  61775. paddingColor?: Color3 | Color4;
  61776. }
  61777. /**
  61778. * Defines the basic interface of a TexturePacker JSON File
  61779. */
  61780. export interface ITexturePackerJSON {
  61781. /**
  61782. * The frame ID
  61783. */
  61784. name: string;
  61785. /**
  61786. * The base64 channel data
  61787. */
  61788. sets: any;
  61789. /**
  61790. * The options of the Packer
  61791. */
  61792. options: ITexturePackerOptions;
  61793. /**
  61794. * The frame data of the Packer
  61795. */
  61796. frames: Array<number>;
  61797. }
  61798. /**
  61799. * This is a support class that generates a series of packed texture sets.
  61800. * @see https://doc.babylonjs.com/babylon101/materials
  61801. */
  61802. export class TexturePacker {
  61803. /** Packer Layout Constant 0 */
  61804. static readonly LAYOUT_STRIP: number;
  61805. /** Packer Layout Constant 1 */
  61806. static readonly LAYOUT_POWER2: number;
  61807. /** Packer Layout Constant 2 */
  61808. static readonly LAYOUT_COLNUM: number;
  61809. /** Packer Layout Constant 0 */
  61810. static readonly SUBUV_WRAP: number;
  61811. /** Packer Layout Constant 1 */
  61812. static readonly SUBUV_EXTEND: number;
  61813. /** Packer Layout Constant 2 */
  61814. static readonly SUBUV_COLOR: number;
  61815. /** The Name of the Texture Package */
  61816. name: string;
  61817. /** The scene scope of the TexturePacker */
  61818. scene: Scene;
  61819. /** The Meshes to target */
  61820. meshes: AbstractMesh[];
  61821. /** Arguments passed with the Constructor */
  61822. options: ITexturePackerOptions;
  61823. /** The promise that is started upon initialization */
  61824. promise: Nullable<Promise<TexturePacker | string>>;
  61825. /** The Container object for the channel sets that are generated */
  61826. sets: object;
  61827. /** The Container array for the frames that are generated */
  61828. frames: TexturePackerFrame[];
  61829. /** The expected number of textures the system is parsing. */
  61830. private _expecting;
  61831. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61832. private _paddingValue;
  61833. /**
  61834. * Initializes a texture package series from an array of meshes or a single mesh.
  61835. * @param name The name of the package
  61836. * @param meshes The target meshes to compose the package from
  61837. * @param options The arguments that texture packer should follow while building.
  61838. * @param scene The scene which the textures are scoped to.
  61839. * @returns TexturePacker
  61840. */
  61841. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61842. /**
  61843. * Starts the package process
  61844. * @param resolve The promises resolution function
  61845. * @returns TexturePacker
  61846. */
  61847. private _createFrames;
  61848. /**
  61849. * Calculates the Size of the Channel Sets
  61850. * @returns Vector2
  61851. */
  61852. private _calculateSize;
  61853. /**
  61854. * Calculates the UV data for the frames.
  61855. * @param baseSize the base frameSize
  61856. * @param padding the base frame padding
  61857. * @param dtSize size of the Dynamic Texture for that channel
  61858. * @param dtUnits is 1/dtSize
  61859. * @param update flag to update the input meshes
  61860. */
  61861. private _calculateMeshUVFrames;
  61862. /**
  61863. * Calculates the frames Offset.
  61864. * @param index of the frame
  61865. * @returns Vector2
  61866. */
  61867. private _getFrameOffset;
  61868. /**
  61869. * Updates a Mesh to the frame data
  61870. * @param mesh that is the target
  61871. * @param frameID or the frame index
  61872. */
  61873. private _updateMeshUV;
  61874. /**
  61875. * Updates a Meshes materials to use the texture packer channels
  61876. * @param m is the mesh to target
  61877. * @param force all channels on the packer to be set.
  61878. */
  61879. private _updateTextureReferences;
  61880. /**
  61881. * Public method to set a Mesh to a frame
  61882. * @param m that is the target
  61883. * @param frameID or the frame index
  61884. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61885. */
  61886. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61887. /**
  61888. * Starts the async promise to compile the texture packer.
  61889. * @returns Promise<void>
  61890. */
  61891. processAsync(): Promise<void>;
  61892. /**
  61893. * Disposes all textures associated with this packer
  61894. */
  61895. dispose(): void;
  61896. /**
  61897. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61898. * @param imageType is the image type to use.
  61899. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61900. */
  61901. download(imageType?: string, quality?: number): void;
  61902. /**
  61903. * Public method to load a texturePacker JSON file.
  61904. * @param data of the JSON file in string format.
  61905. */
  61906. updateFromJSON(data: string): void;
  61907. }
  61908. }
  61909. declare module BABYLON {
  61910. /**
  61911. * 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.
  61912. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61913. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61914. */
  61915. export class CustomProceduralTexture extends ProceduralTexture {
  61916. private _animate;
  61917. private _time;
  61918. private _config;
  61919. private _texturePath;
  61920. /**
  61921. * Instantiates a new Custom Procedural Texture.
  61922. * 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.
  61923. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61924. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61925. * @param name Define the name of the texture
  61926. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61927. * @param size Define the size of the texture to create
  61928. * @param scene Define the scene the texture belongs to
  61929. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61930. * @param generateMipMaps Define if the texture should creates mip maps or not
  61931. */
  61932. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61933. private _loadJson;
  61934. /**
  61935. * Is the texture ready to be used ? (rendered at least once)
  61936. * @returns true if ready, otherwise, false.
  61937. */
  61938. isReady(): boolean;
  61939. /**
  61940. * Render the texture to its associated render target.
  61941. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61942. */
  61943. render(useCameraPostProcess?: boolean): void;
  61944. /**
  61945. * Update the list of dependant textures samplers in the shader.
  61946. */
  61947. updateTextures(): void;
  61948. /**
  61949. * Update the uniform values of the procedural texture in the shader.
  61950. */
  61951. updateShaderUniforms(): void;
  61952. /**
  61953. * Define if the texture animates or not.
  61954. */
  61955. get animate(): boolean;
  61956. set animate(value: boolean);
  61957. }
  61958. }
  61959. declare module BABYLON {
  61960. /** @hidden */
  61961. export var noisePixelShader: {
  61962. name: string;
  61963. shader: string;
  61964. };
  61965. }
  61966. declare module BABYLON {
  61967. /**
  61968. * Class used to generate noise procedural textures
  61969. */
  61970. export class NoiseProceduralTexture extends ProceduralTexture {
  61971. private _time;
  61972. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61973. brightness: number;
  61974. /** Defines the number of octaves to process */
  61975. octaves: number;
  61976. /** Defines the level of persistence (0.8 by default) */
  61977. persistence: number;
  61978. /** Gets or sets animation speed factor (default is 1) */
  61979. animationSpeedFactor: number;
  61980. /**
  61981. * Creates a new NoiseProceduralTexture
  61982. * @param name defines the name fo the texture
  61983. * @param size defines the size of the texture (default is 256)
  61984. * @param scene defines the hosting scene
  61985. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61986. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61987. */
  61988. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61989. private _updateShaderUniforms;
  61990. protected _getDefines(): string;
  61991. /** Generate the current state of the procedural texture */
  61992. render(useCameraPostProcess?: boolean): void;
  61993. /**
  61994. * Serializes this noise procedural texture
  61995. * @returns a serialized noise procedural texture object
  61996. */
  61997. serialize(): any;
  61998. /**
  61999. * Clone the texture.
  62000. * @returns the cloned texture
  62001. */
  62002. clone(): NoiseProceduralTexture;
  62003. /**
  62004. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62005. * @param parsedTexture defines parsed texture data
  62006. * @param scene defines the current scene
  62007. * @param rootUrl defines the root URL containing noise procedural texture information
  62008. * @returns a parsed NoiseProceduralTexture
  62009. */
  62010. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62011. }
  62012. }
  62013. declare module BABYLON {
  62014. /**
  62015. * Raw cube texture where the raw buffers are passed in
  62016. */
  62017. export class RawCubeTexture extends CubeTexture {
  62018. /**
  62019. * Creates a cube texture where the raw buffers are passed in.
  62020. * @param scene defines the scene the texture is attached to
  62021. * @param data defines the array of data to use to create each face
  62022. * @param size defines the size of the textures
  62023. * @param format defines the format of the data
  62024. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62025. * @param generateMipMaps defines if the engine should generate the mip levels
  62026. * @param invertY defines if data must be stored with Y axis inverted
  62027. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62028. * @param compression defines the compression used (null by default)
  62029. */
  62030. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62031. /**
  62032. * Updates the raw cube texture.
  62033. * @param data defines the data to store
  62034. * @param format defines the data format
  62035. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62036. * @param invertY defines if data must be stored with Y axis inverted
  62037. * @param compression defines the compression used (null by default)
  62038. * @param level defines which level of the texture to update
  62039. */
  62040. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62041. /**
  62042. * Updates a raw cube texture with RGBD encoded data.
  62043. * @param data defines the array of data [mipmap][face] to use to create each face
  62044. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62045. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62046. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62047. * @returns a promsie that resolves when the operation is complete
  62048. */
  62049. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62050. /**
  62051. * Clones the raw cube texture.
  62052. * @return a new cube texture
  62053. */
  62054. clone(): CubeTexture;
  62055. /** @hidden */
  62056. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62057. }
  62058. }
  62059. declare module BABYLON {
  62060. /**
  62061. * Class used to store 2D array textures containing user data
  62062. */
  62063. export class RawTexture2DArray extends Texture {
  62064. /** Gets or sets the texture format to use */
  62065. format: number;
  62066. /**
  62067. * Create a new RawTexture2DArray
  62068. * @param data defines the data of the texture
  62069. * @param width defines the width of the texture
  62070. * @param height defines the height of the texture
  62071. * @param depth defines the number of layers of the texture
  62072. * @param format defines the texture format to use
  62073. * @param scene defines the hosting scene
  62074. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62075. * @param invertY defines if texture must be stored with Y axis inverted
  62076. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62077. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62078. */
  62079. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62080. /** Gets or sets the texture format to use */
  62081. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62082. /**
  62083. * Update the texture with new data
  62084. * @param data defines the data to store in the texture
  62085. */
  62086. update(data: ArrayBufferView): void;
  62087. }
  62088. }
  62089. declare module BABYLON {
  62090. /**
  62091. * Class used to store 3D textures containing user data
  62092. */
  62093. export class RawTexture3D extends Texture {
  62094. /** Gets or sets the texture format to use */
  62095. format: number;
  62096. /**
  62097. * Create a new RawTexture3D
  62098. * @param data defines the data of the texture
  62099. * @param width defines the width of the texture
  62100. * @param height defines the height of the texture
  62101. * @param depth defines the depth of the texture
  62102. * @param format defines the texture format to use
  62103. * @param scene defines the hosting scene
  62104. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62105. * @param invertY defines if texture must be stored with Y axis inverted
  62106. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62107. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62108. */
  62109. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62110. /** Gets or sets the texture format to use */
  62111. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62112. /**
  62113. * Update the texture with new data
  62114. * @param data defines the data to store in the texture
  62115. */
  62116. update(data: ArrayBufferView): void;
  62117. }
  62118. }
  62119. declare module BABYLON {
  62120. /**
  62121. * Creates a refraction texture used by refraction channel of the standard material.
  62122. * It is like a mirror but to see through a material.
  62123. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62124. */
  62125. export class RefractionTexture extends RenderTargetTexture {
  62126. /**
  62127. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62128. * 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.
  62129. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62130. */
  62131. refractionPlane: Plane;
  62132. /**
  62133. * Define how deep under the surface we should see.
  62134. */
  62135. depth: number;
  62136. /**
  62137. * Creates a refraction texture used by refraction channel of the standard material.
  62138. * It is like a mirror but to see through a material.
  62139. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62140. * @param name Define the texture name
  62141. * @param size Define the size of the underlying texture
  62142. * @param scene Define the scene the refraction belongs to
  62143. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62144. */
  62145. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62146. /**
  62147. * Clone the refraction texture.
  62148. * @returns the cloned texture
  62149. */
  62150. clone(): RefractionTexture;
  62151. /**
  62152. * Serialize the texture to a JSON representation you could use in Parse later on
  62153. * @returns the serialized JSON representation
  62154. */
  62155. serialize(): any;
  62156. }
  62157. }
  62158. declare module BABYLON {
  62159. /**
  62160. * Block used to add support for vertex skinning (bones)
  62161. */
  62162. export class BonesBlock extends NodeMaterialBlock {
  62163. /**
  62164. * Creates a new BonesBlock
  62165. * @param name defines the block name
  62166. */
  62167. constructor(name: string);
  62168. /**
  62169. * Initialize the block and prepare the context for build
  62170. * @param state defines the state that will be used for the build
  62171. */
  62172. initialize(state: NodeMaterialBuildState): void;
  62173. /**
  62174. * Gets the current class name
  62175. * @returns the class name
  62176. */
  62177. getClassName(): string;
  62178. /**
  62179. * Gets the matrix indices input component
  62180. */
  62181. get matricesIndices(): NodeMaterialConnectionPoint;
  62182. /**
  62183. * Gets the matrix weights input component
  62184. */
  62185. get matricesWeights(): NodeMaterialConnectionPoint;
  62186. /**
  62187. * Gets the extra matrix indices input component
  62188. */
  62189. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62190. /**
  62191. * Gets the extra matrix weights input component
  62192. */
  62193. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62194. /**
  62195. * Gets the world input component
  62196. */
  62197. get world(): NodeMaterialConnectionPoint;
  62198. /**
  62199. * Gets the output component
  62200. */
  62201. get output(): NodeMaterialConnectionPoint;
  62202. autoConfigure(material: NodeMaterial): void;
  62203. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62204. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62205. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62206. protected _buildBlock(state: NodeMaterialBuildState): this;
  62207. }
  62208. }
  62209. declare module BABYLON {
  62210. /**
  62211. * Block used to add support for instances
  62212. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62213. */
  62214. export class InstancesBlock extends NodeMaterialBlock {
  62215. /**
  62216. * Creates a new InstancesBlock
  62217. * @param name defines the block name
  62218. */
  62219. constructor(name: string);
  62220. /**
  62221. * Gets the current class name
  62222. * @returns the class name
  62223. */
  62224. getClassName(): string;
  62225. /**
  62226. * Gets the first world row input component
  62227. */
  62228. get world0(): NodeMaterialConnectionPoint;
  62229. /**
  62230. * Gets the second world row input component
  62231. */
  62232. get world1(): NodeMaterialConnectionPoint;
  62233. /**
  62234. * Gets the third world row input component
  62235. */
  62236. get world2(): NodeMaterialConnectionPoint;
  62237. /**
  62238. * Gets the forth world row input component
  62239. */
  62240. get world3(): NodeMaterialConnectionPoint;
  62241. /**
  62242. * Gets the world input component
  62243. */
  62244. get world(): NodeMaterialConnectionPoint;
  62245. /**
  62246. * Gets the output component
  62247. */
  62248. get output(): NodeMaterialConnectionPoint;
  62249. /**
  62250. * Gets the isntanceID component
  62251. */
  62252. get instanceID(): NodeMaterialConnectionPoint;
  62253. autoConfigure(material: NodeMaterial): void;
  62254. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62255. protected _buildBlock(state: NodeMaterialBuildState): this;
  62256. }
  62257. }
  62258. declare module BABYLON {
  62259. /**
  62260. * Block used to add morph targets support to vertex shader
  62261. */
  62262. export class MorphTargetsBlock extends NodeMaterialBlock {
  62263. private _repeatableContentAnchor;
  62264. /**
  62265. * Create a new MorphTargetsBlock
  62266. * @param name defines the block name
  62267. */
  62268. constructor(name: string);
  62269. /**
  62270. * Gets the current class name
  62271. * @returns the class name
  62272. */
  62273. getClassName(): string;
  62274. /**
  62275. * Gets the position input component
  62276. */
  62277. get position(): NodeMaterialConnectionPoint;
  62278. /**
  62279. * Gets the normal input component
  62280. */
  62281. get normal(): NodeMaterialConnectionPoint;
  62282. /**
  62283. * Gets the tangent input component
  62284. */
  62285. get tangent(): NodeMaterialConnectionPoint;
  62286. /**
  62287. * Gets the tangent input component
  62288. */
  62289. get uv(): NodeMaterialConnectionPoint;
  62290. /**
  62291. * Gets the position output component
  62292. */
  62293. get positionOutput(): NodeMaterialConnectionPoint;
  62294. /**
  62295. * Gets the normal output component
  62296. */
  62297. get normalOutput(): NodeMaterialConnectionPoint;
  62298. /**
  62299. * Gets the tangent output component
  62300. */
  62301. get tangentOutput(): NodeMaterialConnectionPoint;
  62302. /**
  62303. * Gets the tangent output component
  62304. */
  62305. get uvOutput(): NodeMaterialConnectionPoint;
  62306. initialize(state: NodeMaterialBuildState): void;
  62307. autoConfigure(material: NodeMaterial): void;
  62308. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62309. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62310. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62311. protected _buildBlock(state: NodeMaterialBuildState): this;
  62312. }
  62313. }
  62314. declare module BABYLON {
  62315. /**
  62316. * Block used to get data information from a light
  62317. */
  62318. export class LightInformationBlock extends NodeMaterialBlock {
  62319. private _lightDataUniformName;
  62320. private _lightColorUniformName;
  62321. private _lightTypeDefineName;
  62322. /**
  62323. * Gets or sets the light associated with this block
  62324. */
  62325. light: Nullable<Light>;
  62326. /**
  62327. * Creates a new LightInformationBlock
  62328. * @param name defines the block name
  62329. */
  62330. constructor(name: string);
  62331. /**
  62332. * Gets the current class name
  62333. * @returns the class name
  62334. */
  62335. getClassName(): string;
  62336. /**
  62337. * Gets the world position input component
  62338. */
  62339. get worldPosition(): NodeMaterialConnectionPoint;
  62340. /**
  62341. * Gets the direction output component
  62342. */
  62343. get direction(): NodeMaterialConnectionPoint;
  62344. /**
  62345. * Gets the direction output component
  62346. */
  62347. get color(): NodeMaterialConnectionPoint;
  62348. /**
  62349. * Gets the direction output component
  62350. */
  62351. get intensity(): NodeMaterialConnectionPoint;
  62352. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62353. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62354. protected _buildBlock(state: NodeMaterialBuildState): this;
  62355. serialize(): any;
  62356. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62357. }
  62358. }
  62359. declare module BABYLON {
  62360. /**
  62361. * Block used to add image processing support to fragment shader
  62362. */
  62363. export class ImageProcessingBlock extends NodeMaterialBlock {
  62364. /**
  62365. * Create a new ImageProcessingBlock
  62366. * @param name defines the block name
  62367. */
  62368. constructor(name: string);
  62369. /**
  62370. * Gets the current class name
  62371. * @returns the class name
  62372. */
  62373. getClassName(): string;
  62374. /**
  62375. * Gets the color input component
  62376. */
  62377. get color(): NodeMaterialConnectionPoint;
  62378. /**
  62379. * Gets the output component
  62380. */
  62381. get output(): NodeMaterialConnectionPoint;
  62382. /**
  62383. * Initialize the block and prepare the context for build
  62384. * @param state defines the state that will be used for the build
  62385. */
  62386. initialize(state: NodeMaterialBuildState): void;
  62387. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62389. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62390. protected _buildBlock(state: NodeMaterialBuildState): this;
  62391. }
  62392. }
  62393. declare module BABYLON {
  62394. /**
  62395. * Block used to pertub normals based on a normal map
  62396. */
  62397. export class PerturbNormalBlock extends NodeMaterialBlock {
  62398. private _tangentSpaceParameterName;
  62399. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62400. invertX: boolean;
  62401. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62402. invertY: boolean;
  62403. /**
  62404. * Create a new PerturbNormalBlock
  62405. * @param name defines the block name
  62406. */
  62407. constructor(name: string);
  62408. /**
  62409. * Gets the current class name
  62410. * @returns the class name
  62411. */
  62412. getClassName(): string;
  62413. /**
  62414. * Gets the world position input component
  62415. */
  62416. get worldPosition(): NodeMaterialConnectionPoint;
  62417. /**
  62418. * Gets the world normal input component
  62419. */
  62420. get worldNormal(): NodeMaterialConnectionPoint;
  62421. /**
  62422. * Gets the world tangent input component
  62423. */
  62424. get worldTangent(): NodeMaterialConnectionPoint;
  62425. /**
  62426. * Gets the uv input component
  62427. */
  62428. get uv(): NodeMaterialConnectionPoint;
  62429. /**
  62430. * Gets the normal map color input component
  62431. */
  62432. get normalMapColor(): NodeMaterialConnectionPoint;
  62433. /**
  62434. * Gets the strength input component
  62435. */
  62436. get strength(): NodeMaterialConnectionPoint;
  62437. /**
  62438. * Gets the output component
  62439. */
  62440. get output(): NodeMaterialConnectionPoint;
  62441. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62442. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62443. autoConfigure(material: NodeMaterial): void;
  62444. protected _buildBlock(state: NodeMaterialBuildState): this;
  62445. protected _dumpPropertiesCode(): string;
  62446. serialize(): any;
  62447. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62448. }
  62449. }
  62450. declare module BABYLON {
  62451. /**
  62452. * Block used to discard a pixel if a value is smaller than a cutoff
  62453. */
  62454. export class DiscardBlock extends NodeMaterialBlock {
  62455. /**
  62456. * Create a new DiscardBlock
  62457. * @param name defines the block name
  62458. */
  62459. constructor(name: string);
  62460. /**
  62461. * Gets the current class name
  62462. * @returns the class name
  62463. */
  62464. getClassName(): string;
  62465. /**
  62466. * Gets the color input component
  62467. */
  62468. get value(): NodeMaterialConnectionPoint;
  62469. /**
  62470. * Gets the cutoff input component
  62471. */
  62472. get cutoff(): NodeMaterialConnectionPoint;
  62473. protected _buildBlock(state: NodeMaterialBuildState): this;
  62474. }
  62475. }
  62476. declare module BABYLON {
  62477. /**
  62478. * Block used to test if the fragment shader is front facing
  62479. */
  62480. export class FrontFacingBlock extends NodeMaterialBlock {
  62481. /**
  62482. * Creates a new FrontFacingBlock
  62483. * @param name defines the block name
  62484. */
  62485. constructor(name: string);
  62486. /**
  62487. * Gets the current class name
  62488. * @returns the class name
  62489. */
  62490. getClassName(): string;
  62491. /**
  62492. * Gets the output component
  62493. */
  62494. get output(): NodeMaterialConnectionPoint;
  62495. protected _buildBlock(state: NodeMaterialBuildState): this;
  62496. }
  62497. }
  62498. declare module BABYLON {
  62499. /**
  62500. * Block used to get the derivative value on x and y of a given input
  62501. */
  62502. export class DerivativeBlock extends NodeMaterialBlock {
  62503. /**
  62504. * Create a new DerivativeBlock
  62505. * @param name defines the block name
  62506. */
  62507. constructor(name: string);
  62508. /**
  62509. * Gets the current class name
  62510. * @returns the class name
  62511. */
  62512. getClassName(): string;
  62513. /**
  62514. * Gets the input component
  62515. */
  62516. get input(): NodeMaterialConnectionPoint;
  62517. /**
  62518. * Gets the derivative output on x
  62519. */
  62520. get dx(): NodeMaterialConnectionPoint;
  62521. /**
  62522. * Gets the derivative output on y
  62523. */
  62524. get dy(): NodeMaterialConnectionPoint;
  62525. protected _buildBlock(state: NodeMaterialBuildState): this;
  62526. }
  62527. }
  62528. declare module BABYLON {
  62529. /**
  62530. * Block used to make gl_FragCoord available
  62531. */
  62532. export class FragCoordBlock extends NodeMaterialBlock {
  62533. /**
  62534. * Creates a new FragCoordBlock
  62535. * @param name defines the block name
  62536. */
  62537. constructor(name: string);
  62538. /**
  62539. * Gets the current class name
  62540. * @returns the class name
  62541. */
  62542. getClassName(): string;
  62543. /**
  62544. * Gets the xy component
  62545. */
  62546. get xy(): NodeMaterialConnectionPoint;
  62547. /**
  62548. * Gets the xyz component
  62549. */
  62550. get xyz(): NodeMaterialConnectionPoint;
  62551. /**
  62552. * Gets the xyzw component
  62553. */
  62554. get xyzw(): NodeMaterialConnectionPoint;
  62555. /**
  62556. * Gets the x component
  62557. */
  62558. get x(): NodeMaterialConnectionPoint;
  62559. /**
  62560. * Gets the y component
  62561. */
  62562. get y(): NodeMaterialConnectionPoint;
  62563. /**
  62564. * Gets the z component
  62565. */
  62566. get z(): NodeMaterialConnectionPoint;
  62567. /**
  62568. * Gets the w component
  62569. */
  62570. get output(): NodeMaterialConnectionPoint;
  62571. protected writeOutputs(state: NodeMaterialBuildState): string;
  62572. protected _buildBlock(state: NodeMaterialBuildState): this;
  62573. }
  62574. }
  62575. declare module BABYLON {
  62576. /**
  62577. * Block used to get the screen sizes
  62578. */
  62579. export class ScreenSizeBlock extends NodeMaterialBlock {
  62580. private _varName;
  62581. private _scene;
  62582. /**
  62583. * Creates a new ScreenSizeBlock
  62584. * @param name defines the block name
  62585. */
  62586. constructor(name: string);
  62587. /**
  62588. * Gets the current class name
  62589. * @returns the class name
  62590. */
  62591. getClassName(): string;
  62592. /**
  62593. * Gets the xy component
  62594. */
  62595. get xy(): NodeMaterialConnectionPoint;
  62596. /**
  62597. * Gets the x component
  62598. */
  62599. get x(): NodeMaterialConnectionPoint;
  62600. /**
  62601. * Gets the y component
  62602. */
  62603. get y(): NodeMaterialConnectionPoint;
  62604. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62605. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62606. protected _buildBlock(state: NodeMaterialBuildState): this;
  62607. }
  62608. }
  62609. declare module BABYLON {
  62610. /**
  62611. * Block used to add support for scene fog
  62612. */
  62613. export class FogBlock extends NodeMaterialBlock {
  62614. private _fogDistanceName;
  62615. private _fogParameters;
  62616. /**
  62617. * Create a new FogBlock
  62618. * @param name defines the block name
  62619. */
  62620. constructor(name: string);
  62621. /**
  62622. * Gets the current class name
  62623. * @returns the class name
  62624. */
  62625. getClassName(): string;
  62626. /**
  62627. * Gets the world position input component
  62628. */
  62629. get worldPosition(): NodeMaterialConnectionPoint;
  62630. /**
  62631. * Gets the view input component
  62632. */
  62633. get view(): NodeMaterialConnectionPoint;
  62634. /**
  62635. * Gets the color input component
  62636. */
  62637. get input(): NodeMaterialConnectionPoint;
  62638. /**
  62639. * Gets the fog color input component
  62640. */
  62641. get fogColor(): NodeMaterialConnectionPoint;
  62642. /**
  62643. * Gets the output component
  62644. */
  62645. get output(): NodeMaterialConnectionPoint;
  62646. autoConfigure(material: NodeMaterial): void;
  62647. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62648. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62649. protected _buildBlock(state: NodeMaterialBuildState): this;
  62650. }
  62651. }
  62652. declare module BABYLON {
  62653. /**
  62654. * Block used to add light in the fragment shader
  62655. */
  62656. export class LightBlock extends NodeMaterialBlock {
  62657. private _lightId;
  62658. /**
  62659. * Gets or sets the light associated with this block
  62660. */
  62661. light: Nullable<Light>;
  62662. /**
  62663. * Create a new LightBlock
  62664. * @param name defines the block name
  62665. */
  62666. constructor(name: string);
  62667. /**
  62668. * Gets the current class name
  62669. * @returns the class name
  62670. */
  62671. getClassName(): string;
  62672. /**
  62673. * Gets the world position input component
  62674. */
  62675. get worldPosition(): NodeMaterialConnectionPoint;
  62676. /**
  62677. * Gets the world normal input component
  62678. */
  62679. get worldNormal(): NodeMaterialConnectionPoint;
  62680. /**
  62681. * Gets the camera (or eye) position component
  62682. */
  62683. get cameraPosition(): NodeMaterialConnectionPoint;
  62684. /**
  62685. * Gets the glossiness component
  62686. */
  62687. get glossiness(): NodeMaterialConnectionPoint;
  62688. /**
  62689. * Gets the glossinness power component
  62690. */
  62691. get glossPower(): NodeMaterialConnectionPoint;
  62692. /**
  62693. * Gets the diffuse color component
  62694. */
  62695. get diffuseColor(): NodeMaterialConnectionPoint;
  62696. /**
  62697. * Gets the specular color component
  62698. */
  62699. get specularColor(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Gets the diffuse output component
  62702. */
  62703. get diffuseOutput(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Gets the specular output component
  62706. */
  62707. get specularOutput(): NodeMaterialConnectionPoint;
  62708. /**
  62709. * Gets the shadow output component
  62710. */
  62711. get shadow(): NodeMaterialConnectionPoint;
  62712. autoConfigure(material: NodeMaterial): void;
  62713. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62714. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62715. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62716. private _injectVertexCode;
  62717. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62718. serialize(): any;
  62719. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62720. }
  62721. }
  62722. declare module BABYLON {
  62723. /**
  62724. * Block used to read a reflection texture from a sampler
  62725. */
  62726. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62727. /**
  62728. * Create a new ReflectionTextureBlock
  62729. * @param name defines the block name
  62730. */
  62731. constructor(name: string);
  62732. /**
  62733. * Gets the current class name
  62734. * @returns the class name
  62735. */
  62736. getClassName(): string;
  62737. /**
  62738. * Gets the world position input component
  62739. */
  62740. get position(): NodeMaterialConnectionPoint;
  62741. /**
  62742. * Gets the world position input component
  62743. */
  62744. get worldPosition(): NodeMaterialConnectionPoint;
  62745. /**
  62746. * Gets the world normal input component
  62747. */
  62748. get worldNormal(): NodeMaterialConnectionPoint;
  62749. /**
  62750. * Gets the world input component
  62751. */
  62752. get world(): NodeMaterialConnectionPoint;
  62753. /**
  62754. * Gets the camera (or eye) position component
  62755. */
  62756. get cameraPosition(): NodeMaterialConnectionPoint;
  62757. /**
  62758. * Gets the view input component
  62759. */
  62760. get view(): NodeMaterialConnectionPoint;
  62761. /**
  62762. * Gets the rgb output component
  62763. */
  62764. get rgb(): NodeMaterialConnectionPoint;
  62765. /**
  62766. * Gets the rgba output component
  62767. */
  62768. get rgba(): NodeMaterialConnectionPoint;
  62769. /**
  62770. * Gets the r output component
  62771. */
  62772. get r(): NodeMaterialConnectionPoint;
  62773. /**
  62774. * Gets the g output component
  62775. */
  62776. get g(): NodeMaterialConnectionPoint;
  62777. /**
  62778. * Gets the b output component
  62779. */
  62780. get b(): NodeMaterialConnectionPoint;
  62781. /**
  62782. * Gets the a output component
  62783. */
  62784. get a(): NodeMaterialConnectionPoint;
  62785. autoConfigure(material: NodeMaterial): void;
  62786. protected _buildBlock(state: NodeMaterialBuildState): this;
  62787. }
  62788. }
  62789. declare module BABYLON {
  62790. /**
  62791. * Block used to add 2 vectors
  62792. */
  62793. export class AddBlock extends NodeMaterialBlock {
  62794. /**
  62795. * Creates a new AddBlock
  62796. * @param name defines the block name
  62797. */
  62798. constructor(name: string);
  62799. /**
  62800. * Gets the current class name
  62801. * @returns the class name
  62802. */
  62803. getClassName(): string;
  62804. /**
  62805. * Gets the left operand input component
  62806. */
  62807. get left(): NodeMaterialConnectionPoint;
  62808. /**
  62809. * Gets the right operand input component
  62810. */
  62811. get right(): NodeMaterialConnectionPoint;
  62812. /**
  62813. * Gets the output component
  62814. */
  62815. get output(): NodeMaterialConnectionPoint;
  62816. protected _buildBlock(state: NodeMaterialBuildState): this;
  62817. }
  62818. }
  62819. declare module BABYLON {
  62820. /**
  62821. * Block used to scale a vector by a float
  62822. */
  62823. export class ScaleBlock extends NodeMaterialBlock {
  62824. /**
  62825. * Creates a new ScaleBlock
  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 input component
  62836. */
  62837. get input(): NodeMaterialConnectionPoint;
  62838. /**
  62839. * Gets the factor input component
  62840. */
  62841. get factor(): NodeMaterialConnectionPoint;
  62842. /**
  62843. * Gets the output component
  62844. */
  62845. get output(): NodeMaterialConnectionPoint;
  62846. protected _buildBlock(state: NodeMaterialBuildState): this;
  62847. }
  62848. }
  62849. declare module BABYLON {
  62850. /**
  62851. * Block used to clamp a float
  62852. */
  62853. export class ClampBlock extends NodeMaterialBlock {
  62854. /** Gets or sets the minimum range */
  62855. minimum: number;
  62856. /** Gets or sets the maximum range */
  62857. maximum: number;
  62858. /**
  62859. * Creates a new ClampBlock
  62860. * @param name defines the block name
  62861. */
  62862. constructor(name: string);
  62863. /**
  62864. * Gets the current class name
  62865. * @returns the class name
  62866. */
  62867. getClassName(): string;
  62868. /**
  62869. * Gets the value input component
  62870. */
  62871. get value(): NodeMaterialConnectionPoint;
  62872. /**
  62873. * Gets the output component
  62874. */
  62875. get output(): NodeMaterialConnectionPoint;
  62876. protected _buildBlock(state: NodeMaterialBuildState): this;
  62877. protected _dumpPropertiesCode(): string;
  62878. serialize(): any;
  62879. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62880. }
  62881. }
  62882. declare module BABYLON {
  62883. /**
  62884. * Block used to apply a cross product between 2 vectors
  62885. */
  62886. export class CrossBlock extends NodeMaterialBlock {
  62887. /**
  62888. * Creates a new CrossBlock
  62889. * @param name defines the block name
  62890. */
  62891. constructor(name: string);
  62892. /**
  62893. * Gets the current class name
  62894. * @returns the class name
  62895. */
  62896. getClassName(): string;
  62897. /**
  62898. * Gets the left operand input component
  62899. */
  62900. get left(): NodeMaterialConnectionPoint;
  62901. /**
  62902. * Gets the right operand input component
  62903. */
  62904. get right(): NodeMaterialConnectionPoint;
  62905. /**
  62906. * Gets the output component
  62907. */
  62908. get output(): NodeMaterialConnectionPoint;
  62909. protected _buildBlock(state: NodeMaterialBuildState): this;
  62910. }
  62911. }
  62912. declare module BABYLON {
  62913. /**
  62914. * Block used to apply a dot product between 2 vectors
  62915. */
  62916. export class DotBlock extends NodeMaterialBlock {
  62917. /**
  62918. * Creates a new DotBlock
  62919. * @param name defines the block name
  62920. */
  62921. constructor(name: string);
  62922. /**
  62923. * Gets the current class name
  62924. * @returns the class name
  62925. */
  62926. getClassName(): string;
  62927. /**
  62928. * Gets the left operand input component
  62929. */
  62930. get left(): NodeMaterialConnectionPoint;
  62931. /**
  62932. * Gets the right operand input component
  62933. */
  62934. get right(): NodeMaterialConnectionPoint;
  62935. /**
  62936. * Gets the output component
  62937. */
  62938. get output(): NodeMaterialConnectionPoint;
  62939. protected _buildBlock(state: NodeMaterialBuildState): this;
  62940. }
  62941. }
  62942. declare module BABYLON {
  62943. /**
  62944. * Block used to normalize a vector
  62945. */
  62946. export class NormalizeBlock extends NodeMaterialBlock {
  62947. /**
  62948. * Creates a new NormalizeBlock
  62949. * @param name defines the block name
  62950. */
  62951. constructor(name: string);
  62952. /**
  62953. * Gets the current class name
  62954. * @returns the class name
  62955. */
  62956. getClassName(): string;
  62957. /**
  62958. * Gets the input component
  62959. */
  62960. get input(): NodeMaterialConnectionPoint;
  62961. /**
  62962. * Gets the output component
  62963. */
  62964. get output(): NodeMaterialConnectionPoint;
  62965. protected _buildBlock(state: NodeMaterialBuildState): this;
  62966. }
  62967. }
  62968. declare module BABYLON {
  62969. /**
  62970. * Operations supported by the Trigonometry block
  62971. */
  62972. export enum TrigonometryBlockOperations {
  62973. /** Cos */
  62974. Cos = 0,
  62975. /** Sin */
  62976. Sin = 1,
  62977. /** Abs */
  62978. Abs = 2,
  62979. /** Exp */
  62980. Exp = 3,
  62981. /** Exp2 */
  62982. Exp2 = 4,
  62983. /** Round */
  62984. Round = 5,
  62985. /** Floor */
  62986. Floor = 6,
  62987. /** Ceiling */
  62988. Ceiling = 7,
  62989. /** Square root */
  62990. Sqrt = 8,
  62991. /** Log */
  62992. Log = 9,
  62993. /** Tangent */
  62994. Tan = 10,
  62995. /** Arc tangent */
  62996. ArcTan = 11,
  62997. /** Arc cosinus */
  62998. ArcCos = 12,
  62999. /** Arc sinus */
  63000. ArcSin = 13,
  63001. /** Fraction */
  63002. Fract = 14,
  63003. /** Sign */
  63004. Sign = 15,
  63005. /** To radians (from degrees) */
  63006. Radians = 16,
  63007. /** To degrees (from radians) */
  63008. Degrees = 17
  63009. }
  63010. /**
  63011. * Block used to apply trigonometry operation to floats
  63012. */
  63013. export class TrigonometryBlock extends NodeMaterialBlock {
  63014. /**
  63015. * Gets or sets the operation applied by the block
  63016. */
  63017. operation: TrigonometryBlockOperations;
  63018. /**
  63019. * Creates a new TrigonometryBlock
  63020. * @param name defines the block name
  63021. */
  63022. constructor(name: string);
  63023. /**
  63024. * Gets the current class name
  63025. * @returns the class name
  63026. */
  63027. getClassName(): string;
  63028. /**
  63029. * Gets the input component
  63030. */
  63031. get input(): NodeMaterialConnectionPoint;
  63032. /**
  63033. * Gets the output component
  63034. */
  63035. get output(): NodeMaterialConnectionPoint;
  63036. protected _buildBlock(state: NodeMaterialBuildState): this;
  63037. serialize(): any;
  63038. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63039. protected _dumpPropertiesCode(): string;
  63040. }
  63041. }
  63042. declare module BABYLON {
  63043. /**
  63044. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63045. */
  63046. export class ColorMergerBlock extends NodeMaterialBlock {
  63047. /**
  63048. * Create a new ColorMergerBlock
  63049. * @param name defines the block name
  63050. */
  63051. constructor(name: string);
  63052. /**
  63053. * Gets the current class name
  63054. * @returns the class name
  63055. */
  63056. getClassName(): string;
  63057. /**
  63058. * Gets the rgb component (input)
  63059. */
  63060. get rgbIn(): NodeMaterialConnectionPoint;
  63061. /**
  63062. * Gets the r component (input)
  63063. */
  63064. get r(): NodeMaterialConnectionPoint;
  63065. /**
  63066. * Gets the g component (input)
  63067. */
  63068. get g(): NodeMaterialConnectionPoint;
  63069. /**
  63070. * Gets the b component (input)
  63071. */
  63072. get b(): NodeMaterialConnectionPoint;
  63073. /**
  63074. * Gets the a component (input)
  63075. */
  63076. get a(): NodeMaterialConnectionPoint;
  63077. /**
  63078. * Gets the rgba component (output)
  63079. */
  63080. get rgba(): NodeMaterialConnectionPoint;
  63081. /**
  63082. * Gets the rgb component (output)
  63083. */
  63084. get rgbOut(): NodeMaterialConnectionPoint;
  63085. /**
  63086. * Gets the rgb component (output)
  63087. * @deprecated Please use rgbOut instead.
  63088. */
  63089. get rgb(): NodeMaterialConnectionPoint;
  63090. protected _buildBlock(state: NodeMaterialBuildState): this;
  63091. }
  63092. }
  63093. declare module BABYLON {
  63094. /**
  63095. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63096. */
  63097. export class VectorSplitterBlock extends NodeMaterialBlock {
  63098. /**
  63099. * Create a new VectorSplitterBlock
  63100. * @param name defines the block name
  63101. */
  63102. constructor(name: string);
  63103. /**
  63104. * Gets the current class name
  63105. * @returns the class name
  63106. */
  63107. getClassName(): string;
  63108. /**
  63109. * Gets the xyzw component (input)
  63110. */
  63111. get xyzw(): NodeMaterialConnectionPoint;
  63112. /**
  63113. * Gets the xyz component (input)
  63114. */
  63115. get xyzIn(): NodeMaterialConnectionPoint;
  63116. /**
  63117. * Gets the xy component (input)
  63118. */
  63119. get xyIn(): NodeMaterialConnectionPoint;
  63120. /**
  63121. * Gets the xyz component (output)
  63122. */
  63123. get xyzOut(): NodeMaterialConnectionPoint;
  63124. /**
  63125. * Gets the xy component (output)
  63126. */
  63127. get xyOut(): NodeMaterialConnectionPoint;
  63128. /**
  63129. * Gets the x component (output)
  63130. */
  63131. get x(): NodeMaterialConnectionPoint;
  63132. /**
  63133. * Gets the y component (output)
  63134. */
  63135. get y(): NodeMaterialConnectionPoint;
  63136. /**
  63137. * Gets the z component (output)
  63138. */
  63139. get z(): NodeMaterialConnectionPoint;
  63140. /**
  63141. * Gets the w component (output)
  63142. */
  63143. get w(): NodeMaterialConnectionPoint;
  63144. protected _inputRename(name: string): string;
  63145. protected _outputRename(name: string): string;
  63146. protected _buildBlock(state: NodeMaterialBuildState): this;
  63147. }
  63148. }
  63149. declare module BABYLON {
  63150. /**
  63151. * Block used to lerp between 2 values
  63152. */
  63153. export class LerpBlock extends NodeMaterialBlock {
  63154. /**
  63155. * Creates a new LerpBlock
  63156. * @param name defines the block name
  63157. */
  63158. constructor(name: string);
  63159. /**
  63160. * Gets the current class name
  63161. * @returns the class name
  63162. */
  63163. getClassName(): string;
  63164. /**
  63165. * Gets the left operand input component
  63166. */
  63167. get left(): NodeMaterialConnectionPoint;
  63168. /**
  63169. * Gets the right operand input component
  63170. */
  63171. get right(): NodeMaterialConnectionPoint;
  63172. /**
  63173. * Gets the gradient operand input component
  63174. */
  63175. get gradient(): NodeMaterialConnectionPoint;
  63176. /**
  63177. * Gets the output component
  63178. */
  63179. get output(): NodeMaterialConnectionPoint;
  63180. protected _buildBlock(state: NodeMaterialBuildState): this;
  63181. }
  63182. }
  63183. declare module BABYLON {
  63184. /**
  63185. * Block used to divide 2 vectors
  63186. */
  63187. export class DivideBlock extends NodeMaterialBlock {
  63188. /**
  63189. * Creates a new DivideBlock
  63190. * @param name defines the block name
  63191. */
  63192. constructor(name: string);
  63193. /**
  63194. * Gets the current class name
  63195. * @returns the class name
  63196. */
  63197. getClassName(): string;
  63198. /**
  63199. * Gets the left operand input component
  63200. */
  63201. get left(): NodeMaterialConnectionPoint;
  63202. /**
  63203. * Gets the right operand input component
  63204. */
  63205. get right(): NodeMaterialConnectionPoint;
  63206. /**
  63207. * Gets the output component
  63208. */
  63209. get output(): NodeMaterialConnectionPoint;
  63210. protected _buildBlock(state: NodeMaterialBuildState): this;
  63211. }
  63212. }
  63213. declare module BABYLON {
  63214. /**
  63215. * Block used to subtract 2 vectors
  63216. */
  63217. export class SubtractBlock extends NodeMaterialBlock {
  63218. /**
  63219. * Creates a new SubtractBlock
  63220. * @param name defines the block name
  63221. */
  63222. constructor(name: string);
  63223. /**
  63224. * Gets the current class name
  63225. * @returns the class name
  63226. */
  63227. getClassName(): string;
  63228. /**
  63229. * Gets the left operand input component
  63230. */
  63231. get left(): NodeMaterialConnectionPoint;
  63232. /**
  63233. * Gets the right operand input component
  63234. */
  63235. get right(): NodeMaterialConnectionPoint;
  63236. /**
  63237. * Gets the output component
  63238. */
  63239. get output(): NodeMaterialConnectionPoint;
  63240. protected _buildBlock(state: NodeMaterialBuildState): this;
  63241. }
  63242. }
  63243. declare module BABYLON {
  63244. /**
  63245. * Block used to step a value
  63246. */
  63247. export class StepBlock extends NodeMaterialBlock {
  63248. /**
  63249. * Creates a new StepBlock
  63250. * @param name defines the block name
  63251. */
  63252. constructor(name: string);
  63253. /**
  63254. * Gets the current class name
  63255. * @returns the class name
  63256. */
  63257. getClassName(): string;
  63258. /**
  63259. * Gets the value operand input component
  63260. */
  63261. get value(): NodeMaterialConnectionPoint;
  63262. /**
  63263. * Gets the edge operand input component
  63264. */
  63265. get edge(): NodeMaterialConnectionPoint;
  63266. /**
  63267. * Gets the output component
  63268. */
  63269. get output(): NodeMaterialConnectionPoint;
  63270. protected _buildBlock(state: NodeMaterialBuildState): this;
  63271. }
  63272. }
  63273. declare module BABYLON {
  63274. /**
  63275. * Block used to get the opposite (1 - x) of a value
  63276. */
  63277. export class OneMinusBlock extends NodeMaterialBlock {
  63278. /**
  63279. * Creates a new OneMinusBlock
  63280. * @param name defines the block name
  63281. */
  63282. constructor(name: string);
  63283. /**
  63284. * Gets the current class name
  63285. * @returns the class name
  63286. */
  63287. getClassName(): string;
  63288. /**
  63289. * Gets the input component
  63290. */
  63291. get input(): NodeMaterialConnectionPoint;
  63292. /**
  63293. * Gets the output component
  63294. */
  63295. get output(): NodeMaterialConnectionPoint;
  63296. protected _buildBlock(state: NodeMaterialBuildState): this;
  63297. }
  63298. }
  63299. declare module BABYLON {
  63300. /**
  63301. * Block used to get the view direction
  63302. */
  63303. export class ViewDirectionBlock extends NodeMaterialBlock {
  63304. /**
  63305. * Creates a new ViewDirectionBlock
  63306. * @param name defines the block name
  63307. */
  63308. constructor(name: string);
  63309. /**
  63310. * Gets the current class name
  63311. * @returns the class name
  63312. */
  63313. getClassName(): string;
  63314. /**
  63315. * Gets the world position component
  63316. */
  63317. get worldPosition(): NodeMaterialConnectionPoint;
  63318. /**
  63319. * Gets the camera position component
  63320. */
  63321. get cameraPosition(): NodeMaterialConnectionPoint;
  63322. /**
  63323. * Gets the output component
  63324. */
  63325. get output(): NodeMaterialConnectionPoint;
  63326. autoConfigure(material: NodeMaterial): void;
  63327. protected _buildBlock(state: NodeMaterialBuildState): this;
  63328. }
  63329. }
  63330. declare module BABYLON {
  63331. /**
  63332. * Block used to compute fresnel value
  63333. */
  63334. export class FresnelBlock extends NodeMaterialBlock {
  63335. /**
  63336. * Create a new FresnelBlock
  63337. * @param name defines the block name
  63338. */
  63339. constructor(name: string);
  63340. /**
  63341. * Gets the current class name
  63342. * @returns the class name
  63343. */
  63344. getClassName(): string;
  63345. /**
  63346. * Gets the world normal input component
  63347. */
  63348. get worldNormal(): NodeMaterialConnectionPoint;
  63349. /**
  63350. * Gets the view direction input component
  63351. */
  63352. get viewDirection(): NodeMaterialConnectionPoint;
  63353. /**
  63354. * Gets the bias input component
  63355. */
  63356. get bias(): NodeMaterialConnectionPoint;
  63357. /**
  63358. * Gets the camera (or eye) position component
  63359. */
  63360. get power(): NodeMaterialConnectionPoint;
  63361. /**
  63362. * Gets the fresnel output component
  63363. */
  63364. get fresnel(): NodeMaterialConnectionPoint;
  63365. autoConfigure(material: NodeMaterial): void;
  63366. protected _buildBlock(state: NodeMaterialBuildState): this;
  63367. }
  63368. }
  63369. declare module BABYLON {
  63370. /**
  63371. * Block used to get the max of 2 values
  63372. */
  63373. export class MaxBlock extends NodeMaterialBlock {
  63374. /**
  63375. * Creates a new MaxBlock
  63376. * @param name defines the block name
  63377. */
  63378. constructor(name: string);
  63379. /**
  63380. * Gets the current class name
  63381. * @returns the class name
  63382. */
  63383. getClassName(): string;
  63384. /**
  63385. * Gets the left operand input component
  63386. */
  63387. get left(): NodeMaterialConnectionPoint;
  63388. /**
  63389. * Gets the right operand input component
  63390. */
  63391. get right(): NodeMaterialConnectionPoint;
  63392. /**
  63393. * Gets the output component
  63394. */
  63395. get output(): NodeMaterialConnectionPoint;
  63396. protected _buildBlock(state: NodeMaterialBuildState): this;
  63397. }
  63398. }
  63399. declare module BABYLON {
  63400. /**
  63401. * Block used to get the min of 2 values
  63402. */
  63403. export class MinBlock extends NodeMaterialBlock {
  63404. /**
  63405. * Creates a new MinBlock
  63406. * @param name defines the block name
  63407. */
  63408. constructor(name: string);
  63409. /**
  63410. * Gets the current class name
  63411. * @returns the class name
  63412. */
  63413. getClassName(): string;
  63414. /**
  63415. * Gets the left operand input component
  63416. */
  63417. get left(): NodeMaterialConnectionPoint;
  63418. /**
  63419. * Gets the right operand input component
  63420. */
  63421. get right(): NodeMaterialConnectionPoint;
  63422. /**
  63423. * Gets the output component
  63424. */
  63425. get output(): NodeMaterialConnectionPoint;
  63426. protected _buildBlock(state: NodeMaterialBuildState): this;
  63427. }
  63428. }
  63429. declare module BABYLON {
  63430. /**
  63431. * Block used to get the distance between 2 values
  63432. */
  63433. export class DistanceBlock extends NodeMaterialBlock {
  63434. /**
  63435. * Creates a new DistanceBlock
  63436. * @param name defines the block name
  63437. */
  63438. constructor(name: string);
  63439. /**
  63440. * Gets the current class name
  63441. * @returns the class name
  63442. */
  63443. getClassName(): string;
  63444. /**
  63445. * Gets the left operand input component
  63446. */
  63447. get left(): NodeMaterialConnectionPoint;
  63448. /**
  63449. * Gets the right operand input component
  63450. */
  63451. get right(): NodeMaterialConnectionPoint;
  63452. /**
  63453. * Gets the output component
  63454. */
  63455. get output(): NodeMaterialConnectionPoint;
  63456. protected _buildBlock(state: NodeMaterialBuildState): this;
  63457. }
  63458. }
  63459. declare module BABYLON {
  63460. /**
  63461. * Block used to get the length of a vector
  63462. */
  63463. export class LengthBlock extends NodeMaterialBlock {
  63464. /**
  63465. * Creates a new LengthBlock
  63466. * @param name defines the block name
  63467. */
  63468. constructor(name: string);
  63469. /**
  63470. * Gets the current class name
  63471. * @returns the class name
  63472. */
  63473. getClassName(): string;
  63474. /**
  63475. * Gets the value input component
  63476. */
  63477. get value(): NodeMaterialConnectionPoint;
  63478. /**
  63479. * Gets the output component
  63480. */
  63481. get output(): NodeMaterialConnectionPoint;
  63482. protected _buildBlock(state: NodeMaterialBuildState): this;
  63483. }
  63484. }
  63485. declare module BABYLON {
  63486. /**
  63487. * Block used to get negative version of a value (i.e. x * -1)
  63488. */
  63489. export class NegateBlock extends NodeMaterialBlock {
  63490. /**
  63491. * Creates a new NegateBlock
  63492. * @param name defines the block name
  63493. */
  63494. constructor(name: string);
  63495. /**
  63496. * Gets the current class name
  63497. * @returns the class name
  63498. */
  63499. getClassName(): string;
  63500. /**
  63501. * Gets the value input component
  63502. */
  63503. get value(): NodeMaterialConnectionPoint;
  63504. /**
  63505. * Gets the output component
  63506. */
  63507. get output(): NodeMaterialConnectionPoint;
  63508. protected _buildBlock(state: NodeMaterialBuildState): this;
  63509. }
  63510. }
  63511. declare module BABYLON {
  63512. /**
  63513. * Block used to get the value of the first parameter raised to the power of the second
  63514. */
  63515. export class PowBlock extends NodeMaterialBlock {
  63516. /**
  63517. * Creates a new PowBlock
  63518. * @param name defines the block name
  63519. */
  63520. constructor(name: string);
  63521. /**
  63522. * Gets the current class name
  63523. * @returns the class name
  63524. */
  63525. getClassName(): string;
  63526. /**
  63527. * Gets the value operand input component
  63528. */
  63529. get value(): NodeMaterialConnectionPoint;
  63530. /**
  63531. * Gets the power operand input component
  63532. */
  63533. get power(): NodeMaterialConnectionPoint;
  63534. /**
  63535. * Gets the output component
  63536. */
  63537. get output(): NodeMaterialConnectionPoint;
  63538. protected _buildBlock(state: NodeMaterialBuildState): this;
  63539. }
  63540. }
  63541. declare module BABYLON {
  63542. /**
  63543. * Block used to get a random number
  63544. */
  63545. export class RandomNumberBlock extends NodeMaterialBlock {
  63546. /**
  63547. * Creates a new RandomNumberBlock
  63548. * @param name defines the block name
  63549. */
  63550. constructor(name: string);
  63551. /**
  63552. * Gets the current class name
  63553. * @returns the class name
  63554. */
  63555. getClassName(): string;
  63556. /**
  63557. * Gets the seed input component
  63558. */
  63559. get seed(): NodeMaterialConnectionPoint;
  63560. /**
  63561. * Gets the output component
  63562. */
  63563. get output(): NodeMaterialConnectionPoint;
  63564. protected _buildBlock(state: NodeMaterialBuildState): this;
  63565. }
  63566. }
  63567. declare module BABYLON {
  63568. /**
  63569. * Block used to compute arc tangent of 2 values
  63570. */
  63571. export class ArcTan2Block extends NodeMaterialBlock {
  63572. /**
  63573. * Creates a new ArcTan2Block
  63574. * @param name defines the block name
  63575. */
  63576. constructor(name: string);
  63577. /**
  63578. * Gets the current class name
  63579. * @returns the class name
  63580. */
  63581. getClassName(): string;
  63582. /**
  63583. * Gets the x operand input component
  63584. */
  63585. get x(): NodeMaterialConnectionPoint;
  63586. /**
  63587. * Gets the y operand input component
  63588. */
  63589. get y(): NodeMaterialConnectionPoint;
  63590. /**
  63591. * Gets the output component
  63592. */
  63593. get output(): NodeMaterialConnectionPoint;
  63594. protected _buildBlock(state: NodeMaterialBuildState): this;
  63595. }
  63596. }
  63597. declare module BABYLON {
  63598. /**
  63599. * Block used to smooth step a value
  63600. */
  63601. export class SmoothStepBlock extends NodeMaterialBlock {
  63602. /**
  63603. * Creates a new SmoothStepBlock
  63604. * @param name defines the block name
  63605. */
  63606. constructor(name: string);
  63607. /**
  63608. * Gets the current class name
  63609. * @returns the class name
  63610. */
  63611. getClassName(): string;
  63612. /**
  63613. * Gets the value operand input component
  63614. */
  63615. get value(): NodeMaterialConnectionPoint;
  63616. /**
  63617. * Gets the first edge operand input component
  63618. */
  63619. get edge0(): NodeMaterialConnectionPoint;
  63620. /**
  63621. * Gets the second edge operand input component
  63622. */
  63623. get edge1(): NodeMaterialConnectionPoint;
  63624. /**
  63625. * Gets the output component
  63626. */
  63627. get output(): NodeMaterialConnectionPoint;
  63628. protected _buildBlock(state: NodeMaterialBuildState): this;
  63629. }
  63630. }
  63631. declare module BABYLON {
  63632. /**
  63633. * Block used to get the reciprocal (1 / x) of a value
  63634. */
  63635. export class ReciprocalBlock extends NodeMaterialBlock {
  63636. /**
  63637. * Creates a new ReciprocalBlock
  63638. * @param name defines the block name
  63639. */
  63640. constructor(name: string);
  63641. /**
  63642. * Gets the current class name
  63643. * @returns the class name
  63644. */
  63645. getClassName(): string;
  63646. /**
  63647. * Gets the input component
  63648. */
  63649. get input(): NodeMaterialConnectionPoint;
  63650. /**
  63651. * Gets the output component
  63652. */
  63653. get output(): NodeMaterialConnectionPoint;
  63654. protected _buildBlock(state: NodeMaterialBuildState): this;
  63655. }
  63656. }
  63657. declare module BABYLON {
  63658. /**
  63659. * Block used to replace a color by another one
  63660. */
  63661. export class ReplaceColorBlock extends NodeMaterialBlock {
  63662. /**
  63663. * Creates a new ReplaceColorBlock
  63664. * @param name defines the block name
  63665. */
  63666. constructor(name: string);
  63667. /**
  63668. * Gets the current class name
  63669. * @returns the class name
  63670. */
  63671. getClassName(): string;
  63672. /**
  63673. * Gets the value input component
  63674. */
  63675. get value(): NodeMaterialConnectionPoint;
  63676. /**
  63677. * Gets the reference input component
  63678. */
  63679. get reference(): NodeMaterialConnectionPoint;
  63680. /**
  63681. * Gets the distance input component
  63682. */
  63683. get distance(): NodeMaterialConnectionPoint;
  63684. /**
  63685. * Gets the replacement input component
  63686. */
  63687. get replacement(): NodeMaterialConnectionPoint;
  63688. /**
  63689. * Gets the output component
  63690. */
  63691. get output(): NodeMaterialConnectionPoint;
  63692. protected _buildBlock(state: NodeMaterialBuildState): this;
  63693. }
  63694. }
  63695. declare module BABYLON {
  63696. /**
  63697. * Block used to posterize a value
  63698. * @see https://en.wikipedia.org/wiki/Posterization
  63699. */
  63700. export class PosterizeBlock extends NodeMaterialBlock {
  63701. /**
  63702. * Creates a new PosterizeBlock
  63703. * @param name defines the block name
  63704. */
  63705. constructor(name: string);
  63706. /**
  63707. * Gets the current class name
  63708. * @returns the class name
  63709. */
  63710. getClassName(): string;
  63711. /**
  63712. * Gets the value input component
  63713. */
  63714. get value(): NodeMaterialConnectionPoint;
  63715. /**
  63716. * Gets the steps input component
  63717. */
  63718. get steps(): NodeMaterialConnectionPoint;
  63719. /**
  63720. * Gets the output component
  63721. */
  63722. get output(): NodeMaterialConnectionPoint;
  63723. protected _buildBlock(state: NodeMaterialBuildState): this;
  63724. }
  63725. }
  63726. declare module BABYLON {
  63727. /**
  63728. * Operations supported by the Wave block
  63729. */
  63730. export enum WaveBlockKind {
  63731. /** SawTooth */
  63732. SawTooth = 0,
  63733. /** Square */
  63734. Square = 1,
  63735. /** Triangle */
  63736. Triangle = 2
  63737. }
  63738. /**
  63739. * Block used to apply wave operation to floats
  63740. */
  63741. export class WaveBlock extends NodeMaterialBlock {
  63742. /**
  63743. * Gets or sets the kibnd of wave to be applied by the block
  63744. */
  63745. kind: WaveBlockKind;
  63746. /**
  63747. * Creates a new WaveBlock
  63748. * @param name defines the block name
  63749. */
  63750. constructor(name: string);
  63751. /**
  63752. * Gets the current class name
  63753. * @returns the class name
  63754. */
  63755. getClassName(): string;
  63756. /**
  63757. * Gets the input component
  63758. */
  63759. get input(): NodeMaterialConnectionPoint;
  63760. /**
  63761. * Gets the output component
  63762. */
  63763. get output(): NodeMaterialConnectionPoint;
  63764. protected _buildBlock(state: NodeMaterialBuildState): this;
  63765. serialize(): any;
  63766. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63767. }
  63768. }
  63769. declare module BABYLON {
  63770. /**
  63771. * Class used to store a color step for the GradientBlock
  63772. */
  63773. export class GradientBlockColorStep {
  63774. /**
  63775. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63776. */
  63777. step: number;
  63778. /**
  63779. * Gets or sets the color associated with this step
  63780. */
  63781. color: Color3;
  63782. /**
  63783. * Creates a new GradientBlockColorStep
  63784. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63785. * @param color defines the color associated with this step
  63786. */
  63787. constructor(
  63788. /**
  63789. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63790. */
  63791. step: number,
  63792. /**
  63793. * Gets or sets the color associated with this step
  63794. */
  63795. color: Color3);
  63796. }
  63797. /**
  63798. * Block used to return a color from a gradient based on an input value between 0 and 1
  63799. */
  63800. export class GradientBlock extends NodeMaterialBlock {
  63801. /**
  63802. * Gets or sets the list of color steps
  63803. */
  63804. colorSteps: GradientBlockColorStep[];
  63805. /**
  63806. * Creates a new GradientBlock
  63807. * @param name defines the block name
  63808. */
  63809. constructor(name: string);
  63810. /**
  63811. * Gets the current class name
  63812. * @returns the class name
  63813. */
  63814. getClassName(): string;
  63815. /**
  63816. * Gets the gradient input component
  63817. */
  63818. get gradient(): NodeMaterialConnectionPoint;
  63819. /**
  63820. * Gets the output component
  63821. */
  63822. get output(): NodeMaterialConnectionPoint;
  63823. private _writeColorConstant;
  63824. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63825. serialize(): any;
  63826. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63827. protected _dumpPropertiesCode(): string;
  63828. }
  63829. }
  63830. declare module BABYLON {
  63831. /**
  63832. * Block used to normalize lerp between 2 values
  63833. */
  63834. export class NLerpBlock extends NodeMaterialBlock {
  63835. /**
  63836. * Creates a new NLerpBlock
  63837. * @param name defines the block name
  63838. */
  63839. constructor(name: string);
  63840. /**
  63841. * Gets the current class name
  63842. * @returns the class name
  63843. */
  63844. getClassName(): string;
  63845. /**
  63846. * Gets the left operand input component
  63847. */
  63848. get left(): NodeMaterialConnectionPoint;
  63849. /**
  63850. * Gets the right operand input component
  63851. */
  63852. get right(): NodeMaterialConnectionPoint;
  63853. /**
  63854. * Gets the gradient operand input component
  63855. */
  63856. get gradient(): NodeMaterialConnectionPoint;
  63857. /**
  63858. * Gets the output component
  63859. */
  63860. get output(): NodeMaterialConnectionPoint;
  63861. protected _buildBlock(state: NodeMaterialBuildState): this;
  63862. }
  63863. }
  63864. declare module BABYLON {
  63865. /**
  63866. * block used to Generate a Worley Noise 3D Noise Pattern
  63867. */
  63868. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63869. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63870. manhattanDistance: boolean;
  63871. /**
  63872. * Creates a new WorleyNoise3DBlock
  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 seed input component
  63883. */
  63884. get seed(): NodeMaterialConnectionPoint;
  63885. /**
  63886. * Gets the jitter input component
  63887. */
  63888. get jitter(): NodeMaterialConnectionPoint;
  63889. /**
  63890. * Gets the output component
  63891. */
  63892. get output(): NodeMaterialConnectionPoint;
  63893. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63894. /**
  63895. * Exposes the properties to the UI?
  63896. */
  63897. protected _dumpPropertiesCode(): string;
  63898. /**
  63899. * Exposes the properties to the Seralize?
  63900. */
  63901. serialize(): any;
  63902. /**
  63903. * Exposes the properties to the deseralize?
  63904. */
  63905. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63906. }
  63907. }
  63908. declare module BABYLON {
  63909. /**
  63910. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63911. */
  63912. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63913. /**
  63914. * Creates a new SimplexPerlin3DBlock
  63915. * @param name defines the block name
  63916. */
  63917. constructor(name: string);
  63918. /**
  63919. * Gets the current class name
  63920. * @returns the class name
  63921. */
  63922. getClassName(): string;
  63923. /**
  63924. * Gets the seed operand input component
  63925. */
  63926. get seed(): NodeMaterialConnectionPoint;
  63927. /**
  63928. * Gets the output component
  63929. */
  63930. get output(): NodeMaterialConnectionPoint;
  63931. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63932. }
  63933. }
  63934. declare module BABYLON {
  63935. /**
  63936. * Block used to blend normals
  63937. */
  63938. export class NormalBlendBlock extends NodeMaterialBlock {
  63939. /**
  63940. * Creates a new NormalBlendBlock
  63941. * @param name defines the block name
  63942. */
  63943. constructor(name: string);
  63944. /**
  63945. * Gets the current class name
  63946. * @returns the class name
  63947. */
  63948. getClassName(): string;
  63949. /**
  63950. * Gets the first input component
  63951. */
  63952. get normalMap0(): NodeMaterialConnectionPoint;
  63953. /**
  63954. * Gets the second input component
  63955. */
  63956. get normalMap1(): 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 rotate a 2d vector by a given angle
  63967. */
  63968. export class Rotate2dBlock extends NodeMaterialBlock {
  63969. /**
  63970. * Creates a new Rotate2dBlock
  63971. * @param name defines the block name
  63972. */
  63973. constructor(name: string);
  63974. /**
  63975. * Gets the current class name
  63976. * @returns the class name
  63977. */
  63978. getClassName(): string;
  63979. /**
  63980. * Gets the input vector
  63981. */
  63982. get input(): NodeMaterialConnectionPoint;
  63983. /**
  63984. * Gets the input angle
  63985. */
  63986. get angle(): NodeMaterialConnectionPoint;
  63987. /**
  63988. * Gets the output component
  63989. */
  63990. get output(): NodeMaterialConnectionPoint;
  63991. autoConfigure(material: NodeMaterial): void;
  63992. protected _buildBlock(state: NodeMaterialBuildState): this;
  63993. }
  63994. }
  63995. declare module BABYLON {
  63996. /**
  63997. * Block used to get the reflected vector from a direction and a normal
  63998. */
  63999. export class ReflectBlock extends NodeMaterialBlock {
  64000. /**
  64001. * Creates a new ReflectBlock
  64002. * @param name defines the block name
  64003. */
  64004. constructor(name: string);
  64005. /**
  64006. * Gets the current class name
  64007. * @returns the class name
  64008. */
  64009. getClassName(): string;
  64010. /**
  64011. * Gets the incident component
  64012. */
  64013. get incident(): NodeMaterialConnectionPoint;
  64014. /**
  64015. * Gets the normal component
  64016. */
  64017. get normal(): NodeMaterialConnectionPoint;
  64018. /**
  64019. * Gets the output component
  64020. */
  64021. get output(): NodeMaterialConnectionPoint;
  64022. protected _buildBlock(state: NodeMaterialBuildState): this;
  64023. }
  64024. }
  64025. declare module BABYLON {
  64026. /**
  64027. * Block used to get the refracted vector from a direction and a normal
  64028. */
  64029. export class RefractBlock extends NodeMaterialBlock {
  64030. /**
  64031. * Creates a new RefractBlock
  64032. * @param name defines the block name
  64033. */
  64034. constructor(name: string);
  64035. /**
  64036. * Gets the current class name
  64037. * @returns the class name
  64038. */
  64039. getClassName(): string;
  64040. /**
  64041. * Gets the incident component
  64042. */
  64043. get incident(): NodeMaterialConnectionPoint;
  64044. /**
  64045. * Gets the normal component
  64046. */
  64047. get normal(): NodeMaterialConnectionPoint;
  64048. /**
  64049. * Gets the index of refraction component
  64050. */
  64051. get ior(): NodeMaterialConnectionPoint;
  64052. /**
  64053. * Gets the output component
  64054. */
  64055. get output(): NodeMaterialConnectionPoint;
  64056. protected _buildBlock(state: NodeMaterialBuildState): this;
  64057. }
  64058. }
  64059. declare module BABYLON {
  64060. /**
  64061. * Block used to desaturate a color
  64062. */
  64063. export class DesaturateBlock extends NodeMaterialBlock {
  64064. /**
  64065. * Creates a new DesaturateBlock
  64066. * @param name defines the block name
  64067. */
  64068. constructor(name: string);
  64069. /**
  64070. * Gets the current class name
  64071. * @returns the class name
  64072. */
  64073. getClassName(): string;
  64074. /**
  64075. * Gets the color operand input component
  64076. */
  64077. get color(): NodeMaterialConnectionPoint;
  64078. /**
  64079. * Gets the level operand input component
  64080. */
  64081. get level(): NodeMaterialConnectionPoint;
  64082. /**
  64083. * Gets the output component
  64084. */
  64085. get output(): NodeMaterialConnectionPoint;
  64086. protected _buildBlock(state: NodeMaterialBuildState): this;
  64087. }
  64088. }
  64089. declare module BABYLON {
  64090. /**
  64091. * Block used to implement the ambient occlusion module of the PBR material
  64092. */
  64093. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64094. /**
  64095. * Create a new AmbientOcclusionBlock
  64096. * @param name defines the block name
  64097. */
  64098. constructor(name: string);
  64099. /**
  64100. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64101. */
  64102. useAmbientInGrayScale: boolean;
  64103. /**
  64104. * Initialize the block and prepare the context for build
  64105. * @param state defines the state that will be used for the build
  64106. */
  64107. initialize(state: NodeMaterialBuildState): void;
  64108. /**
  64109. * Gets the current class name
  64110. * @returns the class name
  64111. */
  64112. getClassName(): string;
  64113. /**
  64114. * Gets the texture input component
  64115. */
  64116. get texture(): NodeMaterialConnectionPoint;
  64117. /**
  64118. * Gets the texture intensity component
  64119. */
  64120. get intensity(): NodeMaterialConnectionPoint;
  64121. /**
  64122. * Gets the direct light intensity input component
  64123. */
  64124. get directLightIntensity(): NodeMaterialConnectionPoint;
  64125. /**
  64126. * Gets the ambient occlusion object output component
  64127. */
  64128. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64129. /**
  64130. * Gets the main code of the block (fragment side)
  64131. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64132. * @returns the shader code
  64133. */
  64134. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64135. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64136. protected _buildBlock(state: NodeMaterialBuildState): this;
  64137. protected _dumpPropertiesCode(): string;
  64138. serialize(): any;
  64139. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64140. }
  64141. }
  64142. declare module BABYLON {
  64143. /**
  64144. * Block used to implement the reflection module of the PBR material
  64145. */
  64146. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64147. /** @hidden */
  64148. _defineLODReflectionAlpha: string;
  64149. /** @hidden */
  64150. _defineLinearSpecularReflection: string;
  64151. private _vEnvironmentIrradianceName;
  64152. /** @hidden */
  64153. _vReflectionMicrosurfaceInfosName: string;
  64154. /** @hidden */
  64155. _vReflectionInfosName: string;
  64156. /** @hidden */
  64157. _vReflectionFilteringInfoName: string;
  64158. private _scene;
  64159. /**
  64160. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64161. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64162. * It's less burden on the user side in the editor part.
  64163. */
  64164. /** @hidden */
  64165. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64166. /** @hidden */
  64167. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64168. /** @hidden */
  64169. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64170. /**
  64171. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64172. * diffuse part of the IBL.
  64173. */
  64174. useSphericalHarmonics: boolean;
  64175. /**
  64176. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64177. */
  64178. forceIrradianceInFragment: boolean;
  64179. /**
  64180. * Create a new ReflectionBlock
  64181. * @param name defines the block name
  64182. */
  64183. constructor(name: string);
  64184. /**
  64185. * Gets the current class name
  64186. * @returns the class name
  64187. */
  64188. getClassName(): string;
  64189. /**
  64190. * Gets the position input component
  64191. */
  64192. get position(): NodeMaterialConnectionPoint;
  64193. /**
  64194. * Gets the world position input component
  64195. */
  64196. get worldPosition(): NodeMaterialConnectionPoint;
  64197. /**
  64198. * Gets the world normal input component
  64199. */
  64200. get worldNormal(): NodeMaterialConnectionPoint;
  64201. /**
  64202. * Gets the world input component
  64203. */
  64204. get world(): NodeMaterialConnectionPoint;
  64205. /**
  64206. * Gets the camera (or eye) position component
  64207. */
  64208. get cameraPosition(): NodeMaterialConnectionPoint;
  64209. /**
  64210. * Gets the view input component
  64211. */
  64212. get view(): NodeMaterialConnectionPoint;
  64213. /**
  64214. * Gets the color input component
  64215. */
  64216. get color(): NodeMaterialConnectionPoint;
  64217. /**
  64218. * Gets the reflection object output component
  64219. */
  64220. get reflection(): NodeMaterialConnectionPoint;
  64221. /**
  64222. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64223. */
  64224. get hasTexture(): boolean;
  64225. /**
  64226. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64227. */
  64228. get reflectionColor(): string;
  64229. protected _getTexture(): Nullable<BaseTexture>;
  64230. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64231. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64232. /**
  64233. * Gets the code to inject in the vertex shader
  64234. * @param state current state of the node material building
  64235. * @returns the shader code
  64236. */
  64237. handleVertexSide(state: NodeMaterialBuildState): string;
  64238. /**
  64239. * Gets the main code of the block (fragment side)
  64240. * @param state current state of the node material building
  64241. * @param normalVarName name of the existing variable corresponding to the normal
  64242. * @returns the shader code
  64243. */
  64244. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64245. protected _buildBlock(state: NodeMaterialBuildState): this;
  64246. protected _dumpPropertiesCode(): string;
  64247. serialize(): any;
  64248. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64249. }
  64250. }
  64251. declare module BABYLON {
  64252. /**
  64253. * Block used to implement the sheen module of the PBR material
  64254. */
  64255. export class SheenBlock extends NodeMaterialBlock {
  64256. /**
  64257. * Create a new SheenBlock
  64258. * @param name defines the block name
  64259. */
  64260. constructor(name: string);
  64261. /**
  64262. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64263. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64264. * making it easier to setup and tweak the effect
  64265. */
  64266. albedoScaling: boolean;
  64267. /**
  64268. * Defines if the sheen is linked to the sheen color.
  64269. */
  64270. linkSheenWithAlbedo: boolean;
  64271. /**
  64272. * Initialize the block and prepare the context for build
  64273. * @param state defines the state that will be used for the build
  64274. */
  64275. initialize(state: NodeMaterialBuildState): void;
  64276. /**
  64277. * Gets the current class name
  64278. * @returns the class name
  64279. */
  64280. getClassName(): string;
  64281. /**
  64282. * Gets the intensity input component
  64283. */
  64284. get intensity(): NodeMaterialConnectionPoint;
  64285. /**
  64286. * Gets the color input component
  64287. */
  64288. get color(): NodeMaterialConnectionPoint;
  64289. /**
  64290. * Gets the roughness input component
  64291. */
  64292. get roughness(): NodeMaterialConnectionPoint;
  64293. /**
  64294. * Gets the sheen object output component
  64295. */
  64296. get sheen(): NodeMaterialConnectionPoint;
  64297. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64298. /**
  64299. * Gets the main code of the block (fragment side)
  64300. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64301. * @returns the shader code
  64302. */
  64303. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64304. protected _buildBlock(state: NodeMaterialBuildState): this;
  64305. protected _dumpPropertiesCode(): string;
  64306. serialize(): any;
  64307. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64308. }
  64309. }
  64310. declare module BABYLON {
  64311. /**
  64312. * Block used to implement the reflectivity module of the PBR material
  64313. */
  64314. export class ReflectivityBlock extends NodeMaterialBlock {
  64315. private _metallicReflectanceColor;
  64316. private _metallicF0Factor;
  64317. /** @hidden */
  64318. _vMetallicReflectanceFactorsName: string;
  64319. /**
  64320. * The property below is set by the main PBR block prior to calling methods of this class.
  64321. */
  64322. /** @hidden */
  64323. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64324. /**
  64325. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64326. */
  64327. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64328. /**
  64329. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64330. */
  64331. useMetallnessFromMetallicTextureBlue: boolean;
  64332. /**
  64333. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64334. */
  64335. useRoughnessFromMetallicTextureAlpha: boolean;
  64336. /**
  64337. * Specifies if the metallic texture contains the roughness information in its green channel.
  64338. */
  64339. useRoughnessFromMetallicTextureGreen: boolean;
  64340. /**
  64341. * Create a new ReflectivityBlock
  64342. * @param name defines the block name
  64343. */
  64344. constructor(name: string);
  64345. /**
  64346. * Initialize the block and prepare the context for build
  64347. * @param state defines the state that will be used for the build
  64348. */
  64349. initialize(state: NodeMaterialBuildState): void;
  64350. /**
  64351. * Gets the current class name
  64352. * @returns the class name
  64353. */
  64354. getClassName(): string;
  64355. /**
  64356. * Gets the metallic input component
  64357. */
  64358. get metallic(): NodeMaterialConnectionPoint;
  64359. /**
  64360. * Gets the roughness input component
  64361. */
  64362. get roughness(): NodeMaterialConnectionPoint;
  64363. /**
  64364. * Gets the texture input component
  64365. */
  64366. get texture(): NodeMaterialConnectionPoint;
  64367. /**
  64368. * Gets the reflectivity object output component
  64369. */
  64370. get reflectivity(): NodeMaterialConnectionPoint;
  64371. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64372. /**
  64373. * Gets the main code of the block (fragment side)
  64374. * @param state current state of the node material building
  64375. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64376. * @returns the shader code
  64377. */
  64378. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64379. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64380. protected _buildBlock(state: NodeMaterialBuildState): this;
  64381. protected _dumpPropertiesCode(): string;
  64382. serialize(): any;
  64383. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64384. }
  64385. }
  64386. declare module BABYLON {
  64387. /**
  64388. * Block used to implement the anisotropy module of the PBR material
  64389. */
  64390. export class AnisotropyBlock extends NodeMaterialBlock {
  64391. /**
  64392. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64393. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64394. * It's less burden on the user side in the editor part.
  64395. */
  64396. /** @hidden */
  64397. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64398. /** @hidden */
  64399. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64400. /**
  64401. * Create a new AnisotropyBlock
  64402. * @param name defines the block name
  64403. */
  64404. constructor(name: string);
  64405. /**
  64406. * Initialize the block and prepare the context for build
  64407. * @param state defines the state that will be used for the build
  64408. */
  64409. initialize(state: NodeMaterialBuildState): void;
  64410. /**
  64411. * Gets the current class name
  64412. * @returns the class name
  64413. */
  64414. getClassName(): string;
  64415. /**
  64416. * Gets the intensity input component
  64417. */
  64418. get intensity(): NodeMaterialConnectionPoint;
  64419. /**
  64420. * Gets the direction input component
  64421. */
  64422. get direction(): NodeMaterialConnectionPoint;
  64423. /**
  64424. * Gets the texture input component
  64425. */
  64426. get texture(): NodeMaterialConnectionPoint;
  64427. /**
  64428. * Gets the uv input component
  64429. */
  64430. get uv(): NodeMaterialConnectionPoint;
  64431. /**
  64432. * Gets the worldTangent input component
  64433. */
  64434. get worldTangent(): NodeMaterialConnectionPoint;
  64435. /**
  64436. * Gets the anisotropy object output component
  64437. */
  64438. get anisotropy(): NodeMaterialConnectionPoint;
  64439. private _generateTBNSpace;
  64440. /**
  64441. * Gets the main code of the block (fragment side)
  64442. * @param state current state of the node material building
  64443. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64444. * @returns the shader code
  64445. */
  64446. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64448. protected _buildBlock(state: NodeMaterialBuildState): this;
  64449. }
  64450. }
  64451. declare module BABYLON {
  64452. /**
  64453. * Block used to implement the clear coat module of the PBR material
  64454. */
  64455. export class ClearCoatBlock extends NodeMaterialBlock {
  64456. private _scene;
  64457. /**
  64458. * Create a new ClearCoatBlock
  64459. * @param name defines the block name
  64460. */
  64461. constructor(name: string);
  64462. /**
  64463. * Initialize the block and prepare the context for build
  64464. * @param state defines the state that will be used for the build
  64465. */
  64466. initialize(state: NodeMaterialBuildState): void;
  64467. /**
  64468. * Gets the current class name
  64469. * @returns the class name
  64470. */
  64471. getClassName(): string;
  64472. /**
  64473. * Gets the intensity input component
  64474. */
  64475. get intensity(): NodeMaterialConnectionPoint;
  64476. /**
  64477. * Gets the roughness input component
  64478. */
  64479. get roughness(): NodeMaterialConnectionPoint;
  64480. /**
  64481. * Gets the ior input component
  64482. */
  64483. get ior(): NodeMaterialConnectionPoint;
  64484. /**
  64485. * Gets the texture input component
  64486. */
  64487. get texture(): NodeMaterialConnectionPoint;
  64488. /**
  64489. * Gets the bump texture input component
  64490. */
  64491. get bumpTexture(): NodeMaterialConnectionPoint;
  64492. /**
  64493. * Gets the uv input component
  64494. */
  64495. get uv(): NodeMaterialConnectionPoint;
  64496. /**
  64497. * Gets the tint color input component
  64498. */
  64499. get tintColor(): NodeMaterialConnectionPoint;
  64500. /**
  64501. * Gets the tint "at distance" input component
  64502. */
  64503. get tintAtDistance(): NodeMaterialConnectionPoint;
  64504. /**
  64505. * Gets the tint thickness input component
  64506. */
  64507. get tintThickness(): NodeMaterialConnectionPoint;
  64508. /**
  64509. * Gets the world tangent input component
  64510. */
  64511. get worldTangent(): NodeMaterialConnectionPoint;
  64512. /**
  64513. * Gets the clear coat object output component
  64514. */
  64515. get clearcoat(): NodeMaterialConnectionPoint;
  64516. autoConfigure(material: NodeMaterial): void;
  64517. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64518. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64519. private _generateTBNSpace;
  64520. /**
  64521. * Gets the main code of the block (fragment side)
  64522. * @param state current state of the node material building
  64523. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64524. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64525. * @param worldPosVarName name of the variable holding the world position
  64526. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64527. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64528. * @param worldNormalVarName name of the variable holding the world normal
  64529. * @returns the shader code
  64530. */
  64531. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64532. protected _buildBlock(state: NodeMaterialBuildState): this;
  64533. }
  64534. }
  64535. declare module BABYLON {
  64536. /**
  64537. * Block used to implement the sub surface module of the PBR material
  64538. */
  64539. export class SubSurfaceBlock extends NodeMaterialBlock {
  64540. /**
  64541. * Create a new SubSurfaceBlock
  64542. * @param name defines the block name
  64543. */
  64544. constructor(name: string);
  64545. /**
  64546. * Stores the intensity of the different subsurface effects in the thickness texture.
  64547. * * the green channel is the translucency intensity.
  64548. * * the blue channel is the scattering intensity.
  64549. * * the alpha channel is the refraction intensity.
  64550. */
  64551. useMaskFromThicknessTexture: boolean;
  64552. /**
  64553. * Initialize the block and prepare the context for build
  64554. * @param state defines the state that will be used for the build
  64555. */
  64556. initialize(state: NodeMaterialBuildState): void;
  64557. /**
  64558. * Gets the current class name
  64559. * @returns the class name
  64560. */
  64561. getClassName(): string;
  64562. /**
  64563. * Gets the min thickness input component
  64564. */
  64565. get minThickness(): NodeMaterialConnectionPoint;
  64566. /**
  64567. * Gets the max thickness input component
  64568. */
  64569. get maxThickness(): NodeMaterialConnectionPoint;
  64570. /**
  64571. * Gets the thickness texture component
  64572. */
  64573. get thicknessTexture(): NodeMaterialConnectionPoint;
  64574. /**
  64575. * Gets the tint color input component
  64576. */
  64577. get tintColor(): NodeMaterialConnectionPoint;
  64578. /**
  64579. * Gets the translucency intensity input component
  64580. */
  64581. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64582. /**
  64583. * Gets the translucency diffusion distance input component
  64584. */
  64585. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64586. /**
  64587. * Gets the refraction object parameters
  64588. */
  64589. get refraction(): NodeMaterialConnectionPoint;
  64590. /**
  64591. * Gets the sub surface object output component
  64592. */
  64593. get subsurface(): NodeMaterialConnectionPoint;
  64594. autoConfigure(material: NodeMaterial): void;
  64595. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64596. /**
  64597. * Gets the main code of the block (fragment side)
  64598. * @param state current state of the node material building
  64599. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64600. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64601. * @param worldPosVarName name of the variable holding the world position
  64602. * @returns the shader code
  64603. */
  64604. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64605. protected _buildBlock(state: NodeMaterialBuildState): this;
  64606. }
  64607. }
  64608. declare module BABYLON {
  64609. /**
  64610. * Block used to implement the PBR metallic/roughness model
  64611. */
  64612. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64613. /**
  64614. * Gets or sets the light associated with this block
  64615. */
  64616. light: Nullable<Light>;
  64617. private _lightId;
  64618. private _scene;
  64619. private _environmentBRDFTexture;
  64620. private _environmentBrdfSamplerName;
  64621. private _vNormalWName;
  64622. private _invertNormalName;
  64623. /**
  64624. * Create a new ReflectionBlock
  64625. * @param name defines the block name
  64626. */
  64627. constructor(name: string);
  64628. /**
  64629. * Intensity of the direct lights e.g. the four lights available in your scene.
  64630. * This impacts both the direct diffuse and specular highlights.
  64631. */
  64632. directIntensity: number;
  64633. /**
  64634. * Intensity of the environment e.g. how much the environment will light the object
  64635. * either through harmonics for rough material or through the refelction for shiny ones.
  64636. */
  64637. environmentIntensity: number;
  64638. /**
  64639. * This is a special control allowing the reduction of the specular highlights coming from the
  64640. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64641. */
  64642. specularIntensity: number;
  64643. /**
  64644. * Defines the falloff type used in this material.
  64645. * It by default is Physical.
  64646. */
  64647. lightFalloff: number;
  64648. /**
  64649. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64650. */
  64651. useAlphaFromAlbedoTexture: boolean;
  64652. /**
  64653. * Specifies that alpha test should be used
  64654. */
  64655. useAlphaTest: boolean;
  64656. /**
  64657. * Defines the alpha limits in alpha test mode.
  64658. */
  64659. alphaTestCutoff: number;
  64660. /**
  64661. * Specifies that alpha blending should be used
  64662. */
  64663. useAlphaBlending: boolean;
  64664. /**
  64665. * Defines if the alpha value should be determined via the rgb values.
  64666. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64667. */
  64668. opacityRGB: boolean;
  64669. /**
  64670. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64671. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64672. */
  64673. useRadianceOverAlpha: boolean;
  64674. /**
  64675. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64676. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64677. */
  64678. useSpecularOverAlpha: boolean;
  64679. /**
  64680. * Enables specular anti aliasing in the PBR shader.
  64681. * It will both interacts on the Geometry for analytical and IBL lighting.
  64682. * It also prefilter the roughness map based on the bump values.
  64683. */
  64684. enableSpecularAntiAliasing: boolean;
  64685. /**
  64686. * Enables realtime filtering on the texture.
  64687. */
  64688. realTimeFiltering: boolean;
  64689. /**
  64690. * Quality switch for realtime filtering
  64691. */
  64692. realTimeFilteringQuality: number;
  64693. /**
  64694. * Defines if the material uses energy conservation.
  64695. */
  64696. useEnergyConservation: boolean;
  64697. /**
  64698. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64699. * too much the area relying on ambient texture to define their ambient occlusion.
  64700. */
  64701. useRadianceOcclusion: boolean;
  64702. /**
  64703. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64704. * makes the reflect vector face the model (under horizon).
  64705. */
  64706. useHorizonOcclusion: boolean;
  64707. /**
  64708. * If set to true, no lighting calculations will be applied.
  64709. */
  64710. unlit: boolean;
  64711. /**
  64712. * Force normal to face away from face.
  64713. */
  64714. forceNormalForward: boolean;
  64715. /**
  64716. * Defines the material debug mode.
  64717. * It helps seeing only some components of the material while troubleshooting.
  64718. */
  64719. debugMode: number;
  64720. /**
  64721. * Specify from where on screen the debug mode should start.
  64722. * The value goes from -1 (full screen) to 1 (not visible)
  64723. * It helps with side by side comparison against the final render
  64724. * This defaults to 0
  64725. */
  64726. debugLimit: number;
  64727. /**
  64728. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64729. * You can use the factor to better multiply the final value.
  64730. */
  64731. debugFactor: number;
  64732. /**
  64733. * Initialize the block and prepare the context for build
  64734. * @param state defines the state that will be used for the build
  64735. */
  64736. initialize(state: NodeMaterialBuildState): void;
  64737. /**
  64738. * Gets the current class name
  64739. * @returns the class name
  64740. */
  64741. getClassName(): string;
  64742. /**
  64743. * Gets the world position input component
  64744. */
  64745. get worldPosition(): NodeMaterialConnectionPoint;
  64746. /**
  64747. * Gets the world normal input component
  64748. */
  64749. get worldNormal(): NodeMaterialConnectionPoint;
  64750. /**
  64751. * Gets the perturbed normal input component
  64752. */
  64753. get perturbedNormal(): NodeMaterialConnectionPoint;
  64754. /**
  64755. * Gets the camera position input component
  64756. */
  64757. get cameraPosition(): NodeMaterialConnectionPoint;
  64758. /**
  64759. * Gets the base color input component
  64760. */
  64761. get baseColor(): NodeMaterialConnectionPoint;
  64762. /**
  64763. * Gets the opacity texture input component
  64764. */
  64765. get opacityTexture(): NodeMaterialConnectionPoint;
  64766. /**
  64767. * Gets the ambient color input component
  64768. */
  64769. get ambientColor(): NodeMaterialConnectionPoint;
  64770. /**
  64771. * Gets the reflectivity object parameters
  64772. */
  64773. get reflectivity(): NodeMaterialConnectionPoint;
  64774. /**
  64775. * Gets the ambient occlusion object parameters
  64776. */
  64777. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64778. /**
  64779. * Gets the reflection object parameters
  64780. */
  64781. get reflection(): NodeMaterialConnectionPoint;
  64782. /**
  64783. * Gets the sheen object parameters
  64784. */
  64785. get sheen(): NodeMaterialConnectionPoint;
  64786. /**
  64787. * Gets the clear coat object parameters
  64788. */
  64789. get clearcoat(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the sub surface object parameters
  64792. */
  64793. get subsurface(): NodeMaterialConnectionPoint;
  64794. /**
  64795. * Gets the anisotropy object parameters
  64796. */
  64797. get anisotropy(): NodeMaterialConnectionPoint;
  64798. /**
  64799. * Gets the ambient output component
  64800. */
  64801. get ambient(): NodeMaterialConnectionPoint;
  64802. /**
  64803. * Gets the diffuse output component
  64804. */
  64805. get diffuse(): NodeMaterialConnectionPoint;
  64806. /**
  64807. * Gets the specular output component
  64808. */
  64809. get specular(): NodeMaterialConnectionPoint;
  64810. /**
  64811. * Gets the sheen output component
  64812. */
  64813. get sheenDir(): NodeMaterialConnectionPoint;
  64814. /**
  64815. * Gets the clear coat output component
  64816. */
  64817. get clearcoatDir(): NodeMaterialConnectionPoint;
  64818. /**
  64819. * Gets the indirect diffuse output component
  64820. */
  64821. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64822. /**
  64823. * Gets the indirect specular output component
  64824. */
  64825. get specularIndirect(): NodeMaterialConnectionPoint;
  64826. /**
  64827. * Gets the indirect sheen output component
  64828. */
  64829. get sheenIndirect(): NodeMaterialConnectionPoint;
  64830. /**
  64831. * Gets the indirect clear coat output component
  64832. */
  64833. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64834. /**
  64835. * Gets the refraction output component
  64836. */
  64837. get refraction(): NodeMaterialConnectionPoint;
  64838. /**
  64839. * Gets the global lighting output component
  64840. */
  64841. get lighting(): NodeMaterialConnectionPoint;
  64842. /**
  64843. * Gets the shadow output component
  64844. */
  64845. get shadow(): NodeMaterialConnectionPoint;
  64846. /**
  64847. * Gets the alpha output component
  64848. */
  64849. get alpha(): NodeMaterialConnectionPoint;
  64850. autoConfigure(material: NodeMaterial): void;
  64851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64852. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64853. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64854. private _injectVertexCode;
  64855. /**
  64856. * Gets the code corresponding to the albedo/opacity module
  64857. * @returns the shader code
  64858. */
  64859. getAlbedoOpacityCode(): string;
  64860. protected _buildBlock(state: NodeMaterialBuildState): this;
  64861. protected _dumpPropertiesCode(): string;
  64862. serialize(): any;
  64863. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64864. }
  64865. }
  64866. declare module BABYLON {
  64867. /**
  64868. * Block used to compute value of one parameter modulo another
  64869. */
  64870. export class ModBlock extends NodeMaterialBlock {
  64871. /**
  64872. * Creates a new ModBlock
  64873. * @param name defines the block name
  64874. */
  64875. constructor(name: string);
  64876. /**
  64877. * Gets the current class name
  64878. * @returns the class name
  64879. */
  64880. getClassName(): string;
  64881. /**
  64882. * Gets the left operand input component
  64883. */
  64884. get left(): NodeMaterialConnectionPoint;
  64885. /**
  64886. * Gets the right operand input component
  64887. */
  64888. get right(): NodeMaterialConnectionPoint;
  64889. /**
  64890. * Gets the output component
  64891. */
  64892. get output(): NodeMaterialConnectionPoint;
  64893. protected _buildBlock(state: NodeMaterialBuildState): this;
  64894. }
  64895. }
  64896. declare module BABYLON {
  64897. /**
  64898. * Helper class to push actions to a pool of workers.
  64899. */
  64900. export class WorkerPool implements IDisposable {
  64901. private _workerInfos;
  64902. private _pendingActions;
  64903. /**
  64904. * Constructor
  64905. * @param workers Array of workers to use for actions
  64906. */
  64907. constructor(workers: Array<Worker>);
  64908. /**
  64909. * Terminates all workers and clears any pending actions.
  64910. */
  64911. dispose(): void;
  64912. /**
  64913. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64914. * pended until a worker has completed its action.
  64915. * @param action The action to perform. Call onComplete when the action is complete.
  64916. */
  64917. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64918. private _execute;
  64919. }
  64920. }
  64921. declare module BABYLON {
  64922. /**
  64923. * Configuration for Draco compression
  64924. */
  64925. export interface IDracoCompressionConfiguration {
  64926. /**
  64927. * Configuration for the decoder.
  64928. */
  64929. decoder: {
  64930. /**
  64931. * The url to the WebAssembly module.
  64932. */
  64933. wasmUrl?: string;
  64934. /**
  64935. * The url to the WebAssembly binary.
  64936. */
  64937. wasmBinaryUrl?: string;
  64938. /**
  64939. * The url to the fallback JavaScript module.
  64940. */
  64941. fallbackUrl?: string;
  64942. };
  64943. }
  64944. /**
  64945. * Draco compression (https://google.github.io/draco/)
  64946. *
  64947. * This class wraps the Draco module.
  64948. *
  64949. * **Encoder**
  64950. *
  64951. * The encoder is not currently implemented.
  64952. *
  64953. * **Decoder**
  64954. *
  64955. * 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.
  64956. *
  64957. * To update the configuration, use the following code:
  64958. * ```javascript
  64959. * DracoCompression.Configuration = {
  64960. * decoder: {
  64961. * wasmUrl: "<url to the WebAssembly library>",
  64962. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64963. * fallbackUrl: "<url to the fallback JavaScript library>",
  64964. * }
  64965. * };
  64966. * ```
  64967. *
  64968. * 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.
  64969. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64970. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64971. *
  64972. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64973. * ```javascript
  64974. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64975. * ```
  64976. *
  64977. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64978. */
  64979. export class DracoCompression implements IDisposable {
  64980. private _workerPoolPromise?;
  64981. private _decoderModulePromise?;
  64982. /**
  64983. * The configuration. Defaults to the following urls:
  64984. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64985. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64986. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64987. */
  64988. static Configuration: IDracoCompressionConfiguration;
  64989. /**
  64990. * Returns true if the decoder configuration is available.
  64991. */
  64992. static get DecoderAvailable(): boolean;
  64993. /**
  64994. * Default number of workers to create when creating the draco compression object.
  64995. */
  64996. static DefaultNumWorkers: number;
  64997. private static GetDefaultNumWorkers;
  64998. private static _Default;
  64999. /**
  65000. * Default instance for the draco compression object.
  65001. */
  65002. static get Default(): DracoCompression;
  65003. /**
  65004. * Constructor
  65005. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65006. */
  65007. constructor(numWorkers?: number);
  65008. /**
  65009. * Stop all async operations and release resources.
  65010. */
  65011. dispose(): void;
  65012. /**
  65013. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65014. * @returns a promise that resolves when ready
  65015. */
  65016. whenReadyAsync(): Promise<void>;
  65017. /**
  65018. * Decode Draco compressed mesh data to vertex data.
  65019. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65020. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65021. * @returns A promise that resolves with the decoded vertex data
  65022. */
  65023. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65024. [kind: string]: number;
  65025. }): Promise<VertexData>;
  65026. }
  65027. }
  65028. declare module BABYLON {
  65029. /**
  65030. * Class for building Constructive Solid Geometry
  65031. */
  65032. export class CSG {
  65033. private polygons;
  65034. /**
  65035. * The world matrix
  65036. */
  65037. matrix: Matrix;
  65038. /**
  65039. * Stores the position
  65040. */
  65041. position: Vector3;
  65042. /**
  65043. * Stores the rotation
  65044. */
  65045. rotation: Vector3;
  65046. /**
  65047. * Stores the rotation quaternion
  65048. */
  65049. rotationQuaternion: Nullable<Quaternion>;
  65050. /**
  65051. * Stores the scaling vector
  65052. */
  65053. scaling: Vector3;
  65054. /**
  65055. * Convert the Mesh to CSG
  65056. * @param mesh The Mesh to convert to CSG
  65057. * @returns A new CSG from the Mesh
  65058. */
  65059. static FromMesh(mesh: Mesh): CSG;
  65060. /**
  65061. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65062. * @param polygons Polygons used to construct a CSG solid
  65063. */
  65064. private static FromPolygons;
  65065. /**
  65066. * Clones, or makes a deep copy, of the CSG
  65067. * @returns A new CSG
  65068. */
  65069. clone(): CSG;
  65070. /**
  65071. * Unions this CSG with another CSG
  65072. * @param csg The CSG to union against this CSG
  65073. * @returns The unioned CSG
  65074. */
  65075. union(csg: CSG): CSG;
  65076. /**
  65077. * Unions this CSG with another CSG in place
  65078. * @param csg The CSG to union against this CSG
  65079. */
  65080. unionInPlace(csg: CSG): void;
  65081. /**
  65082. * Subtracts this CSG with another CSG
  65083. * @param csg The CSG to subtract against this CSG
  65084. * @returns A new CSG
  65085. */
  65086. subtract(csg: CSG): CSG;
  65087. /**
  65088. * Subtracts this CSG with another CSG in place
  65089. * @param csg The CSG to subtact against this CSG
  65090. */
  65091. subtractInPlace(csg: CSG): void;
  65092. /**
  65093. * Intersect this CSG with another CSG
  65094. * @param csg The CSG to intersect against this CSG
  65095. * @returns A new CSG
  65096. */
  65097. intersect(csg: CSG): CSG;
  65098. /**
  65099. * Intersects this CSG with another CSG in place
  65100. * @param csg The CSG to intersect against this CSG
  65101. */
  65102. intersectInPlace(csg: CSG): void;
  65103. /**
  65104. * Return a new CSG solid with solid and empty space switched. This solid is
  65105. * not modified.
  65106. * @returns A new CSG solid with solid and empty space switched
  65107. */
  65108. inverse(): CSG;
  65109. /**
  65110. * Inverses the CSG in place
  65111. */
  65112. inverseInPlace(): void;
  65113. /**
  65114. * This is used to keep meshes transformations so they can be restored
  65115. * when we build back a Babylon Mesh
  65116. * NB : All CSG operations are performed in world coordinates
  65117. * @param csg The CSG to copy the transform attributes from
  65118. * @returns This CSG
  65119. */
  65120. copyTransformAttributes(csg: CSG): CSG;
  65121. /**
  65122. * Build Raw mesh from CSG
  65123. * Coordinates here are in world space
  65124. * @param name The name of the mesh geometry
  65125. * @param scene The Scene
  65126. * @param keepSubMeshes Specifies if the submeshes should be kept
  65127. * @returns A new Mesh
  65128. */
  65129. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65130. /**
  65131. * Build Mesh from CSG taking material and transforms into account
  65132. * @param name The name of the Mesh
  65133. * @param material The material of the Mesh
  65134. * @param scene The Scene
  65135. * @param keepSubMeshes Specifies if submeshes should be kept
  65136. * @returns The new Mesh
  65137. */
  65138. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65139. }
  65140. }
  65141. declare module BABYLON {
  65142. /**
  65143. * Class used to create a trail following a mesh
  65144. */
  65145. export class TrailMesh extends Mesh {
  65146. private _generator;
  65147. private _autoStart;
  65148. private _running;
  65149. private _diameter;
  65150. private _length;
  65151. private _sectionPolygonPointsCount;
  65152. private _sectionVectors;
  65153. private _sectionNormalVectors;
  65154. private _beforeRenderObserver;
  65155. /**
  65156. * @constructor
  65157. * @param name The value used by scene.getMeshByName() to do a lookup.
  65158. * @param generator The mesh or transform node to generate a trail.
  65159. * @param scene The scene to add this mesh to.
  65160. * @param diameter Diameter of trailing mesh. Default is 1.
  65161. * @param length Length of trailing mesh. Default is 60.
  65162. * @param autoStart Automatically start trailing mesh. Default true.
  65163. */
  65164. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65165. /**
  65166. * "TrailMesh"
  65167. * @returns "TrailMesh"
  65168. */
  65169. getClassName(): string;
  65170. private _createMesh;
  65171. /**
  65172. * Start trailing mesh.
  65173. */
  65174. start(): void;
  65175. /**
  65176. * Stop trailing mesh.
  65177. */
  65178. stop(): void;
  65179. /**
  65180. * Update trailing mesh geometry.
  65181. */
  65182. update(): void;
  65183. /**
  65184. * Returns a new TrailMesh object.
  65185. * @param name is a string, the name given to the new mesh
  65186. * @param newGenerator use new generator object for cloned trail mesh
  65187. * @returns a new mesh
  65188. */
  65189. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65190. /**
  65191. * Serializes this trail mesh
  65192. * @param serializationObject object to write serialization to
  65193. */
  65194. serialize(serializationObject: any): void;
  65195. /**
  65196. * Parses a serialized trail mesh
  65197. * @param parsedMesh the serialized mesh
  65198. * @param scene the scene to create the trail mesh in
  65199. * @returns the created trail mesh
  65200. */
  65201. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65202. }
  65203. }
  65204. declare module BABYLON {
  65205. /**
  65206. * Class containing static functions to help procedurally build meshes
  65207. */
  65208. export class TiledBoxBuilder {
  65209. /**
  65210. * Creates a box mesh
  65211. * 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)
  65212. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65214. * * 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
  65215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65216. * @param name defines the name of the mesh
  65217. * @param options defines the options used to create the mesh
  65218. * @param scene defines the hosting scene
  65219. * @returns the box mesh
  65220. */
  65221. static CreateTiledBox(name: string, options: {
  65222. pattern?: number;
  65223. width?: number;
  65224. height?: number;
  65225. depth?: number;
  65226. tileSize?: number;
  65227. tileWidth?: number;
  65228. tileHeight?: number;
  65229. alignHorizontal?: number;
  65230. alignVertical?: number;
  65231. faceUV?: Vector4[];
  65232. faceColors?: Color4[];
  65233. sideOrientation?: number;
  65234. updatable?: boolean;
  65235. }, scene?: Nullable<Scene>): Mesh;
  65236. }
  65237. }
  65238. declare module BABYLON {
  65239. /**
  65240. * Class containing static functions to help procedurally build meshes
  65241. */
  65242. export class TorusKnotBuilder {
  65243. /**
  65244. * Creates a torus knot mesh
  65245. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65246. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65247. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65248. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65250. * * 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
  65251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65252. * @param name defines the name of the mesh
  65253. * @param options defines the options used to create the mesh
  65254. * @param scene defines the hosting scene
  65255. * @returns the torus knot mesh
  65256. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65257. */
  65258. static CreateTorusKnot(name: string, options: {
  65259. radius?: number;
  65260. tube?: number;
  65261. radialSegments?: number;
  65262. tubularSegments?: number;
  65263. p?: number;
  65264. q?: number;
  65265. updatable?: boolean;
  65266. sideOrientation?: number;
  65267. frontUVs?: Vector4;
  65268. backUVs?: Vector4;
  65269. }, scene: any): Mesh;
  65270. }
  65271. }
  65272. declare module BABYLON {
  65273. /**
  65274. * Polygon
  65275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65276. */
  65277. export class Polygon {
  65278. /**
  65279. * Creates a rectangle
  65280. * @param xmin bottom X coord
  65281. * @param ymin bottom Y coord
  65282. * @param xmax top X coord
  65283. * @param ymax top Y coord
  65284. * @returns points that make the resulting rectation
  65285. */
  65286. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65287. /**
  65288. * Creates a circle
  65289. * @param radius radius of circle
  65290. * @param cx scale in x
  65291. * @param cy scale in y
  65292. * @param numberOfSides number of sides that make up the circle
  65293. * @returns points that make the resulting circle
  65294. */
  65295. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65296. /**
  65297. * Creates a polygon from input string
  65298. * @param input Input polygon data
  65299. * @returns the parsed points
  65300. */
  65301. static Parse(input: string): Vector2[];
  65302. /**
  65303. * Starts building a polygon from x and y coordinates
  65304. * @param x x coordinate
  65305. * @param y y coordinate
  65306. * @returns the started path2
  65307. */
  65308. static StartingAt(x: number, y: number): Path2;
  65309. }
  65310. /**
  65311. * Builds a polygon
  65312. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65313. */
  65314. export class PolygonMeshBuilder {
  65315. private _points;
  65316. private _outlinepoints;
  65317. private _holes;
  65318. private _name;
  65319. private _scene;
  65320. private _epoints;
  65321. private _eholes;
  65322. private _addToepoint;
  65323. /**
  65324. * Babylon reference to the earcut plugin.
  65325. */
  65326. bjsEarcut: any;
  65327. /**
  65328. * Creates a PolygonMeshBuilder
  65329. * @param name name of the builder
  65330. * @param contours Path of the polygon
  65331. * @param scene scene to add to when creating the mesh
  65332. * @param earcutInjection can be used to inject your own earcut reference
  65333. */
  65334. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65335. /**
  65336. * Adds a whole within the polygon
  65337. * @param hole Array of points defining the hole
  65338. * @returns this
  65339. */
  65340. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65341. /**
  65342. * Creates the polygon
  65343. * @param updatable If the mesh should be updatable
  65344. * @param depth The depth of the mesh created
  65345. * @returns the created mesh
  65346. */
  65347. build(updatable?: boolean, depth?: number): Mesh;
  65348. /**
  65349. * Creates the polygon
  65350. * @param depth The depth of the mesh created
  65351. * @returns the created VertexData
  65352. */
  65353. buildVertexData(depth?: number): VertexData;
  65354. /**
  65355. * Adds a side to the polygon
  65356. * @param positions points that make the polygon
  65357. * @param normals normals of the polygon
  65358. * @param uvs uvs of the polygon
  65359. * @param indices indices of the polygon
  65360. * @param bounds bounds of the polygon
  65361. * @param points points of the polygon
  65362. * @param depth depth of the polygon
  65363. * @param flip flip of the polygon
  65364. */
  65365. private addSide;
  65366. }
  65367. }
  65368. declare module BABYLON {
  65369. /**
  65370. * Class containing static functions to help procedurally build meshes
  65371. */
  65372. export class PolygonBuilder {
  65373. /**
  65374. * Creates a polygon mesh
  65375. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65376. * * 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
  65377. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65379. * * 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)
  65380. * * Remember you can only change the shape positions, not their number when updating a polygon
  65381. * @param name defines the name of the mesh
  65382. * @param options defines the options used to create the mesh
  65383. * @param scene defines the hosting scene
  65384. * @param earcutInjection can be used to inject your own earcut reference
  65385. * @returns the polygon mesh
  65386. */
  65387. static CreatePolygon(name: string, options: {
  65388. shape: Vector3[];
  65389. holes?: Vector3[][];
  65390. depth?: number;
  65391. faceUV?: Vector4[];
  65392. faceColors?: Color4[];
  65393. updatable?: boolean;
  65394. sideOrientation?: number;
  65395. frontUVs?: Vector4;
  65396. backUVs?: Vector4;
  65397. wrap?: boolean;
  65398. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65399. /**
  65400. * Creates an extruded polygon mesh, with depth in the Y direction.
  65401. * * 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)
  65402. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65403. * @param name defines the name of the mesh
  65404. * @param options defines the options used to create the mesh
  65405. * @param scene defines the hosting scene
  65406. * @param earcutInjection can be used to inject your own earcut reference
  65407. * @returns the polygon mesh
  65408. */
  65409. static ExtrudePolygon(name: string, options: {
  65410. shape: Vector3[];
  65411. holes?: Vector3[][];
  65412. depth?: number;
  65413. faceUV?: Vector4[];
  65414. faceColors?: Color4[];
  65415. updatable?: boolean;
  65416. sideOrientation?: number;
  65417. frontUVs?: Vector4;
  65418. backUVs?: Vector4;
  65419. wrap?: boolean;
  65420. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65421. }
  65422. }
  65423. declare module BABYLON {
  65424. /**
  65425. * Class containing static functions to help procedurally build meshes
  65426. */
  65427. export class LatheBuilder {
  65428. /**
  65429. * Creates lathe mesh.
  65430. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65431. * * 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
  65432. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65433. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65434. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65435. * * 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
  65436. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65437. * * 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
  65438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65439. * * 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
  65440. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65442. * @param name defines the name of the mesh
  65443. * @param options defines the options used to create the mesh
  65444. * @param scene defines the hosting scene
  65445. * @returns the lathe mesh
  65446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65447. */
  65448. static CreateLathe(name: string, options: {
  65449. shape: Vector3[];
  65450. radius?: number;
  65451. tessellation?: number;
  65452. clip?: number;
  65453. arc?: number;
  65454. closed?: boolean;
  65455. updatable?: boolean;
  65456. sideOrientation?: number;
  65457. frontUVs?: Vector4;
  65458. backUVs?: Vector4;
  65459. cap?: number;
  65460. invertUV?: boolean;
  65461. }, scene?: Nullable<Scene>): Mesh;
  65462. }
  65463. }
  65464. declare module BABYLON {
  65465. /**
  65466. * Class containing static functions to help procedurally build meshes
  65467. */
  65468. export class TiledPlaneBuilder {
  65469. /**
  65470. * Creates a tiled plane mesh
  65471. * * The parameter `pattern` will, depending on value, do nothing or
  65472. * * * flip (reflect about central vertical) alternate tiles across and up
  65473. * * * flip every tile on alternate rows
  65474. * * * rotate (180 degs) alternate tiles across and up
  65475. * * * rotate every tile on alternate rows
  65476. * * * flip and rotate alternate tiles across and up
  65477. * * * flip and rotate every tile on alternate rows
  65478. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65479. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65480. * * 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
  65481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65482. * * 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)
  65483. * * 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)
  65484. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65485. * @param name defines the name of the mesh
  65486. * @param options defines the options used to create the mesh
  65487. * @param scene defines the hosting scene
  65488. * @returns the box mesh
  65489. */
  65490. static CreateTiledPlane(name: string, options: {
  65491. pattern?: number;
  65492. tileSize?: number;
  65493. tileWidth?: number;
  65494. tileHeight?: number;
  65495. size?: number;
  65496. width?: number;
  65497. height?: number;
  65498. alignHorizontal?: number;
  65499. alignVertical?: number;
  65500. sideOrientation?: number;
  65501. frontUVs?: Vector4;
  65502. backUVs?: Vector4;
  65503. updatable?: boolean;
  65504. }, scene?: Nullable<Scene>): Mesh;
  65505. }
  65506. }
  65507. declare module BABYLON {
  65508. /**
  65509. * Class containing static functions to help procedurally build meshes
  65510. */
  65511. export class TubeBuilder {
  65512. /**
  65513. * Creates a tube mesh.
  65514. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65515. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65516. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65517. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65518. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65519. * * 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)
  65520. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65521. * * 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
  65522. * * 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
  65523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65524. * * 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
  65525. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65527. * @param name defines the name of the mesh
  65528. * @param options defines the options used to create the mesh
  65529. * @param scene defines the hosting scene
  65530. * @returns the tube mesh
  65531. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65532. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65533. */
  65534. static CreateTube(name: string, options: {
  65535. path: Vector3[];
  65536. radius?: number;
  65537. tessellation?: number;
  65538. radiusFunction?: {
  65539. (i: number, distance: number): number;
  65540. };
  65541. cap?: number;
  65542. arc?: number;
  65543. updatable?: boolean;
  65544. sideOrientation?: number;
  65545. frontUVs?: Vector4;
  65546. backUVs?: Vector4;
  65547. instance?: Mesh;
  65548. invertUV?: boolean;
  65549. }, scene?: Nullable<Scene>): Mesh;
  65550. }
  65551. }
  65552. declare module BABYLON {
  65553. /**
  65554. * Class containing static functions to help procedurally build meshes
  65555. */
  65556. export class IcoSphereBuilder {
  65557. /**
  65558. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65559. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65560. * * 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`)
  65561. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65562. * * 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
  65563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65564. * * 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
  65565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65566. * @param name defines the name of the mesh
  65567. * @param options defines the options used to create the mesh
  65568. * @param scene defines the hosting scene
  65569. * @returns the icosahedron mesh
  65570. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65571. */
  65572. static CreateIcoSphere(name: string, options: {
  65573. radius?: number;
  65574. radiusX?: number;
  65575. radiusY?: number;
  65576. radiusZ?: number;
  65577. flat?: boolean;
  65578. subdivisions?: number;
  65579. sideOrientation?: number;
  65580. frontUVs?: Vector4;
  65581. backUVs?: Vector4;
  65582. updatable?: boolean;
  65583. }, scene?: Nullable<Scene>): Mesh;
  65584. }
  65585. }
  65586. declare module BABYLON {
  65587. /**
  65588. * Class containing static functions to help procedurally build meshes
  65589. */
  65590. export class DecalBuilder {
  65591. /**
  65592. * Creates a decal mesh.
  65593. * 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
  65594. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65595. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65596. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65597. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65598. * @param name defines the name of the mesh
  65599. * @param sourceMesh defines the mesh where the decal must be applied
  65600. * @param options defines the options used to create the mesh
  65601. * @param scene defines the hosting scene
  65602. * @returns the decal mesh
  65603. * @see https://doc.babylonjs.com/how_to/decals
  65604. */
  65605. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65606. position?: Vector3;
  65607. normal?: Vector3;
  65608. size?: Vector3;
  65609. angle?: number;
  65610. }): Mesh;
  65611. }
  65612. }
  65613. declare module BABYLON {
  65614. /**
  65615. * Class containing static functions to help procedurally build meshes
  65616. */
  65617. export class MeshBuilder {
  65618. /**
  65619. * Creates a box mesh
  65620. * * The parameter `size` sets the size (float) of each box side (default 1)
  65621. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65622. * * 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)
  65623. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65625. * * 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
  65626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65627. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65628. * @param name defines the name of the mesh
  65629. * @param options defines the options used to create the mesh
  65630. * @param scene defines the hosting scene
  65631. * @returns the box mesh
  65632. */
  65633. static CreateBox(name: string, options: {
  65634. size?: number;
  65635. width?: number;
  65636. height?: number;
  65637. depth?: number;
  65638. faceUV?: Vector4[];
  65639. faceColors?: Color4[];
  65640. sideOrientation?: number;
  65641. frontUVs?: Vector4;
  65642. backUVs?: Vector4;
  65643. wrap?: boolean;
  65644. topBaseAt?: number;
  65645. bottomBaseAt?: number;
  65646. updatable?: boolean;
  65647. }, scene?: Nullable<Scene>): Mesh;
  65648. /**
  65649. * Creates a tiled box mesh
  65650. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65652. * @param name defines the name of the mesh
  65653. * @param options defines the options used to create the mesh
  65654. * @param scene defines the hosting scene
  65655. * @returns the tiled box mesh
  65656. */
  65657. static CreateTiledBox(name: string, options: {
  65658. pattern?: number;
  65659. size?: number;
  65660. width?: number;
  65661. height?: number;
  65662. depth: number;
  65663. tileSize?: number;
  65664. tileWidth?: number;
  65665. tileHeight?: number;
  65666. faceUV?: Vector4[];
  65667. faceColors?: Color4[];
  65668. alignHorizontal?: number;
  65669. alignVertical?: number;
  65670. sideOrientation?: number;
  65671. updatable?: boolean;
  65672. }, scene?: Nullable<Scene>): Mesh;
  65673. /**
  65674. * Creates a sphere mesh
  65675. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65676. * * 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`)
  65677. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65678. * * 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
  65679. * * 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)
  65680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65681. * * 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
  65682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65683. * @param name defines the name of the mesh
  65684. * @param options defines the options used to create the mesh
  65685. * @param scene defines the hosting scene
  65686. * @returns the sphere mesh
  65687. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65688. */
  65689. static CreateSphere(name: string, options: {
  65690. segments?: number;
  65691. diameter?: number;
  65692. diameterX?: number;
  65693. diameterY?: number;
  65694. diameterZ?: number;
  65695. arc?: number;
  65696. slice?: number;
  65697. sideOrientation?: number;
  65698. frontUVs?: Vector4;
  65699. backUVs?: Vector4;
  65700. updatable?: boolean;
  65701. }, scene?: Nullable<Scene>): Mesh;
  65702. /**
  65703. * Creates a plane polygonal mesh. By default, this is a disc
  65704. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65705. * * 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
  65706. * * 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
  65707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65708. * * 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
  65709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65710. * @param name defines the name of the mesh
  65711. * @param options defines the options used to create the mesh
  65712. * @param scene defines the hosting scene
  65713. * @returns the plane polygonal mesh
  65714. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65715. */
  65716. static CreateDisc(name: string, options: {
  65717. radius?: number;
  65718. tessellation?: number;
  65719. arc?: number;
  65720. updatable?: boolean;
  65721. sideOrientation?: number;
  65722. frontUVs?: Vector4;
  65723. backUVs?: Vector4;
  65724. }, scene?: Nullable<Scene>): Mesh;
  65725. /**
  65726. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65727. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65728. * * 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`)
  65729. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65730. * * 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
  65731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65732. * * 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
  65733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65734. * @param name defines the name of the mesh
  65735. * @param options defines the options used to create the mesh
  65736. * @param scene defines the hosting scene
  65737. * @returns the icosahedron mesh
  65738. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65739. */
  65740. static CreateIcoSphere(name: string, options: {
  65741. radius?: number;
  65742. radiusX?: number;
  65743. radiusY?: number;
  65744. radiusZ?: number;
  65745. flat?: boolean;
  65746. subdivisions?: number;
  65747. sideOrientation?: number;
  65748. frontUVs?: Vector4;
  65749. backUVs?: Vector4;
  65750. updatable?: boolean;
  65751. }, scene?: Nullable<Scene>): Mesh;
  65752. /**
  65753. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65754. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65755. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65756. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65757. * * 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
  65758. * * 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
  65759. * * 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
  65760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65761. * * 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
  65762. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65763. * * 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
  65764. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65765. * * 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
  65766. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65768. * @param name defines the name of the mesh
  65769. * @param options defines the options used to create the mesh
  65770. * @param scene defines the hosting scene
  65771. * @returns the ribbon mesh
  65772. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65773. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65774. */
  65775. static CreateRibbon(name: string, options: {
  65776. pathArray: Vector3[][];
  65777. closeArray?: boolean;
  65778. closePath?: boolean;
  65779. offset?: number;
  65780. updatable?: boolean;
  65781. sideOrientation?: number;
  65782. frontUVs?: Vector4;
  65783. backUVs?: Vector4;
  65784. instance?: Mesh;
  65785. invertUV?: boolean;
  65786. uvs?: Vector2[];
  65787. colors?: Color4[];
  65788. }, scene?: Nullable<Scene>): Mesh;
  65789. /**
  65790. * Creates a cylinder or a cone mesh
  65791. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65792. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65793. * * 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.
  65794. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65795. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65796. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65797. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65798. * * 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).
  65799. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65800. * * 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).
  65801. * * 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
  65802. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65803. * * 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
  65804. * * 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.
  65805. * * If `enclose` is false, a ring surface is one element.
  65806. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65807. * * 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
  65808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65809. * * 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
  65810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65811. * @param name defines the name of the mesh
  65812. * @param options defines the options used to create the mesh
  65813. * @param scene defines the hosting scene
  65814. * @returns the cylinder mesh
  65815. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65816. */
  65817. static CreateCylinder(name: string, options: {
  65818. height?: number;
  65819. diameterTop?: number;
  65820. diameterBottom?: number;
  65821. diameter?: number;
  65822. tessellation?: number;
  65823. subdivisions?: number;
  65824. arc?: number;
  65825. faceColors?: Color4[];
  65826. faceUV?: Vector4[];
  65827. updatable?: boolean;
  65828. hasRings?: boolean;
  65829. enclose?: boolean;
  65830. cap?: number;
  65831. sideOrientation?: number;
  65832. frontUVs?: Vector4;
  65833. backUVs?: Vector4;
  65834. }, scene?: Nullable<Scene>): Mesh;
  65835. /**
  65836. * Creates a torus mesh
  65837. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65838. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65839. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65841. * * 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
  65842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65843. * @param name defines the name of the mesh
  65844. * @param options defines the options used to create the mesh
  65845. * @param scene defines the hosting scene
  65846. * @returns the torus mesh
  65847. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65848. */
  65849. static CreateTorus(name: string, options: {
  65850. diameter?: number;
  65851. thickness?: number;
  65852. tessellation?: number;
  65853. updatable?: boolean;
  65854. sideOrientation?: number;
  65855. frontUVs?: Vector4;
  65856. backUVs?: Vector4;
  65857. }, scene?: Nullable<Scene>): Mesh;
  65858. /**
  65859. * Creates a torus knot mesh
  65860. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65861. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65862. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65863. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65865. * * 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
  65866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65867. * @param name defines the name of the mesh
  65868. * @param options defines the options used to create the mesh
  65869. * @param scene defines the hosting scene
  65870. * @returns the torus knot mesh
  65871. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65872. */
  65873. static CreateTorusKnot(name: string, options: {
  65874. radius?: number;
  65875. tube?: number;
  65876. radialSegments?: number;
  65877. tubularSegments?: number;
  65878. p?: number;
  65879. q?: number;
  65880. updatable?: boolean;
  65881. sideOrientation?: number;
  65882. frontUVs?: Vector4;
  65883. backUVs?: Vector4;
  65884. }, scene?: Nullable<Scene>): Mesh;
  65885. /**
  65886. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65887. * * 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
  65888. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65889. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65890. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65891. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65892. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65893. * * 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
  65894. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65896. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65897. * @param name defines the name of the new line system
  65898. * @param options defines the options used to create the line system
  65899. * @param scene defines the hosting scene
  65900. * @returns a new line system mesh
  65901. */
  65902. static CreateLineSystem(name: string, options: {
  65903. lines: Vector3[][];
  65904. updatable?: boolean;
  65905. instance?: Nullable<LinesMesh>;
  65906. colors?: Nullable<Color4[][]>;
  65907. useVertexAlpha?: boolean;
  65908. }, scene: Nullable<Scene>): LinesMesh;
  65909. /**
  65910. * Creates a line mesh
  65911. * 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
  65912. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65913. * * The parameter `points` is an array successive Vector3
  65914. * * 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
  65915. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65916. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65917. * * When updating an instance, remember that only point positions can change, not the number of points
  65918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65919. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65920. * @param name defines the name of the new line system
  65921. * @param options defines the options used to create the line system
  65922. * @param scene defines the hosting scene
  65923. * @returns a new line mesh
  65924. */
  65925. static CreateLines(name: string, options: {
  65926. points: Vector3[];
  65927. updatable?: boolean;
  65928. instance?: Nullable<LinesMesh>;
  65929. colors?: Color4[];
  65930. useVertexAlpha?: boolean;
  65931. }, scene?: Nullable<Scene>): LinesMesh;
  65932. /**
  65933. * Creates a dashed line mesh
  65934. * * 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
  65935. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65936. * * The parameter `points` is an array successive Vector3
  65937. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65938. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65939. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65940. * * 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
  65941. * * When updating an instance, remember that only point positions can change, not the number of points
  65942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65943. * @param name defines the name of the mesh
  65944. * @param options defines the options used to create the mesh
  65945. * @param scene defines the hosting scene
  65946. * @returns the dashed line mesh
  65947. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65948. */
  65949. static CreateDashedLines(name: string, options: {
  65950. points: Vector3[];
  65951. dashSize?: number;
  65952. gapSize?: number;
  65953. dashNb?: number;
  65954. updatable?: boolean;
  65955. instance?: LinesMesh;
  65956. }, scene?: Nullable<Scene>): LinesMesh;
  65957. /**
  65958. * 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.
  65959. * * 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.
  65960. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65961. * * 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.
  65962. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65963. * * 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
  65964. * * 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
  65965. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65968. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65970. * @param name defines the name of the mesh
  65971. * @param options defines the options used to create the mesh
  65972. * @param scene defines the hosting scene
  65973. * @returns the extruded shape mesh
  65974. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65975. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65976. */
  65977. static ExtrudeShape(name: string, options: {
  65978. shape: Vector3[];
  65979. path: Vector3[];
  65980. scale?: number;
  65981. rotation?: number;
  65982. cap?: number;
  65983. updatable?: boolean;
  65984. sideOrientation?: number;
  65985. frontUVs?: Vector4;
  65986. backUVs?: Vector4;
  65987. instance?: Mesh;
  65988. invertUV?: boolean;
  65989. }, scene?: Nullable<Scene>): Mesh;
  65990. /**
  65991. * Creates an custom extruded shape mesh.
  65992. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65993. * * 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.
  65994. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65995. * * 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
  65996. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65997. * * 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
  65998. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65999. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66000. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66001. * * 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
  66002. * * 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
  66003. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66005. * * 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
  66006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66008. * @param name defines the name of the mesh
  66009. * @param options defines the options used to create the mesh
  66010. * @param scene defines the hosting scene
  66011. * @returns the custom extruded shape mesh
  66012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66013. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66015. */
  66016. static ExtrudeShapeCustom(name: string, options: {
  66017. shape: Vector3[];
  66018. path: Vector3[];
  66019. scaleFunction?: any;
  66020. rotationFunction?: any;
  66021. ribbonCloseArray?: boolean;
  66022. ribbonClosePath?: boolean;
  66023. cap?: number;
  66024. updatable?: boolean;
  66025. sideOrientation?: number;
  66026. frontUVs?: Vector4;
  66027. backUVs?: Vector4;
  66028. instance?: Mesh;
  66029. invertUV?: boolean;
  66030. }, scene?: Nullable<Scene>): Mesh;
  66031. /**
  66032. * Creates lathe mesh.
  66033. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66034. * * 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
  66035. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66036. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66037. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66038. * * 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
  66039. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66040. * * 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
  66041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66042. * * 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
  66043. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66045. * @param name defines the name of the mesh
  66046. * @param options defines the options used to create the mesh
  66047. * @param scene defines the hosting scene
  66048. * @returns the lathe mesh
  66049. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66050. */
  66051. static CreateLathe(name: string, options: {
  66052. shape: Vector3[];
  66053. radius?: number;
  66054. tessellation?: number;
  66055. clip?: number;
  66056. arc?: number;
  66057. closed?: boolean;
  66058. updatable?: boolean;
  66059. sideOrientation?: number;
  66060. frontUVs?: Vector4;
  66061. backUVs?: Vector4;
  66062. cap?: number;
  66063. invertUV?: boolean;
  66064. }, scene?: Nullable<Scene>): Mesh;
  66065. /**
  66066. * Creates a tiled plane mesh
  66067. * * You can set a limited pattern arrangement with the tiles
  66068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66069. * * 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
  66070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66071. * @param name defines the name of the mesh
  66072. * @param options defines the options used to create the mesh
  66073. * @param scene defines the hosting scene
  66074. * @returns the plane mesh
  66075. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66076. */
  66077. static CreateTiledPlane(name: string, options: {
  66078. pattern?: number;
  66079. tileSize?: number;
  66080. tileWidth?: number;
  66081. tileHeight?: number;
  66082. size?: number;
  66083. width?: number;
  66084. height?: number;
  66085. alignHorizontal?: number;
  66086. alignVertical?: number;
  66087. sideOrientation?: number;
  66088. frontUVs?: Vector4;
  66089. backUVs?: Vector4;
  66090. updatable?: boolean;
  66091. }, scene?: Nullable<Scene>): Mesh;
  66092. /**
  66093. * Creates a plane mesh
  66094. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66095. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66096. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66098. * * 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
  66099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66100. * @param name defines the name of the mesh
  66101. * @param options defines the options used to create the mesh
  66102. * @param scene defines the hosting scene
  66103. * @returns the plane mesh
  66104. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66105. */
  66106. static CreatePlane(name: string, options: {
  66107. size?: number;
  66108. width?: number;
  66109. height?: number;
  66110. sideOrientation?: number;
  66111. frontUVs?: Vector4;
  66112. backUVs?: Vector4;
  66113. updatable?: boolean;
  66114. sourcePlane?: Plane;
  66115. }, scene?: Nullable<Scene>): Mesh;
  66116. /**
  66117. * Creates a ground mesh
  66118. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66119. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66121. * @param name defines the name of the mesh
  66122. * @param options defines the options used to create the mesh
  66123. * @param scene defines the hosting scene
  66124. * @returns the ground mesh
  66125. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66126. */
  66127. static CreateGround(name: string, options: {
  66128. width?: number;
  66129. height?: number;
  66130. subdivisions?: number;
  66131. subdivisionsX?: number;
  66132. subdivisionsY?: number;
  66133. updatable?: boolean;
  66134. }, scene?: Nullable<Scene>): Mesh;
  66135. /**
  66136. * Creates a tiled ground mesh
  66137. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66138. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66139. * * 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
  66140. * * 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
  66141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66142. * @param name defines the name of the mesh
  66143. * @param options defines the options used to create the mesh
  66144. * @param scene defines the hosting scene
  66145. * @returns the tiled ground mesh
  66146. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66147. */
  66148. static CreateTiledGround(name: string, options: {
  66149. xmin: number;
  66150. zmin: number;
  66151. xmax: number;
  66152. zmax: number;
  66153. subdivisions?: {
  66154. w: number;
  66155. h: number;
  66156. };
  66157. precision?: {
  66158. w: number;
  66159. h: number;
  66160. };
  66161. updatable?: boolean;
  66162. }, scene?: Nullable<Scene>): Mesh;
  66163. /**
  66164. * Creates a ground mesh from a height map
  66165. * * The parameter `url` sets the URL of the height map image resource.
  66166. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66167. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66168. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66169. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66170. * * 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.
  66171. * * 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).
  66172. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66174. * @param name defines the name of the mesh
  66175. * @param url defines the url to the height map
  66176. * @param options defines the options used to create the mesh
  66177. * @param scene defines the hosting scene
  66178. * @returns the ground mesh
  66179. * @see https://doc.babylonjs.com/babylon101/height_map
  66180. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66181. */
  66182. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66183. width?: number;
  66184. height?: number;
  66185. subdivisions?: number;
  66186. minHeight?: number;
  66187. maxHeight?: number;
  66188. colorFilter?: Color3;
  66189. alphaFilter?: number;
  66190. updatable?: boolean;
  66191. onReady?: (mesh: GroundMesh) => void;
  66192. }, scene?: Nullable<Scene>): GroundMesh;
  66193. /**
  66194. * Creates a polygon mesh
  66195. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66196. * * 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
  66197. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66199. * * 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)
  66200. * * Remember you can only change the shape positions, not their number when updating a polygon
  66201. * @param name defines the name of the mesh
  66202. * @param options defines the options used to create the mesh
  66203. * @param scene defines the hosting scene
  66204. * @param earcutInjection can be used to inject your own earcut reference
  66205. * @returns the polygon mesh
  66206. */
  66207. static CreatePolygon(name: string, options: {
  66208. shape: Vector3[];
  66209. holes?: Vector3[][];
  66210. depth?: number;
  66211. faceUV?: Vector4[];
  66212. faceColors?: Color4[];
  66213. updatable?: boolean;
  66214. sideOrientation?: number;
  66215. frontUVs?: Vector4;
  66216. backUVs?: Vector4;
  66217. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66218. /**
  66219. * Creates an extruded polygon mesh, with depth in the Y direction.
  66220. * * 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)
  66221. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66222. * @param name defines the name of the mesh
  66223. * @param options defines the options used to create the mesh
  66224. * @param scene defines the hosting scene
  66225. * @param earcutInjection can be used to inject your own earcut reference
  66226. * @returns the polygon mesh
  66227. */
  66228. static ExtrudePolygon(name: string, options: {
  66229. shape: Vector3[];
  66230. holes?: Vector3[][];
  66231. depth?: number;
  66232. faceUV?: Vector4[];
  66233. faceColors?: Color4[];
  66234. updatable?: boolean;
  66235. sideOrientation?: number;
  66236. frontUVs?: Vector4;
  66237. backUVs?: Vector4;
  66238. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66239. /**
  66240. * Creates a tube mesh.
  66241. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66242. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66243. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66244. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66245. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66246. * * 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)
  66247. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66248. * * 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
  66249. * * 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
  66250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66251. * * 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
  66252. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66254. * @param name defines the name of the mesh
  66255. * @param options defines the options used to create the mesh
  66256. * @param scene defines the hosting scene
  66257. * @returns the tube mesh
  66258. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66259. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66260. */
  66261. static CreateTube(name: string, options: {
  66262. path: Vector3[];
  66263. radius?: number;
  66264. tessellation?: number;
  66265. radiusFunction?: {
  66266. (i: number, distance: number): number;
  66267. };
  66268. cap?: number;
  66269. arc?: number;
  66270. updatable?: boolean;
  66271. sideOrientation?: number;
  66272. frontUVs?: Vector4;
  66273. backUVs?: Vector4;
  66274. instance?: Mesh;
  66275. invertUV?: boolean;
  66276. }, scene?: Nullable<Scene>): Mesh;
  66277. /**
  66278. * Creates a polyhedron mesh
  66279. * * 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
  66280. * * The parameter `size` (positive float, default 1) sets the polygon size
  66281. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66282. * * 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`
  66283. * * 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
  66284. * * 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)`)
  66285. * * 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
  66286. * * 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
  66287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66288. * * 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
  66289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66290. * @param name defines the name of the mesh
  66291. * @param options defines the options used to create the mesh
  66292. * @param scene defines the hosting scene
  66293. * @returns the polyhedron mesh
  66294. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66295. */
  66296. static CreatePolyhedron(name: string, options: {
  66297. type?: number;
  66298. size?: number;
  66299. sizeX?: number;
  66300. sizeY?: number;
  66301. sizeZ?: number;
  66302. custom?: any;
  66303. faceUV?: Vector4[];
  66304. faceColors?: Color4[];
  66305. flat?: boolean;
  66306. updatable?: boolean;
  66307. sideOrientation?: number;
  66308. frontUVs?: Vector4;
  66309. backUVs?: Vector4;
  66310. }, scene?: Nullable<Scene>): Mesh;
  66311. /**
  66312. * Creates a decal mesh.
  66313. * 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
  66314. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66315. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66316. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66317. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66318. * @param name defines the name of the mesh
  66319. * @param sourceMesh defines the mesh where the decal must be applied
  66320. * @param options defines the options used to create the mesh
  66321. * @param scene defines the hosting scene
  66322. * @returns the decal mesh
  66323. * @see https://doc.babylonjs.com/how_to/decals
  66324. */
  66325. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66326. position?: Vector3;
  66327. normal?: Vector3;
  66328. size?: Vector3;
  66329. angle?: number;
  66330. }): Mesh;
  66331. }
  66332. }
  66333. declare module BABYLON {
  66334. /**
  66335. * A simplifier interface for future simplification implementations
  66336. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66337. */
  66338. export interface ISimplifier {
  66339. /**
  66340. * Simplification of a given mesh according to the given settings.
  66341. * Since this requires computation, it is assumed that the function runs async.
  66342. * @param settings The settings of the simplification, including quality and distance
  66343. * @param successCallback A callback that will be called after the mesh was simplified.
  66344. * @param errorCallback in case of an error, this callback will be called. optional.
  66345. */
  66346. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66347. }
  66348. /**
  66349. * Expected simplification settings.
  66350. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66351. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66352. */
  66353. export interface ISimplificationSettings {
  66354. /**
  66355. * Gets or sets the expected quality
  66356. */
  66357. quality: number;
  66358. /**
  66359. * Gets or sets the distance when this optimized version should be used
  66360. */
  66361. distance: number;
  66362. /**
  66363. * Gets an already optimized mesh
  66364. */
  66365. optimizeMesh?: boolean;
  66366. }
  66367. /**
  66368. * Class used to specify simplification options
  66369. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66370. */
  66371. export class SimplificationSettings implements ISimplificationSettings {
  66372. /** expected quality */
  66373. quality: number;
  66374. /** distance when this optimized version should be used */
  66375. distance: number;
  66376. /** already optimized mesh */
  66377. optimizeMesh?: boolean | undefined;
  66378. /**
  66379. * Creates a SimplificationSettings
  66380. * @param quality expected quality
  66381. * @param distance distance when this optimized version should be used
  66382. * @param optimizeMesh already optimized mesh
  66383. */
  66384. constructor(
  66385. /** expected quality */
  66386. quality: number,
  66387. /** distance when this optimized version should be used */
  66388. distance: number,
  66389. /** already optimized mesh */
  66390. optimizeMesh?: boolean | undefined);
  66391. }
  66392. /**
  66393. * Interface used to define a simplification task
  66394. */
  66395. export interface ISimplificationTask {
  66396. /**
  66397. * Array of settings
  66398. */
  66399. settings: Array<ISimplificationSettings>;
  66400. /**
  66401. * Simplification type
  66402. */
  66403. simplificationType: SimplificationType;
  66404. /**
  66405. * Mesh to simplify
  66406. */
  66407. mesh: Mesh;
  66408. /**
  66409. * Callback called on success
  66410. */
  66411. successCallback?: () => void;
  66412. /**
  66413. * Defines if parallel processing can be used
  66414. */
  66415. parallelProcessing: boolean;
  66416. }
  66417. /**
  66418. * Queue used to order the simplification tasks
  66419. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66420. */
  66421. export class SimplificationQueue {
  66422. private _simplificationArray;
  66423. /**
  66424. * Gets a boolean indicating that the process is still running
  66425. */
  66426. running: boolean;
  66427. /**
  66428. * Creates a new queue
  66429. */
  66430. constructor();
  66431. /**
  66432. * Adds a new simplification task
  66433. * @param task defines a task to add
  66434. */
  66435. addTask(task: ISimplificationTask): void;
  66436. /**
  66437. * Execute next task
  66438. */
  66439. executeNext(): void;
  66440. /**
  66441. * Execute a simplification task
  66442. * @param task defines the task to run
  66443. */
  66444. runSimplification(task: ISimplificationTask): void;
  66445. private getSimplifier;
  66446. }
  66447. /**
  66448. * The implemented types of simplification
  66449. * At the moment only Quadratic Error Decimation is implemented
  66450. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66451. */
  66452. export enum SimplificationType {
  66453. /** Quadratic error decimation */
  66454. QUADRATIC = 0
  66455. }
  66456. /**
  66457. * An implementation of the Quadratic Error simplification algorithm.
  66458. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66459. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66460. * @author RaananW
  66461. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66462. */
  66463. export class QuadraticErrorSimplification implements ISimplifier {
  66464. private _mesh;
  66465. private triangles;
  66466. private vertices;
  66467. private references;
  66468. private _reconstructedMesh;
  66469. /** Gets or sets the number pf sync interations */
  66470. syncIterations: number;
  66471. /** Gets or sets the aggressiveness of the simplifier */
  66472. aggressiveness: number;
  66473. /** Gets or sets the number of allowed iterations for decimation */
  66474. decimationIterations: number;
  66475. /** Gets or sets the espilon to use for bounding box computation */
  66476. boundingBoxEpsilon: number;
  66477. /**
  66478. * Creates a new QuadraticErrorSimplification
  66479. * @param _mesh defines the target mesh
  66480. */
  66481. constructor(_mesh: Mesh);
  66482. /**
  66483. * Simplification of a given mesh according to the given settings.
  66484. * Since this requires computation, it is assumed that the function runs async.
  66485. * @param settings The settings of the simplification, including quality and distance
  66486. * @param successCallback A callback that will be called after the mesh was simplified.
  66487. */
  66488. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66489. private runDecimation;
  66490. private initWithMesh;
  66491. private init;
  66492. private reconstructMesh;
  66493. private initDecimatedMesh;
  66494. private isFlipped;
  66495. private updateTriangles;
  66496. private identifyBorder;
  66497. private updateMesh;
  66498. private vertexError;
  66499. private calculateError;
  66500. }
  66501. }
  66502. declare module BABYLON {
  66503. interface Scene {
  66504. /** @hidden (Backing field) */
  66505. _simplificationQueue: SimplificationQueue;
  66506. /**
  66507. * Gets or sets the simplification queue attached to the scene
  66508. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66509. */
  66510. simplificationQueue: SimplificationQueue;
  66511. }
  66512. interface Mesh {
  66513. /**
  66514. * Simplify the mesh according to the given array of settings.
  66515. * Function will return immediately and will simplify async
  66516. * @param settings a collection of simplification settings
  66517. * @param parallelProcessing should all levels calculate parallel or one after the other
  66518. * @param simplificationType the type of simplification to run
  66519. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66520. * @returns the current mesh
  66521. */
  66522. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66523. }
  66524. /**
  66525. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66526. * created in a scene
  66527. */
  66528. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66529. /**
  66530. * The component name helpfull to identify the component in the list of scene components.
  66531. */
  66532. readonly name: string;
  66533. /**
  66534. * The scene the component belongs to.
  66535. */
  66536. scene: Scene;
  66537. /**
  66538. * Creates a new instance of the component for the given scene
  66539. * @param scene Defines the scene to register the component in
  66540. */
  66541. constructor(scene: Scene);
  66542. /**
  66543. * Registers the component in a given scene
  66544. */
  66545. register(): void;
  66546. /**
  66547. * Rebuilds the elements related to this component in case of
  66548. * context lost for instance.
  66549. */
  66550. rebuild(): void;
  66551. /**
  66552. * Disposes the component and the associated ressources
  66553. */
  66554. dispose(): void;
  66555. private _beforeCameraUpdate;
  66556. }
  66557. }
  66558. declare module BABYLON {
  66559. interface Mesh {
  66560. /**
  66561. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66562. */
  66563. thinInstanceEnablePicking: boolean;
  66564. /**
  66565. * Creates a new thin instance
  66566. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66567. * @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
  66568. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66569. */
  66570. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66571. /**
  66572. * Adds the transformation (matrix) of the current mesh as a thin instance
  66573. * @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
  66574. * @returns the thin instance index number
  66575. */
  66576. thinInstanceAddSelf(refresh: boolean): number;
  66577. /**
  66578. * Registers a custom attribute to be used with thin instances
  66579. * @param kind name of the attribute
  66580. * @param stride size in floats of the attribute
  66581. */
  66582. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66583. /**
  66584. * Sets the matrix of a thin instance
  66585. * @param index index of the thin instance
  66586. * @param matrix matrix to set
  66587. * @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
  66588. */
  66589. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66590. /**
  66591. * Sets the value of a custom attribute for a thin instance
  66592. * @param kind name of the attribute
  66593. * @param index index of the thin instance
  66594. * @param value value to set
  66595. * @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
  66596. */
  66597. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66598. /**
  66599. * 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.
  66600. */
  66601. thinInstanceCount: number;
  66602. /**
  66603. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66604. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66605. * @param buffer buffer to set
  66606. * @param stride size in floats of each value of the buffer
  66607. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66608. */
  66609. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66610. /**
  66611. * Gets the list of world matrices
  66612. * @return an array containing all the world matrices from the thin instances
  66613. */
  66614. thinInstanceGetWorldMatrices(): Matrix[];
  66615. /**
  66616. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66617. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66618. */
  66619. thinInstanceBufferUpdated(kind: string): void;
  66620. /**
  66621. * Refreshes the bounding info, taking into account all the thin instances defined
  66622. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66623. */
  66624. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66625. /** @hidden */
  66626. _thinInstanceInitializeUserStorage(): void;
  66627. /** @hidden */
  66628. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66629. /** @hidden */
  66630. _userThinInstanceBuffersStorage: {
  66631. data: {
  66632. [key: string]: Float32Array;
  66633. };
  66634. sizes: {
  66635. [key: string]: number;
  66636. };
  66637. vertexBuffers: {
  66638. [key: string]: Nullable<VertexBuffer>;
  66639. };
  66640. strides: {
  66641. [key: string]: number;
  66642. };
  66643. };
  66644. }
  66645. }
  66646. declare module BABYLON {
  66647. /**
  66648. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66649. */
  66650. export interface INavigationEnginePlugin {
  66651. /**
  66652. * plugin name
  66653. */
  66654. name: string;
  66655. /**
  66656. * Creates a navigation mesh
  66657. * @param meshes array of all the geometry used to compute the navigatio mesh
  66658. * @param parameters bunch of parameters used to filter geometry
  66659. */
  66660. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66661. /**
  66662. * Create a navigation mesh debug mesh
  66663. * @param scene is where the mesh will be added
  66664. * @returns debug display mesh
  66665. */
  66666. createDebugNavMesh(scene: Scene): Mesh;
  66667. /**
  66668. * Get a navigation mesh constrained position, closest to the parameter position
  66669. * @param position world position
  66670. * @returns the closest point to position constrained by the navigation mesh
  66671. */
  66672. getClosestPoint(position: Vector3): Vector3;
  66673. /**
  66674. * Get a navigation mesh constrained position, closest to the parameter position
  66675. * @param position world position
  66676. * @param result output the closest point to position constrained by the navigation mesh
  66677. */
  66678. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66679. /**
  66680. * Get a navigation mesh constrained position, within a particular radius
  66681. * @param position world position
  66682. * @param maxRadius the maximum distance to the constrained world position
  66683. * @returns the closest point to position constrained by the navigation mesh
  66684. */
  66685. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66686. /**
  66687. * Get a navigation mesh constrained position, within a particular radius
  66688. * @param position world position
  66689. * @param maxRadius the maximum distance to the constrained world position
  66690. * @param result output the closest point to position constrained by the navigation mesh
  66691. */
  66692. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66693. /**
  66694. * Compute the final position from a segment made of destination-position
  66695. * @param position world position
  66696. * @param destination world position
  66697. * @returns the resulting point along the navmesh
  66698. */
  66699. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66700. /**
  66701. * Compute the final position from a segment made of destination-position
  66702. * @param position world position
  66703. * @param destination world position
  66704. * @param result output the resulting point along the navmesh
  66705. */
  66706. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66707. /**
  66708. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66709. * @param start world position
  66710. * @param end world position
  66711. * @returns array containing world position composing the path
  66712. */
  66713. computePath(start: Vector3, end: Vector3): Vector3[];
  66714. /**
  66715. * If this plugin is supported
  66716. * @returns true if plugin is supported
  66717. */
  66718. isSupported(): boolean;
  66719. /**
  66720. * Create a new Crowd so you can add agents
  66721. * @param maxAgents the maximum agent count in the crowd
  66722. * @param maxAgentRadius the maximum radius an agent can have
  66723. * @param scene to attach the crowd to
  66724. * @returns the crowd you can add agents to
  66725. */
  66726. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66727. /**
  66728. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66729. * The queries will try to find a solution within those bounds
  66730. * default is (1,1,1)
  66731. * @param extent x,y,z value that define the extent around the queries point of reference
  66732. */
  66733. setDefaultQueryExtent(extent: Vector3): void;
  66734. /**
  66735. * Get the Bounding box extent specified by setDefaultQueryExtent
  66736. * @returns the box extent values
  66737. */
  66738. getDefaultQueryExtent(): Vector3;
  66739. /**
  66740. * build the navmesh from a previously saved state using getNavmeshData
  66741. * @param data the Uint8Array returned by getNavmeshData
  66742. */
  66743. buildFromNavmeshData(data: Uint8Array): void;
  66744. /**
  66745. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66746. * @returns data the Uint8Array that can be saved and reused
  66747. */
  66748. getNavmeshData(): Uint8Array;
  66749. /**
  66750. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66751. * @param result output the box extent values
  66752. */
  66753. getDefaultQueryExtentToRef(result: Vector3): void;
  66754. /**
  66755. * Release all resources
  66756. */
  66757. dispose(): void;
  66758. }
  66759. /**
  66760. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66761. */
  66762. export interface ICrowd {
  66763. /**
  66764. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66765. * You can attach anything to that node. The node position is updated in the scene update tick.
  66766. * @param pos world position that will be constrained by the navigation mesh
  66767. * @param parameters agent parameters
  66768. * @param transform hooked to the agent that will be update by the scene
  66769. * @returns agent index
  66770. */
  66771. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66772. /**
  66773. * Returns the agent position in world space
  66774. * @param index agent index returned by addAgent
  66775. * @returns world space position
  66776. */
  66777. getAgentPosition(index: number): Vector3;
  66778. /**
  66779. * Gets the agent position result in world space
  66780. * @param index agent index returned by addAgent
  66781. * @param result output world space position
  66782. */
  66783. getAgentPositionToRef(index: number, result: Vector3): void;
  66784. /**
  66785. * Gets the agent velocity in world space
  66786. * @param index agent index returned by addAgent
  66787. * @returns world space velocity
  66788. */
  66789. getAgentVelocity(index: number): Vector3;
  66790. /**
  66791. * Gets the agent velocity result in world space
  66792. * @param index agent index returned by addAgent
  66793. * @param result output world space velocity
  66794. */
  66795. getAgentVelocityToRef(index: number, result: Vector3): void;
  66796. /**
  66797. * remove a particular agent previously created
  66798. * @param index agent index returned by addAgent
  66799. */
  66800. removeAgent(index: number): void;
  66801. /**
  66802. * get the list of all agents attached to this crowd
  66803. * @returns list of agent indices
  66804. */
  66805. getAgents(): number[];
  66806. /**
  66807. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66808. * @param deltaTime in seconds
  66809. */
  66810. update(deltaTime: number): void;
  66811. /**
  66812. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66813. * @param index agent index returned by addAgent
  66814. * @param destination targeted world position
  66815. */
  66816. agentGoto(index: number, destination: Vector3): void;
  66817. /**
  66818. * Teleport the agent to a new position
  66819. * @param index agent index returned by addAgent
  66820. * @param destination targeted world position
  66821. */
  66822. agentTeleport(index: number, destination: Vector3): void;
  66823. /**
  66824. * Update agent parameters
  66825. * @param index agent index returned by addAgent
  66826. * @param parameters agent parameters
  66827. */
  66828. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66829. /**
  66830. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66831. * The queries will try to find a solution within those bounds
  66832. * default is (1,1,1)
  66833. * @param extent x,y,z value that define the extent around the queries point of reference
  66834. */
  66835. setDefaultQueryExtent(extent: Vector3): void;
  66836. /**
  66837. * Get the Bounding box extent specified by setDefaultQueryExtent
  66838. * @returns the box extent values
  66839. */
  66840. getDefaultQueryExtent(): Vector3;
  66841. /**
  66842. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66843. * @param result output the box extent values
  66844. */
  66845. getDefaultQueryExtentToRef(result: Vector3): void;
  66846. /**
  66847. * Release all resources
  66848. */
  66849. dispose(): void;
  66850. }
  66851. /**
  66852. * Configures an agent
  66853. */
  66854. export interface IAgentParameters {
  66855. /**
  66856. * Agent radius. [Limit: >= 0]
  66857. */
  66858. radius: number;
  66859. /**
  66860. * Agent height. [Limit: > 0]
  66861. */
  66862. height: number;
  66863. /**
  66864. * Maximum allowed acceleration. [Limit: >= 0]
  66865. */
  66866. maxAcceleration: number;
  66867. /**
  66868. * Maximum allowed speed. [Limit: >= 0]
  66869. */
  66870. maxSpeed: number;
  66871. /**
  66872. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66873. */
  66874. collisionQueryRange: number;
  66875. /**
  66876. * The path visibility optimization range. [Limit: > 0]
  66877. */
  66878. pathOptimizationRange: number;
  66879. /**
  66880. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66881. */
  66882. separationWeight: number;
  66883. }
  66884. /**
  66885. * Configures the navigation mesh creation
  66886. */
  66887. export interface INavMeshParameters {
  66888. /**
  66889. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66890. */
  66891. cs: number;
  66892. /**
  66893. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66894. */
  66895. ch: number;
  66896. /**
  66897. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66898. */
  66899. walkableSlopeAngle: number;
  66900. /**
  66901. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66902. * be considered walkable. [Limit: >= 3] [Units: vx]
  66903. */
  66904. walkableHeight: number;
  66905. /**
  66906. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66907. */
  66908. walkableClimb: number;
  66909. /**
  66910. * The distance to erode/shrink the walkable area of the heightfield away from
  66911. * obstructions. [Limit: >=0] [Units: vx]
  66912. */
  66913. walkableRadius: number;
  66914. /**
  66915. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66916. */
  66917. maxEdgeLen: number;
  66918. /**
  66919. * The maximum distance a simplfied contour's border edges should deviate
  66920. * the original raw contour. [Limit: >=0] [Units: vx]
  66921. */
  66922. maxSimplificationError: number;
  66923. /**
  66924. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66925. */
  66926. minRegionArea: number;
  66927. /**
  66928. * Any regions with a span count smaller than this value will, if possible,
  66929. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66930. */
  66931. mergeRegionArea: number;
  66932. /**
  66933. * The maximum number of vertices allowed for polygons generated during the
  66934. * contour to polygon conversion process. [Limit: >= 3]
  66935. */
  66936. maxVertsPerPoly: number;
  66937. /**
  66938. * Sets the sampling distance to use when generating the detail mesh.
  66939. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66940. */
  66941. detailSampleDist: number;
  66942. /**
  66943. * The maximum distance the detail mesh surface should deviate from heightfield
  66944. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66945. */
  66946. detailSampleMaxError: number;
  66947. }
  66948. }
  66949. declare module BABYLON {
  66950. /**
  66951. * RecastJS navigation plugin
  66952. */
  66953. export class RecastJSPlugin implements INavigationEnginePlugin {
  66954. /**
  66955. * Reference to the Recast library
  66956. */
  66957. bjsRECAST: any;
  66958. /**
  66959. * plugin name
  66960. */
  66961. name: string;
  66962. /**
  66963. * the first navmesh created. We might extend this to support multiple navmeshes
  66964. */
  66965. navMesh: any;
  66966. /**
  66967. * Initializes the recastJS plugin
  66968. * @param recastInjection can be used to inject your own recast reference
  66969. */
  66970. constructor(recastInjection?: any);
  66971. /**
  66972. * Creates a navigation mesh
  66973. * @param meshes array of all the geometry used to compute the navigatio mesh
  66974. * @param parameters bunch of parameters used to filter geometry
  66975. */
  66976. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66977. /**
  66978. * Create a navigation mesh debug mesh
  66979. * @param scene is where the mesh will be added
  66980. * @returns debug display mesh
  66981. */
  66982. createDebugNavMesh(scene: Scene): Mesh;
  66983. /**
  66984. * Get a navigation mesh constrained position, closest to the parameter position
  66985. * @param position world position
  66986. * @returns the closest point to position constrained by the navigation mesh
  66987. */
  66988. getClosestPoint(position: Vector3): Vector3;
  66989. /**
  66990. * Get a navigation mesh constrained position, closest to the parameter position
  66991. * @param position world position
  66992. * @param result output the closest point to position constrained by the navigation mesh
  66993. */
  66994. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66995. /**
  66996. * Get a navigation mesh constrained position, within a particular radius
  66997. * @param position world position
  66998. * @param maxRadius the maximum distance to the constrained world position
  66999. * @returns the closest point to position constrained by the navigation mesh
  67000. */
  67001. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67002. /**
  67003. * Get a navigation mesh constrained position, within a particular radius
  67004. * @param position world position
  67005. * @param maxRadius the maximum distance to the constrained world position
  67006. * @param result output the closest point to position constrained by the navigation mesh
  67007. */
  67008. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67009. /**
  67010. * Compute the final position from a segment made of destination-position
  67011. * @param position world position
  67012. * @param destination world position
  67013. * @returns the resulting point along the navmesh
  67014. */
  67015. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67016. /**
  67017. * Compute the final position from a segment made of destination-position
  67018. * @param position world position
  67019. * @param destination world position
  67020. * @param result output the resulting point along the navmesh
  67021. */
  67022. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67023. /**
  67024. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67025. * @param start world position
  67026. * @param end world position
  67027. * @returns array containing world position composing the path
  67028. */
  67029. computePath(start: Vector3, end: Vector3): Vector3[];
  67030. /**
  67031. * Create a new Crowd so you can add agents
  67032. * @param maxAgents the maximum agent count in the crowd
  67033. * @param maxAgentRadius the maximum radius an agent can have
  67034. * @param scene to attach the crowd to
  67035. * @returns the crowd you can add agents to
  67036. */
  67037. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67038. /**
  67039. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67040. * The queries will try to find a solution within those bounds
  67041. * default is (1,1,1)
  67042. * @param extent x,y,z value that define the extent around the queries point of reference
  67043. */
  67044. setDefaultQueryExtent(extent: Vector3): void;
  67045. /**
  67046. * Get the Bounding box extent specified by setDefaultQueryExtent
  67047. * @returns the box extent values
  67048. */
  67049. getDefaultQueryExtent(): Vector3;
  67050. /**
  67051. * build the navmesh from a previously saved state using getNavmeshData
  67052. * @param data the Uint8Array returned by getNavmeshData
  67053. */
  67054. buildFromNavmeshData(data: Uint8Array): void;
  67055. /**
  67056. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67057. * @returns data the Uint8Array that can be saved and reused
  67058. */
  67059. getNavmeshData(): Uint8Array;
  67060. /**
  67061. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67062. * @param result output the box extent values
  67063. */
  67064. getDefaultQueryExtentToRef(result: Vector3): void;
  67065. /**
  67066. * Disposes
  67067. */
  67068. dispose(): void;
  67069. /**
  67070. * If this plugin is supported
  67071. * @returns true if plugin is supported
  67072. */
  67073. isSupported(): boolean;
  67074. }
  67075. /**
  67076. * Recast detour crowd implementation
  67077. */
  67078. export class RecastJSCrowd implements ICrowd {
  67079. /**
  67080. * Recast/detour plugin
  67081. */
  67082. bjsRECASTPlugin: RecastJSPlugin;
  67083. /**
  67084. * Link to the detour crowd
  67085. */
  67086. recastCrowd: any;
  67087. /**
  67088. * One transform per agent
  67089. */
  67090. transforms: TransformNode[];
  67091. /**
  67092. * All agents created
  67093. */
  67094. agents: number[];
  67095. /**
  67096. * Link to the scene is kept to unregister the crowd from the scene
  67097. */
  67098. private _scene;
  67099. /**
  67100. * Observer for crowd updates
  67101. */
  67102. private _onBeforeAnimationsObserver;
  67103. /**
  67104. * Constructor
  67105. * @param plugin recastJS plugin
  67106. * @param maxAgents the maximum agent count in the crowd
  67107. * @param maxAgentRadius the maximum radius an agent can have
  67108. * @param scene to attach the crowd to
  67109. * @returns the crowd you can add agents to
  67110. */
  67111. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67112. /**
  67113. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67114. * You can attach anything to that node. The node position is updated in the scene update tick.
  67115. * @param pos world position that will be constrained by the navigation mesh
  67116. * @param parameters agent parameters
  67117. * @param transform hooked to the agent that will be update by the scene
  67118. * @returns agent index
  67119. */
  67120. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67121. /**
  67122. * Returns the agent position in world space
  67123. * @param index agent index returned by addAgent
  67124. * @returns world space position
  67125. */
  67126. getAgentPosition(index: number): Vector3;
  67127. /**
  67128. * Returns the agent position result in world space
  67129. * @param index agent index returned by addAgent
  67130. * @param result output world space position
  67131. */
  67132. getAgentPositionToRef(index: number, result: Vector3): void;
  67133. /**
  67134. * Returns the agent velocity in world space
  67135. * @param index agent index returned by addAgent
  67136. * @returns world space velocity
  67137. */
  67138. getAgentVelocity(index: number): Vector3;
  67139. /**
  67140. * Returns the agent velocity result in world space
  67141. * @param index agent index returned by addAgent
  67142. * @param result output world space velocity
  67143. */
  67144. getAgentVelocityToRef(index: number, result: Vector3): void;
  67145. /**
  67146. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67147. * @param index agent index returned by addAgent
  67148. * @param destination targeted world position
  67149. */
  67150. agentGoto(index: number, destination: Vector3): void;
  67151. /**
  67152. * Teleport the agent to a new position
  67153. * @param index agent index returned by addAgent
  67154. * @param destination targeted world position
  67155. */
  67156. agentTeleport(index: number, destination: Vector3): void;
  67157. /**
  67158. * Update agent parameters
  67159. * @param index agent index returned by addAgent
  67160. * @param parameters agent parameters
  67161. */
  67162. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67163. /**
  67164. * remove a particular agent previously created
  67165. * @param index agent index returned by addAgent
  67166. */
  67167. removeAgent(index: number): void;
  67168. /**
  67169. * get the list of all agents attached to this crowd
  67170. * @returns list of agent indices
  67171. */
  67172. getAgents(): number[];
  67173. /**
  67174. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67175. * @param deltaTime in seconds
  67176. */
  67177. update(deltaTime: number): void;
  67178. /**
  67179. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67180. * The queries will try to find a solution within those bounds
  67181. * default is (1,1,1)
  67182. * @param extent x,y,z value that define the extent around the queries point of reference
  67183. */
  67184. setDefaultQueryExtent(extent: Vector3): void;
  67185. /**
  67186. * Get the Bounding box extent specified by setDefaultQueryExtent
  67187. * @returns the box extent values
  67188. */
  67189. getDefaultQueryExtent(): Vector3;
  67190. /**
  67191. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67192. * @param result output the box extent values
  67193. */
  67194. getDefaultQueryExtentToRef(result: Vector3): void;
  67195. /**
  67196. * Release all resources
  67197. */
  67198. dispose(): void;
  67199. }
  67200. }
  67201. declare module BABYLON {
  67202. /**
  67203. * Class used to enable access to IndexedDB
  67204. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67205. */
  67206. export class Database implements IOfflineProvider {
  67207. private _callbackManifestChecked;
  67208. private _currentSceneUrl;
  67209. private _db;
  67210. private _enableSceneOffline;
  67211. private _enableTexturesOffline;
  67212. private _manifestVersionFound;
  67213. private _mustUpdateRessources;
  67214. private _hasReachedQuota;
  67215. private _isSupported;
  67216. private _idbFactory;
  67217. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67218. private static IsUASupportingBlobStorage;
  67219. /**
  67220. * Gets a boolean indicating if Database storate is enabled (off by default)
  67221. */
  67222. static IDBStorageEnabled: boolean;
  67223. /**
  67224. * Gets a boolean indicating if scene must be saved in the database
  67225. */
  67226. get enableSceneOffline(): boolean;
  67227. /**
  67228. * Gets a boolean indicating if textures must be saved in the database
  67229. */
  67230. get enableTexturesOffline(): boolean;
  67231. /**
  67232. * Creates a new Database
  67233. * @param urlToScene defines the url to load the scene
  67234. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67235. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67236. */
  67237. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67238. private static _ParseURL;
  67239. private static _ReturnFullUrlLocation;
  67240. private _checkManifestFile;
  67241. /**
  67242. * Open the database and make it available
  67243. * @param successCallback defines the callback to call on success
  67244. * @param errorCallback defines the callback to call on error
  67245. */
  67246. open(successCallback: () => void, errorCallback: () => void): void;
  67247. /**
  67248. * Loads an image from the database
  67249. * @param url defines the url to load from
  67250. * @param image defines the target DOM image
  67251. */
  67252. loadImage(url: string, image: HTMLImageElement): void;
  67253. private _loadImageFromDBAsync;
  67254. private _saveImageIntoDBAsync;
  67255. private _checkVersionFromDB;
  67256. private _loadVersionFromDBAsync;
  67257. private _saveVersionIntoDBAsync;
  67258. /**
  67259. * Loads a file from database
  67260. * @param url defines the URL to load from
  67261. * @param sceneLoaded defines a callback to call on success
  67262. * @param progressCallBack defines a callback to call when progress changed
  67263. * @param errorCallback defines a callback to call on error
  67264. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67265. */
  67266. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67267. private _loadFileAsync;
  67268. private _saveFileAsync;
  67269. /**
  67270. * Validates if xhr data is correct
  67271. * @param xhr defines the request to validate
  67272. * @param dataType defines the expected data type
  67273. * @returns true if data is correct
  67274. */
  67275. private static _ValidateXHRData;
  67276. }
  67277. }
  67278. declare module BABYLON {
  67279. /** @hidden */
  67280. export var gpuUpdateParticlesPixelShader: {
  67281. name: string;
  67282. shader: string;
  67283. };
  67284. }
  67285. declare module BABYLON {
  67286. /** @hidden */
  67287. export var gpuUpdateParticlesVertexShader: {
  67288. name: string;
  67289. shader: string;
  67290. };
  67291. }
  67292. declare module BABYLON {
  67293. /** @hidden */
  67294. export var clipPlaneFragmentDeclaration2: {
  67295. name: string;
  67296. shader: string;
  67297. };
  67298. }
  67299. declare module BABYLON {
  67300. /** @hidden */
  67301. export var gpuRenderParticlesPixelShader: {
  67302. name: string;
  67303. shader: string;
  67304. };
  67305. }
  67306. declare module BABYLON {
  67307. /** @hidden */
  67308. export var clipPlaneVertexDeclaration2: {
  67309. name: string;
  67310. shader: string;
  67311. };
  67312. }
  67313. declare module BABYLON {
  67314. /** @hidden */
  67315. export var gpuRenderParticlesVertexShader: {
  67316. name: string;
  67317. shader: string;
  67318. };
  67319. }
  67320. declare module BABYLON {
  67321. /**
  67322. * This represents a GPU particle system in Babylon
  67323. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67324. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67325. */
  67326. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67327. /**
  67328. * The layer mask we are rendering the particles through.
  67329. */
  67330. layerMask: number;
  67331. private _capacity;
  67332. private _activeCount;
  67333. private _currentActiveCount;
  67334. private _accumulatedCount;
  67335. private _renderEffect;
  67336. private _updateEffect;
  67337. private _buffer0;
  67338. private _buffer1;
  67339. private _spriteBuffer;
  67340. private _updateVAO;
  67341. private _renderVAO;
  67342. private _targetIndex;
  67343. private _sourceBuffer;
  67344. private _targetBuffer;
  67345. private _currentRenderId;
  67346. private _started;
  67347. private _stopped;
  67348. private _timeDelta;
  67349. private _randomTexture;
  67350. private _randomTexture2;
  67351. private _attributesStrideSize;
  67352. private _updateEffectOptions;
  67353. private _randomTextureSize;
  67354. private _actualFrame;
  67355. private _customEffect;
  67356. private readonly _rawTextureWidth;
  67357. /**
  67358. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67359. */
  67360. static get IsSupported(): boolean;
  67361. /**
  67362. * An event triggered when the system is disposed.
  67363. */
  67364. onDisposeObservable: Observable<IParticleSystem>;
  67365. /**
  67366. * Gets the maximum number of particles active at the same time.
  67367. * @returns The max number of active particles.
  67368. */
  67369. getCapacity(): number;
  67370. /**
  67371. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67372. * to override the particles.
  67373. */
  67374. forceDepthWrite: boolean;
  67375. /**
  67376. * Gets or set the number of active particles
  67377. */
  67378. get activeParticleCount(): number;
  67379. set activeParticleCount(value: number);
  67380. private _preWarmDone;
  67381. /**
  67382. * Specifies if the particles are updated in emitter local space or world space.
  67383. */
  67384. isLocal: boolean;
  67385. /** Gets or sets a matrix to use to compute projection */
  67386. defaultProjectionMatrix: Matrix;
  67387. /**
  67388. * Is this system ready to be used/rendered
  67389. * @return true if the system is ready
  67390. */
  67391. isReady(): boolean;
  67392. /**
  67393. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67394. * @returns True if it has been started, otherwise false.
  67395. */
  67396. isStarted(): boolean;
  67397. /**
  67398. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67399. * @returns True if it has been stopped, otherwise false.
  67400. */
  67401. isStopped(): boolean;
  67402. /**
  67403. * Gets a boolean indicating that the system is stopping
  67404. * @returns true if the system is currently stopping
  67405. */
  67406. isStopping(): boolean;
  67407. /**
  67408. * Gets the number of particles active at the same time.
  67409. * @returns The number of active particles.
  67410. */
  67411. getActiveCount(): number;
  67412. /**
  67413. * Starts the particle system and begins to emit
  67414. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67415. */
  67416. start(delay?: number): void;
  67417. /**
  67418. * Stops the particle system.
  67419. */
  67420. stop(): void;
  67421. /**
  67422. * Remove all active particles
  67423. */
  67424. reset(): void;
  67425. /**
  67426. * Returns the string "GPUParticleSystem"
  67427. * @returns a string containing the class name
  67428. */
  67429. getClassName(): string;
  67430. /**
  67431. * Gets the custom effect used to render the particles
  67432. * @param blendMode Blend mode for which the effect should be retrieved
  67433. * @returns The effect
  67434. */
  67435. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67436. /**
  67437. * Sets the custom effect used to render the particles
  67438. * @param effect The effect to set
  67439. * @param blendMode Blend mode for which the effect should be set
  67440. */
  67441. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67442. /** @hidden */
  67443. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67444. /**
  67445. * Observable that will be called just before the particles are drawn
  67446. */
  67447. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67448. /**
  67449. * Gets the name of the particle vertex shader
  67450. */
  67451. get vertexShaderName(): string;
  67452. private _colorGradientsTexture;
  67453. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67454. /**
  67455. * Adds a new color gradient
  67456. * @param gradient defines the gradient to use (between 0 and 1)
  67457. * @param color1 defines the color to affect to the specified gradient
  67458. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67459. * @returns the current particle system
  67460. */
  67461. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67462. private _refreshColorGradient;
  67463. /** Force the system to rebuild all gradients that need to be resync */
  67464. forceRefreshGradients(): void;
  67465. /**
  67466. * Remove a specific color gradient
  67467. * @param gradient defines the gradient to remove
  67468. * @returns the current particle system
  67469. */
  67470. removeColorGradient(gradient: number): GPUParticleSystem;
  67471. private _angularSpeedGradientsTexture;
  67472. private _sizeGradientsTexture;
  67473. private _velocityGradientsTexture;
  67474. private _limitVelocityGradientsTexture;
  67475. private _dragGradientsTexture;
  67476. private _addFactorGradient;
  67477. /**
  67478. * Adds a new size gradient
  67479. * @param gradient defines the gradient to use (between 0 and 1)
  67480. * @param factor defines the size factor to affect to the specified gradient
  67481. * @returns the current particle system
  67482. */
  67483. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67484. /**
  67485. * Remove a specific size gradient
  67486. * @param gradient defines the gradient to remove
  67487. * @returns the current particle system
  67488. */
  67489. removeSizeGradient(gradient: number): GPUParticleSystem;
  67490. private _refreshFactorGradient;
  67491. /**
  67492. * Adds a new angular speed gradient
  67493. * @param gradient defines the gradient to use (between 0 and 1)
  67494. * @param factor defines the angular speed to affect to the specified gradient
  67495. * @returns the current particle system
  67496. */
  67497. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67498. /**
  67499. * Remove a specific angular speed gradient
  67500. * @param gradient defines the gradient to remove
  67501. * @returns the current particle system
  67502. */
  67503. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67504. /**
  67505. * Adds a new velocity gradient
  67506. * @param gradient defines the gradient to use (between 0 and 1)
  67507. * @param factor defines the velocity to affect to the specified gradient
  67508. * @returns the current particle system
  67509. */
  67510. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67511. /**
  67512. * Remove a specific velocity gradient
  67513. * @param gradient defines the gradient to remove
  67514. * @returns the current particle system
  67515. */
  67516. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67517. /**
  67518. * Adds a new limit velocity gradient
  67519. * @param gradient defines the gradient to use (between 0 and 1)
  67520. * @param factor defines the limit velocity value to affect to the specified gradient
  67521. * @returns the current particle system
  67522. */
  67523. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67524. /**
  67525. * Remove a specific limit velocity gradient
  67526. * @param gradient defines the gradient to remove
  67527. * @returns the current particle system
  67528. */
  67529. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67530. /**
  67531. * Adds a new drag gradient
  67532. * @param gradient defines the gradient to use (between 0 and 1)
  67533. * @param factor defines the drag value to affect to the specified gradient
  67534. * @returns the current particle system
  67535. */
  67536. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67537. /**
  67538. * Remove a specific drag gradient
  67539. * @param gradient defines the gradient to remove
  67540. * @returns the current particle system
  67541. */
  67542. removeDragGradient(gradient: number): GPUParticleSystem;
  67543. /**
  67544. * Not supported by GPUParticleSystem
  67545. * @param gradient defines the gradient to use (between 0 and 1)
  67546. * @param factor defines the emit rate value to affect to the specified gradient
  67547. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67548. * @returns the current particle system
  67549. */
  67550. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67551. /**
  67552. * Not supported by GPUParticleSystem
  67553. * @param gradient defines the gradient to remove
  67554. * @returns the current particle system
  67555. */
  67556. removeEmitRateGradient(gradient: number): IParticleSystem;
  67557. /**
  67558. * Not supported by GPUParticleSystem
  67559. * @param gradient defines the gradient to use (between 0 and 1)
  67560. * @param factor defines the start size value to affect to the specified gradient
  67561. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67562. * @returns the current particle system
  67563. */
  67564. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67565. /**
  67566. * Not supported by GPUParticleSystem
  67567. * @param gradient defines the gradient to remove
  67568. * @returns the current particle system
  67569. */
  67570. removeStartSizeGradient(gradient: number): IParticleSystem;
  67571. /**
  67572. * Not supported by GPUParticleSystem
  67573. * @param gradient defines the gradient to use (between 0 and 1)
  67574. * @param min defines the color remap minimal range
  67575. * @param max defines the color remap maximal range
  67576. * @returns the current particle system
  67577. */
  67578. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67579. /**
  67580. * Not supported by GPUParticleSystem
  67581. * @param gradient defines the gradient to remove
  67582. * @returns the current particle system
  67583. */
  67584. removeColorRemapGradient(): IParticleSystem;
  67585. /**
  67586. * Not supported by GPUParticleSystem
  67587. * @param gradient defines the gradient to use (between 0 and 1)
  67588. * @param min defines the alpha remap minimal range
  67589. * @param max defines the alpha remap maximal range
  67590. * @returns the current particle system
  67591. */
  67592. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67593. /**
  67594. * Not supported by GPUParticleSystem
  67595. * @param gradient defines the gradient to remove
  67596. * @returns the current particle system
  67597. */
  67598. removeAlphaRemapGradient(): IParticleSystem;
  67599. /**
  67600. * Not supported by GPUParticleSystem
  67601. * @param gradient defines the gradient to use (between 0 and 1)
  67602. * @param color defines the color to affect to the specified gradient
  67603. * @returns the current particle system
  67604. */
  67605. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67606. /**
  67607. * Not supported by GPUParticleSystem
  67608. * @param gradient defines the gradient to remove
  67609. * @returns the current particle system
  67610. */
  67611. removeRampGradient(): IParticleSystem;
  67612. /**
  67613. * Not supported by GPUParticleSystem
  67614. * @returns the list of ramp gradients
  67615. */
  67616. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67617. /**
  67618. * Not supported by GPUParticleSystem
  67619. * Gets or sets a boolean indicating that ramp gradients must be used
  67620. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67621. */
  67622. get useRampGradients(): boolean;
  67623. set useRampGradients(value: boolean);
  67624. /**
  67625. * Not supported by GPUParticleSystem
  67626. * @param gradient defines the gradient to use (between 0 and 1)
  67627. * @param factor defines the life time factor to affect to the specified gradient
  67628. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67629. * @returns the current particle system
  67630. */
  67631. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67632. /**
  67633. * Not supported by GPUParticleSystem
  67634. * @param gradient defines the gradient to remove
  67635. * @returns the current particle system
  67636. */
  67637. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67638. /**
  67639. * Instantiates a GPU particle system.
  67640. * 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.
  67641. * @param name The name of the particle system
  67642. * @param options The options used to create the system
  67643. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67644. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67645. * @param customEffect a custom effect used to change the way particles are rendered by default
  67646. */
  67647. constructor(name: string, options: Partial<{
  67648. capacity: number;
  67649. randomTextureSize: number;
  67650. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67651. protected _reset(): void;
  67652. private _createUpdateVAO;
  67653. private _createRenderVAO;
  67654. private _initialize;
  67655. /** @hidden */
  67656. _recreateUpdateEffect(): void;
  67657. private _getEffect;
  67658. /**
  67659. * Fill the defines array according to the current settings of the particle system
  67660. * @param defines Array to be updated
  67661. * @param blendMode blend mode to take into account when updating the array
  67662. */
  67663. fillDefines(defines: Array<string>, blendMode?: number): void;
  67664. /**
  67665. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67666. * @param uniforms Uniforms array to fill
  67667. * @param attributes Attributes array to fill
  67668. * @param samplers Samplers array to fill
  67669. */
  67670. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67671. /** @hidden */
  67672. _recreateRenderEffect(): Effect;
  67673. /**
  67674. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67675. * @param preWarm defines if we are in the pre-warmimg phase
  67676. */
  67677. animate(preWarm?: boolean): void;
  67678. private _createFactorGradientTexture;
  67679. private _createSizeGradientTexture;
  67680. private _createAngularSpeedGradientTexture;
  67681. private _createVelocityGradientTexture;
  67682. private _createLimitVelocityGradientTexture;
  67683. private _createDragGradientTexture;
  67684. private _createColorGradientTexture;
  67685. /**
  67686. * Renders the particle system in its current state
  67687. * @param preWarm defines if the system should only update the particles but not render them
  67688. * @returns the current number of particles
  67689. */
  67690. render(preWarm?: boolean): number;
  67691. /**
  67692. * Rebuilds the particle system
  67693. */
  67694. rebuild(): void;
  67695. private _releaseBuffers;
  67696. private _releaseVAOs;
  67697. /**
  67698. * Disposes the particle system and free the associated resources
  67699. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67700. */
  67701. dispose(disposeTexture?: boolean): void;
  67702. /**
  67703. * Clones the particle system.
  67704. * @param name The name of the cloned object
  67705. * @param newEmitter The new emitter to use
  67706. * @returns the cloned particle system
  67707. */
  67708. clone(name: string, newEmitter: any): GPUParticleSystem;
  67709. /**
  67710. * Serializes the particle system to a JSON object
  67711. * @param serializeTexture defines if the texture must be serialized as well
  67712. * @returns the JSON object
  67713. */
  67714. serialize(serializeTexture?: boolean): any;
  67715. /**
  67716. * Parses a JSON object to create a GPU particle system.
  67717. * @param parsedParticleSystem The JSON object to parse
  67718. * @param sceneOrEngine The scene or the engine to create the particle system in
  67719. * @param rootUrl The root url to use to load external dependencies like texture
  67720. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67721. * @returns the parsed GPU particle system
  67722. */
  67723. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67724. }
  67725. }
  67726. declare module BABYLON {
  67727. /**
  67728. * Represents a set of particle systems working together to create a specific effect
  67729. */
  67730. export class ParticleSystemSet implements IDisposable {
  67731. /**
  67732. * Gets or sets base Assets URL
  67733. */
  67734. static BaseAssetsUrl: string;
  67735. private _emitterCreationOptions;
  67736. private _emitterNode;
  67737. /**
  67738. * Gets the particle system list
  67739. */
  67740. systems: IParticleSystem[];
  67741. /**
  67742. * Gets the emitter node used with this set
  67743. */
  67744. get emitterNode(): Nullable<TransformNode>;
  67745. /**
  67746. * Creates a new emitter mesh as a sphere
  67747. * @param options defines the options used to create the sphere
  67748. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67749. * @param scene defines the hosting scene
  67750. */
  67751. setEmitterAsSphere(options: {
  67752. diameter: number;
  67753. segments: number;
  67754. color: Color3;
  67755. }, renderingGroupId: number, scene: Scene): void;
  67756. /**
  67757. * Starts all particle systems of the set
  67758. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67759. */
  67760. start(emitter?: AbstractMesh): void;
  67761. /**
  67762. * Release all associated resources
  67763. */
  67764. dispose(): void;
  67765. /**
  67766. * Serialize the set into a JSON compatible object
  67767. * @param serializeTexture defines if the texture must be serialized as well
  67768. * @returns a JSON compatible representation of the set
  67769. */
  67770. serialize(serializeTexture?: boolean): any;
  67771. /**
  67772. * Parse a new ParticleSystemSet from a serialized source
  67773. * @param data defines a JSON compatible representation of the set
  67774. * @param scene defines the hosting scene
  67775. * @param gpu defines if we want GPU particles or CPU particles
  67776. * @returns a new ParticleSystemSet
  67777. */
  67778. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67779. }
  67780. }
  67781. declare module BABYLON {
  67782. /**
  67783. * This class is made for on one-liner static method to help creating particle system set.
  67784. */
  67785. export class ParticleHelper {
  67786. /**
  67787. * Gets or sets base Assets URL
  67788. */
  67789. static BaseAssetsUrl: string;
  67790. /** Define the Url to load snippets */
  67791. static SnippetUrl: string;
  67792. /**
  67793. * Create a default particle system that you can tweak
  67794. * @param emitter defines the emitter to use
  67795. * @param capacity defines the system capacity (default is 500 particles)
  67796. * @param scene defines the hosting scene
  67797. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67798. * @returns the new Particle system
  67799. */
  67800. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67801. /**
  67802. * This is the main static method (one-liner) of this helper to create different particle systems
  67803. * @param type This string represents the type to the particle system to create
  67804. * @param scene The scene where the particle system should live
  67805. * @param gpu If the system will use gpu
  67806. * @returns the ParticleSystemSet created
  67807. */
  67808. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67809. /**
  67810. * Static function used to export a particle system to a ParticleSystemSet variable.
  67811. * Please note that the emitter shape is not exported
  67812. * @param systems defines the particle systems to export
  67813. * @returns the created particle system set
  67814. */
  67815. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67816. /**
  67817. * Creates a particle system from a snippet saved in a remote file
  67818. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67819. * @param url defines the url to load from
  67820. * @param scene defines the hosting scene
  67821. * @param gpu If the system will use gpu
  67822. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67823. * @returns a promise that will resolve to the new particle system
  67824. */
  67825. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67826. /**
  67827. * Creates a particle system from a snippet saved by the particle system editor
  67828. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67829. * @param scene defines the hosting scene
  67830. * @param gpu If the system will use gpu
  67831. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67832. * @returns a promise that will resolve to the new particle system
  67833. */
  67834. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67835. }
  67836. }
  67837. declare module BABYLON {
  67838. interface Engine {
  67839. /**
  67840. * Create an effect to use with particle systems.
  67841. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67842. * the particle system for which you want to create a custom effect in the last parameter
  67843. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67844. * @param uniformsNames defines a list of attribute names
  67845. * @param samplers defines an array of string used to represent textures
  67846. * @param defines defines the string containing the defines to use to compile the shaders
  67847. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67848. * @param onCompiled defines a function to call when the effect creation is successful
  67849. * @param onError defines a function to call when the effect creation has failed
  67850. * @param particleSystem the particle system you want to create the effect for
  67851. * @returns the new Effect
  67852. */
  67853. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67854. }
  67855. interface Mesh {
  67856. /**
  67857. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67858. * @returns an array of IParticleSystem
  67859. */
  67860. getEmittedParticleSystems(): IParticleSystem[];
  67861. /**
  67862. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67863. * @returns an array of IParticleSystem
  67864. */
  67865. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67866. }
  67867. }
  67868. declare module BABYLON {
  67869. /** Defines the 4 color options */
  67870. export enum PointColor {
  67871. /** color value */
  67872. Color = 2,
  67873. /** uv value */
  67874. UV = 1,
  67875. /** random value */
  67876. Random = 0,
  67877. /** stated value */
  67878. Stated = 3
  67879. }
  67880. /**
  67881. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67882. * 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.
  67883. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67884. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67885. *
  67886. * Full documentation here : TO BE ENTERED
  67887. */
  67888. export class PointsCloudSystem implements IDisposable {
  67889. /**
  67890. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67891. * Example : var p = SPS.particles[i];
  67892. */
  67893. particles: CloudPoint[];
  67894. /**
  67895. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67896. */
  67897. nbParticles: number;
  67898. /**
  67899. * This a counter for your own usage. It's not set by any SPS functions.
  67900. */
  67901. counter: number;
  67902. /**
  67903. * The PCS name. This name is also given to the underlying mesh.
  67904. */
  67905. name: string;
  67906. /**
  67907. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67908. */
  67909. mesh: Mesh;
  67910. /**
  67911. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67912. * Please read :
  67913. */
  67914. vars: any;
  67915. /**
  67916. * @hidden
  67917. */
  67918. _size: number;
  67919. private _scene;
  67920. private _promises;
  67921. private _positions;
  67922. private _indices;
  67923. private _normals;
  67924. private _colors;
  67925. private _uvs;
  67926. private _indices32;
  67927. private _positions32;
  67928. private _colors32;
  67929. private _uvs32;
  67930. private _updatable;
  67931. private _isVisibilityBoxLocked;
  67932. private _alwaysVisible;
  67933. private _groups;
  67934. private _groupCounter;
  67935. private _computeParticleColor;
  67936. private _computeParticleTexture;
  67937. private _computeParticleRotation;
  67938. private _computeBoundingBox;
  67939. private _isReady;
  67940. /**
  67941. * Creates a PCS (Points Cloud System) object
  67942. * @param name (String) is the PCS name, this will be the underlying mesh name
  67943. * @param pointSize (number) is the size for each point
  67944. * @param scene (Scene) is the scene in which the PCS is added
  67945. * @param options defines the options of the PCS e.g.
  67946. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67947. */
  67948. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67949. updatable?: boolean;
  67950. });
  67951. /**
  67952. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67953. * If no points were added to the PCS, the returned mesh is just a single point.
  67954. * @returns a promise for the created mesh
  67955. */
  67956. buildMeshAsync(): Promise<Mesh>;
  67957. /**
  67958. * @hidden
  67959. */
  67960. private _buildMesh;
  67961. private _addParticle;
  67962. private _randomUnitVector;
  67963. private _getColorIndicesForCoord;
  67964. private _setPointsColorOrUV;
  67965. private _colorFromTexture;
  67966. private _calculateDensity;
  67967. /**
  67968. * Adds points to the PCS in random positions within a unit sphere
  67969. * @param nb (positive integer) the number of particles to be created from this model
  67970. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67971. * @returns the number of groups in the system
  67972. */
  67973. addPoints(nb: number, pointFunction?: any): number;
  67974. /**
  67975. * Adds points to the PCS from the surface of the model shape
  67976. * @param mesh is any Mesh object that will be used as a surface model for the points
  67977. * @param nb (positive integer) the number of particles to be created from this model
  67978. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67979. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67980. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67981. * @returns the number of groups in the system
  67982. */
  67983. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67984. /**
  67985. * Adds points to the PCS inside the model shape
  67986. * @param mesh is any Mesh object that will be used as a surface model for the points
  67987. * @param nb (positive integer) the number of particles to be created from this model
  67988. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67989. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67990. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67991. * @returns the number of groups in the system
  67992. */
  67993. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67994. /**
  67995. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67996. * This method calls `updateParticle()` for each particle of the SPS.
  67997. * For an animated SPS, it is usually called within the render loop.
  67998. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67999. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68000. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68001. * @returns the PCS.
  68002. */
  68003. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68004. /**
  68005. * Disposes the PCS.
  68006. */
  68007. dispose(): void;
  68008. /**
  68009. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68010. * doc :
  68011. * @returns the PCS.
  68012. */
  68013. refreshVisibleSize(): PointsCloudSystem;
  68014. /**
  68015. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68016. * @param size the size (float) of the visibility box
  68017. * note : this doesn't lock the PCS mesh bounding box.
  68018. * doc :
  68019. */
  68020. setVisibilityBox(size: number): void;
  68021. /**
  68022. * Gets whether the PCS is always visible or not
  68023. * doc :
  68024. */
  68025. get isAlwaysVisible(): boolean;
  68026. /**
  68027. * Sets the PCS as always visible or not
  68028. * doc :
  68029. */
  68030. set isAlwaysVisible(val: boolean);
  68031. /**
  68032. * Tells to `setParticles()` to compute the particle rotations or not
  68033. * Default value : false. The PCS is faster when it's set to false
  68034. * Note : particle rotations are only applied to parent particles
  68035. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68036. */
  68037. set computeParticleRotation(val: boolean);
  68038. /**
  68039. * Tells to `setParticles()` to compute the particle colors or not.
  68040. * Default value : true. The PCS is faster when it's set to false.
  68041. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68042. */
  68043. set computeParticleColor(val: boolean);
  68044. set computeParticleTexture(val: boolean);
  68045. /**
  68046. * Gets if `setParticles()` computes the particle colors or not.
  68047. * Default value : false. The PCS is faster when it's set to false.
  68048. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68049. */
  68050. get computeParticleColor(): boolean;
  68051. /**
  68052. * Gets if `setParticles()` computes the particle textures or not.
  68053. * Default value : false. The PCS is faster when it's set to false.
  68054. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68055. */
  68056. get computeParticleTexture(): boolean;
  68057. /**
  68058. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68059. */
  68060. set computeBoundingBox(val: boolean);
  68061. /**
  68062. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68063. */
  68064. get computeBoundingBox(): boolean;
  68065. /**
  68066. * This function does nothing. It may be overwritten to set all the particle first values.
  68067. * The PCS doesn't call this function, you may have to call it by your own.
  68068. * doc :
  68069. */
  68070. initParticles(): void;
  68071. /**
  68072. * This function does nothing. It may be overwritten to recycle a particle
  68073. * The PCS doesn't call this function, you can to call it
  68074. * doc :
  68075. * @param particle The particle to recycle
  68076. * @returns the recycled particle
  68077. */
  68078. recycleParticle(particle: CloudPoint): CloudPoint;
  68079. /**
  68080. * Updates a particle : this function should be overwritten by the user.
  68081. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68082. * doc :
  68083. * @example : just set a particle position or velocity and recycle conditions
  68084. * @param particle The particle to update
  68085. * @returns the updated particle
  68086. */
  68087. updateParticle(particle: CloudPoint): CloudPoint;
  68088. /**
  68089. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68090. * This does nothing and may be overwritten by the user.
  68091. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68092. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68093. * @param update the boolean update value actually passed to setParticles()
  68094. */
  68095. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68096. /**
  68097. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68098. * This will be passed three parameters.
  68099. * This does nothing and may be overwritten by the user.
  68100. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68101. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68102. * @param update the boolean update value actually passed to setParticles()
  68103. */
  68104. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68105. }
  68106. }
  68107. declare module BABYLON {
  68108. /**
  68109. * Represents one particle of a points cloud system.
  68110. */
  68111. export class CloudPoint {
  68112. /**
  68113. * particle global index
  68114. */
  68115. idx: number;
  68116. /**
  68117. * The color of the particle
  68118. */
  68119. color: Nullable<Color4>;
  68120. /**
  68121. * The world space position of the particle.
  68122. */
  68123. position: Vector3;
  68124. /**
  68125. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68126. */
  68127. rotation: Vector3;
  68128. /**
  68129. * The world space rotation quaternion of the particle.
  68130. */
  68131. rotationQuaternion: Nullable<Quaternion>;
  68132. /**
  68133. * The uv of the particle.
  68134. */
  68135. uv: Nullable<Vector2>;
  68136. /**
  68137. * The current speed of the particle.
  68138. */
  68139. velocity: Vector3;
  68140. /**
  68141. * The pivot point in the particle local space.
  68142. */
  68143. pivot: Vector3;
  68144. /**
  68145. * Must the particle be translated from its pivot point in its local space ?
  68146. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68147. * Default : false
  68148. */
  68149. translateFromPivot: boolean;
  68150. /**
  68151. * Index of this particle in the global "positions" array (Internal use)
  68152. * @hidden
  68153. */
  68154. _pos: number;
  68155. /**
  68156. * @hidden Index of this particle in the global "indices" array (Internal use)
  68157. */
  68158. _ind: number;
  68159. /**
  68160. * Group this particle belongs to
  68161. */
  68162. _group: PointsGroup;
  68163. /**
  68164. * Group id of this particle
  68165. */
  68166. groupId: number;
  68167. /**
  68168. * Index of the particle in its group id (Internal use)
  68169. */
  68170. idxInGroup: number;
  68171. /**
  68172. * @hidden Particle BoundingInfo object (Internal use)
  68173. */
  68174. _boundingInfo: BoundingInfo;
  68175. /**
  68176. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68177. */
  68178. _pcs: PointsCloudSystem;
  68179. /**
  68180. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68181. */
  68182. _stillInvisible: boolean;
  68183. /**
  68184. * @hidden Last computed particle rotation matrix
  68185. */
  68186. _rotationMatrix: number[];
  68187. /**
  68188. * Parent particle Id, if any.
  68189. * Default null.
  68190. */
  68191. parentId: Nullable<number>;
  68192. /**
  68193. * @hidden Internal global position in the PCS.
  68194. */
  68195. _globalPosition: Vector3;
  68196. /**
  68197. * Creates a Point Cloud object.
  68198. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68199. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68200. * @param group (PointsGroup) is the group the particle belongs to
  68201. * @param groupId (integer) is the group identifier in the PCS.
  68202. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68203. * @param pcs defines the PCS it is associated to
  68204. */
  68205. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68206. /**
  68207. * get point size
  68208. */
  68209. get size(): Vector3;
  68210. /**
  68211. * Set point size
  68212. */
  68213. set size(scale: Vector3);
  68214. /**
  68215. * Legacy support, changed quaternion to rotationQuaternion
  68216. */
  68217. get quaternion(): Nullable<Quaternion>;
  68218. /**
  68219. * Legacy support, changed quaternion to rotationQuaternion
  68220. */
  68221. set quaternion(q: Nullable<Quaternion>);
  68222. /**
  68223. * Returns a boolean. True if the particle intersects a mesh, else false
  68224. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68225. * @param target is the object (point or mesh) what the intersection is computed against
  68226. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68227. * @returns true if it intersects
  68228. */
  68229. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68230. /**
  68231. * get the rotation matrix of the particle
  68232. * @hidden
  68233. */
  68234. getRotationMatrix(m: Matrix): void;
  68235. }
  68236. /**
  68237. * Represents a group of points in a points cloud system
  68238. * * PCS internal tool, don't use it manually.
  68239. */
  68240. export class PointsGroup {
  68241. /**
  68242. * The group id
  68243. * @hidden
  68244. */
  68245. groupID: number;
  68246. /**
  68247. * image data for group (internal use)
  68248. * @hidden
  68249. */
  68250. _groupImageData: Nullable<ArrayBufferView>;
  68251. /**
  68252. * Image Width (internal use)
  68253. * @hidden
  68254. */
  68255. _groupImgWidth: number;
  68256. /**
  68257. * Image Height (internal use)
  68258. * @hidden
  68259. */
  68260. _groupImgHeight: number;
  68261. /**
  68262. * Custom position function (internal use)
  68263. * @hidden
  68264. */
  68265. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68266. /**
  68267. * density per facet for surface points
  68268. * @hidden
  68269. */
  68270. _groupDensity: number[];
  68271. /**
  68272. * Only when points are colored by texture carries pointer to texture list array
  68273. * @hidden
  68274. */
  68275. _textureNb: number;
  68276. /**
  68277. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68278. * PCS internal tool, don't use it manually.
  68279. * @hidden
  68280. */
  68281. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68282. }
  68283. }
  68284. declare module BABYLON {
  68285. interface Scene {
  68286. /** @hidden (Backing field) */
  68287. _physicsEngine: Nullable<IPhysicsEngine>;
  68288. /** @hidden */
  68289. _physicsTimeAccumulator: number;
  68290. /**
  68291. * Gets the current physics engine
  68292. * @returns a IPhysicsEngine or null if none attached
  68293. */
  68294. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68295. /**
  68296. * Enables physics to the current scene
  68297. * @param gravity defines the scene's gravity for the physics engine
  68298. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68299. * @return a boolean indicating if the physics engine was initialized
  68300. */
  68301. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68302. /**
  68303. * Disables and disposes the physics engine associated with the scene
  68304. */
  68305. disablePhysicsEngine(): void;
  68306. /**
  68307. * Gets a boolean indicating if there is an active physics engine
  68308. * @returns a boolean indicating if there is an active physics engine
  68309. */
  68310. isPhysicsEnabled(): boolean;
  68311. /**
  68312. * Deletes a physics compound impostor
  68313. * @param compound defines the compound to delete
  68314. */
  68315. deleteCompoundImpostor(compound: any): void;
  68316. /**
  68317. * An event triggered when physic simulation is about to be run
  68318. */
  68319. onBeforePhysicsObservable: Observable<Scene>;
  68320. /**
  68321. * An event triggered when physic simulation has been done
  68322. */
  68323. onAfterPhysicsObservable: Observable<Scene>;
  68324. }
  68325. interface AbstractMesh {
  68326. /** @hidden */
  68327. _physicsImpostor: Nullable<PhysicsImpostor>;
  68328. /**
  68329. * Gets or sets impostor used for physic simulation
  68330. * @see https://doc.babylonjs.com/features/physics_engine
  68331. */
  68332. physicsImpostor: Nullable<PhysicsImpostor>;
  68333. /**
  68334. * Gets the current physics impostor
  68335. * @see https://doc.babylonjs.com/features/physics_engine
  68336. * @returns a physics impostor or null
  68337. */
  68338. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68339. /** Apply a physic impulse to the mesh
  68340. * @param force defines the force to apply
  68341. * @param contactPoint defines where to apply the force
  68342. * @returns the current mesh
  68343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68344. */
  68345. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68346. /**
  68347. * Creates a physic joint between two meshes
  68348. * @param otherMesh defines the other mesh to use
  68349. * @param pivot1 defines the pivot to use on this mesh
  68350. * @param pivot2 defines the pivot to use on the other mesh
  68351. * @param options defines additional options (can be plugin dependent)
  68352. * @returns the current mesh
  68353. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68354. */
  68355. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68356. /** @hidden */
  68357. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68358. }
  68359. /**
  68360. * Defines the physics engine scene component responsible to manage a physics engine
  68361. */
  68362. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68363. /**
  68364. * The component name helpful to identify the component in the list of scene components.
  68365. */
  68366. readonly name: string;
  68367. /**
  68368. * The scene the component belongs to.
  68369. */
  68370. scene: Scene;
  68371. /**
  68372. * Creates a new instance of the component for the given scene
  68373. * @param scene Defines the scene to register the component in
  68374. */
  68375. constructor(scene: Scene);
  68376. /**
  68377. * Registers the component in a given scene
  68378. */
  68379. register(): void;
  68380. /**
  68381. * Rebuilds the elements related to this component in case of
  68382. * context lost for instance.
  68383. */
  68384. rebuild(): void;
  68385. /**
  68386. * Disposes the component and the associated ressources
  68387. */
  68388. dispose(): void;
  68389. }
  68390. }
  68391. declare module BABYLON {
  68392. /**
  68393. * A helper for physics simulations
  68394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68395. */
  68396. export class PhysicsHelper {
  68397. private _scene;
  68398. private _physicsEngine;
  68399. /**
  68400. * Initializes the Physics helper
  68401. * @param scene Babylon.js scene
  68402. */
  68403. constructor(scene: Scene);
  68404. /**
  68405. * Applies a radial explosion impulse
  68406. * @param origin the origin of the explosion
  68407. * @param radiusOrEventOptions the radius or the options of radial explosion
  68408. * @param strength the explosion strength
  68409. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68410. * @returns A physics radial explosion event, or null
  68411. */
  68412. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68413. /**
  68414. * Applies a radial explosion force
  68415. * @param origin the origin of the explosion
  68416. * @param radiusOrEventOptions the radius or the options of radial explosion
  68417. * @param strength the explosion strength
  68418. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68419. * @returns A physics radial explosion event, or null
  68420. */
  68421. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68422. /**
  68423. * Creates a gravitational field
  68424. * @param origin the origin of the explosion
  68425. * @param radiusOrEventOptions the radius or the options of radial explosion
  68426. * @param strength the explosion strength
  68427. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68428. * @returns A physics gravitational field event, or null
  68429. */
  68430. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68431. /**
  68432. * Creates a physics updraft event
  68433. * @param origin the origin of the updraft
  68434. * @param radiusOrEventOptions the radius or the options of the updraft
  68435. * @param strength the strength of the updraft
  68436. * @param height the height of the updraft
  68437. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68438. * @returns A physics updraft event, or null
  68439. */
  68440. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68441. /**
  68442. * Creates a physics vortex event
  68443. * @param origin the of the vortex
  68444. * @param radiusOrEventOptions the radius or the options of the vortex
  68445. * @param strength the strength of the vortex
  68446. * @param height the height of the vortex
  68447. * @returns a Physics vortex event, or null
  68448. * A physics vortex event or null
  68449. */
  68450. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68451. }
  68452. /**
  68453. * Represents a physics radial explosion event
  68454. */
  68455. class PhysicsRadialExplosionEvent {
  68456. private _scene;
  68457. private _options;
  68458. private _sphere;
  68459. private _dataFetched;
  68460. /**
  68461. * Initializes a radial explosioin event
  68462. * @param _scene BabylonJS scene
  68463. * @param _options The options for the vortex event
  68464. */
  68465. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68466. /**
  68467. * Returns the data related to the radial explosion event (sphere).
  68468. * @returns The radial explosion event data
  68469. */
  68470. getData(): PhysicsRadialExplosionEventData;
  68471. /**
  68472. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68473. * @param impostor A physics imposter
  68474. * @param origin the origin of the explosion
  68475. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68476. */
  68477. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68478. /**
  68479. * Triggers affecterd impostors callbacks
  68480. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68481. */
  68482. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68483. /**
  68484. * Disposes the sphere.
  68485. * @param force Specifies if the sphere should be disposed by force
  68486. */
  68487. dispose(force?: boolean): void;
  68488. /*** Helpers ***/
  68489. private _prepareSphere;
  68490. private _intersectsWithSphere;
  68491. }
  68492. /**
  68493. * Represents a gravitational field event
  68494. */
  68495. class PhysicsGravitationalFieldEvent {
  68496. private _physicsHelper;
  68497. private _scene;
  68498. private _origin;
  68499. private _options;
  68500. private _tickCallback;
  68501. private _sphere;
  68502. private _dataFetched;
  68503. /**
  68504. * Initializes the physics gravitational field event
  68505. * @param _physicsHelper A physics helper
  68506. * @param _scene BabylonJS scene
  68507. * @param _origin The origin position of the gravitational field event
  68508. * @param _options The options for the vortex event
  68509. */
  68510. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68511. /**
  68512. * Returns the data related to the gravitational field event (sphere).
  68513. * @returns A gravitational field event
  68514. */
  68515. getData(): PhysicsGravitationalFieldEventData;
  68516. /**
  68517. * Enables the gravitational field.
  68518. */
  68519. enable(): void;
  68520. /**
  68521. * Disables the gravitational field.
  68522. */
  68523. disable(): void;
  68524. /**
  68525. * Disposes the sphere.
  68526. * @param force The force to dispose from the gravitational field event
  68527. */
  68528. dispose(force?: boolean): void;
  68529. private _tick;
  68530. }
  68531. /**
  68532. * Represents a physics updraft event
  68533. */
  68534. class PhysicsUpdraftEvent {
  68535. private _scene;
  68536. private _origin;
  68537. private _options;
  68538. private _physicsEngine;
  68539. private _originTop;
  68540. private _originDirection;
  68541. private _tickCallback;
  68542. private _cylinder;
  68543. private _cylinderPosition;
  68544. private _dataFetched;
  68545. /**
  68546. * Initializes the physics updraft event
  68547. * @param _scene BabylonJS scene
  68548. * @param _origin The origin position of the updraft
  68549. * @param _options The options for the updraft event
  68550. */
  68551. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68552. /**
  68553. * Returns the data related to the updraft event (cylinder).
  68554. * @returns A physics updraft event
  68555. */
  68556. getData(): PhysicsUpdraftEventData;
  68557. /**
  68558. * Enables the updraft.
  68559. */
  68560. enable(): void;
  68561. /**
  68562. * Disables the updraft.
  68563. */
  68564. disable(): void;
  68565. /**
  68566. * Disposes the cylinder.
  68567. * @param force Specifies if the updraft should be disposed by force
  68568. */
  68569. dispose(force?: boolean): void;
  68570. private getImpostorHitData;
  68571. private _tick;
  68572. /*** Helpers ***/
  68573. private _prepareCylinder;
  68574. private _intersectsWithCylinder;
  68575. }
  68576. /**
  68577. * Represents a physics vortex event
  68578. */
  68579. class PhysicsVortexEvent {
  68580. private _scene;
  68581. private _origin;
  68582. private _options;
  68583. private _physicsEngine;
  68584. private _originTop;
  68585. private _tickCallback;
  68586. private _cylinder;
  68587. private _cylinderPosition;
  68588. private _dataFetched;
  68589. /**
  68590. * Initializes the physics vortex event
  68591. * @param _scene The BabylonJS scene
  68592. * @param _origin The origin position of the vortex
  68593. * @param _options The options for the vortex event
  68594. */
  68595. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68596. /**
  68597. * Returns the data related to the vortex event (cylinder).
  68598. * @returns The physics vortex event data
  68599. */
  68600. getData(): PhysicsVortexEventData;
  68601. /**
  68602. * Enables the vortex.
  68603. */
  68604. enable(): void;
  68605. /**
  68606. * Disables the cortex.
  68607. */
  68608. disable(): void;
  68609. /**
  68610. * Disposes the sphere.
  68611. * @param force
  68612. */
  68613. dispose(force?: boolean): void;
  68614. private getImpostorHitData;
  68615. private _tick;
  68616. /*** Helpers ***/
  68617. private _prepareCylinder;
  68618. private _intersectsWithCylinder;
  68619. }
  68620. /**
  68621. * Options fot the radial explosion event
  68622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68623. */
  68624. export class PhysicsRadialExplosionEventOptions {
  68625. /**
  68626. * The radius of the sphere for the radial explosion.
  68627. */
  68628. radius: number;
  68629. /**
  68630. * The strenth of the explosion.
  68631. */
  68632. strength: number;
  68633. /**
  68634. * The strenght of the force in correspondence to the distance of the affected object
  68635. */
  68636. falloff: PhysicsRadialImpulseFalloff;
  68637. /**
  68638. * Sphere options for the radial explosion.
  68639. */
  68640. sphere: {
  68641. segments: number;
  68642. diameter: number;
  68643. };
  68644. /**
  68645. * Sphere options for the radial explosion.
  68646. */
  68647. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68648. }
  68649. /**
  68650. * Options fot the updraft event
  68651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68652. */
  68653. export class PhysicsUpdraftEventOptions {
  68654. /**
  68655. * The radius of the cylinder for the vortex
  68656. */
  68657. radius: number;
  68658. /**
  68659. * The strenth of the updraft.
  68660. */
  68661. strength: number;
  68662. /**
  68663. * The height of the cylinder for the updraft.
  68664. */
  68665. height: number;
  68666. /**
  68667. * The mode for the the updraft.
  68668. */
  68669. updraftMode: PhysicsUpdraftMode;
  68670. }
  68671. /**
  68672. * Options fot the vortex event
  68673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68674. */
  68675. export class PhysicsVortexEventOptions {
  68676. /**
  68677. * The radius of the cylinder for the vortex
  68678. */
  68679. radius: number;
  68680. /**
  68681. * The strenth of the vortex.
  68682. */
  68683. strength: number;
  68684. /**
  68685. * The height of the cylinder for the vortex.
  68686. */
  68687. height: number;
  68688. /**
  68689. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68690. */
  68691. centripetalForceThreshold: number;
  68692. /**
  68693. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68694. */
  68695. centripetalForceMultiplier: number;
  68696. /**
  68697. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68698. */
  68699. centrifugalForceMultiplier: number;
  68700. /**
  68701. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68702. */
  68703. updraftForceMultiplier: number;
  68704. }
  68705. /**
  68706. * The strenght of the force in correspondence to the distance of the affected object
  68707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68708. */
  68709. export enum PhysicsRadialImpulseFalloff {
  68710. /** Defines that impulse is constant in strength across it's whole radius */
  68711. Constant = 0,
  68712. /** Defines that impulse gets weaker if it's further from the origin */
  68713. Linear = 1
  68714. }
  68715. /**
  68716. * The strength of the force in correspondence to the distance of the affected object
  68717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68718. */
  68719. export enum PhysicsUpdraftMode {
  68720. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68721. Center = 0,
  68722. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68723. Perpendicular = 1
  68724. }
  68725. /**
  68726. * Interface for a physics hit data
  68727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68728. */
  68729. export interface PhysicsHitData {
  68730. /**
  68731. * The force applied at the contact point
  68732. */
  68733. force: Vector3;
  68734. /**
  68735. * The contact point
  68736. */
  68737. contactPoint: Vector3;
  68738. /**
  68739. * The distance from the origin to the contact point
  68740. */
  68741. distanceFromOrigin: number;
  68742. }
  68743. /**
  68744. * Interface for radial explosion event data
  68745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68746. */
  68747. export interface PhysicsRadialExplosionEventData {
  68748. /**
  68749. * A sphere used for the radial explosion event
  68750. */
  68751. sphere: Mesh;
  68752. }
  68753. /**
  68754. * Interface for gravitational field event data
  68755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68756. */
  68757. export interface PhysicsGravitationalFieldEventData {
  68758. /**
  68759. * A sphere mesh used for the gravitational field event
  68760. */
  68761. sphere: Mesh;
  68762. }
  68763. /**
  68764. * Interface for updraft event data
  68765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68766. */
  68767. export interface PhysicsUpdraftEventData {
  68768. /**
  68769. * A cylinder used for the updraft event
  68770. */
  68771. cylinder: Mesh;
  68772. }
  68773. /**
  68774. * Interface for vortex event data
  68775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68776. */
  68777. export interface PhysicsVortexEventData {
  68778. /**
  68779. * A cylinder used for the vortex event
  68780. */
  68781. cylinder: Mesh;
  68782. }
  68783. /**
  68784. * Interface for an affected physics impostor
  68785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68786. */
  68787. export interface PhysicsAffectedImpostorWithData {
  68788. /**
  68789. * The impostor affected by the effect
  68790. */
  68791. impostor: PhysicsImpostor;
  68792. /**
  68793. * The data about the hit/horce from the explosion
  68794. */
  68795. hitData: PhysicsHitData;
  68796. }
  68797. }
  68798. declare module BABYLON {
  68799. /** @hidden */
  68800. export var blackAndWhitePixelShader: {
  68801. name: string;
  68802. shader: string;
  68803. };
  68804. }
  68805. declare module BABYLON {
  68806. /**
  68807. * Post process used to render in black and white
  68808. */
  68809. export class BlackAndWhitePostProcess extends PostProcess {
  68810. /**
  68811. * Linear about to convert he result to black and white (default: 1)
  68812. */
  68813. degree: number;
  68814. /**
  68815. * Gets a string identifying the name of the class
  68816. * @returns "BlackAndWhitePostProcess" string
  68817. */
  68818. getClassName(): string;
  68819. /**
  68820. * Creates a black and white post process
  68821. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68822. * @param name The name of the effect.
  68823. * @param options The required width/height ratio to downsize to before computing the render pass.
  68824. * @param camera The camera to apply the render pass to.
  68825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68826. * @param engine The engine which the post process will be applied. (default: current engine)
  68827. * @param reusable If the post process can be reused on the same frame. (default: false)
  68828. */
  68829. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68830. /** @hidden */
  68831. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  68832. }
  68833. }
  68834. declare module BABYLON {
  68835. /**
  68836. * This represents a set of one or more post processes in Babylon.
  68837. * A post process can be used to apply a shader to a texture after it is rendered.
  68838. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68839. */
  68840. export class PostProcessRenderEffect {
  68841. private _postProcesses;
  68842. private _getPostProcesses;
  68843. private _singleInstance;
  68844. private _cameras;
  68845. private _indicesForCamera;
  68846. /**
  68847. * Name of the effect
  68848. * @hidden
  68849. */
  68850. _name: string;
  68851. /**
  68852. * Instantiates a post process render effect.
  68853. * A post process can be used to apply a shader to a texture after it is rendered.
  68854. * @param engine The engine the effect is tied to
  68855. * @param name The name of the effect
  68856. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68857. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68858. */
  68859. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68860. /**
  68861. * Checks if all the post processes in the effect are supported.
  68862. */
  68863. get isSupported(): boolean;
  68864. /**
  68865. * Updates the current state of the effect
  68866. * @hidden
  68867. */
  68868. _update(): void;
  68869. /**
  68870. * Attaches the effect on cameras
  68871. * @param cameras The camera to attach to.
  68872. * @hidden
  68873. */
  68874. _attachCameras(cameras: Camera): void;
  68875. /**
  68876. * Attaches the effect on cameras
  68877. * @param cameras The camera to attach to.
  68878. * @hidden
  68879. */
  68880. _attachCameras(cameras: Camera[]): void;
  68881. /**
  68882. * Detaches the effect on cameras
  68883. * @param cameras The camera to detatch from.
  68884. * @hidden
  68885. */
  68886. _detachCameras(cameras: Camera): void;
  68887. /**
  68888. * Detatches the effect on cameras
  68889. * @param cameras The camera to detatch from.
  68890. * @hidden
  68891. */
  68892. _detachCameras(cameras: Camera[]): void;
  68893. /**
  68894. * Enables the effect on given cameras
  68895. * @param cameras The camera to enable.
  68896. * @hidden
  68897. */
  68898. _enable(cameras: Camera): void;
  68899. /**
  68900. * Enables the effect on given cameras
  68901. * @param cameras The camera to enable.
  68902. * @hidden
  68903. */
  68904. _enable(cameras: Nullable<Camera[]>): void;
  68905. /**
  68906. * Disables the effect on the given cameras
  68907. * @param cameras The camera to disable.
  68908. * @hidden
  68909. */
  68910. _disable(cameras: Camera): void;
  68911. /**
  68912. * Disables the effect on the given cameras
  68913. * @param cameras The camera to disable.
  68914. * @hidden
  68915. */
  68916. _disable(cameras: Nullable<Camera[]>): void;
  68917. /**
  68918. * Gets a list of the post processes contained in the effect.
  68919. * @param camera The camera to get the post processes on.
  68920. * @returns The list of the post processes in the effect.
  68921. */
  68922. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68923. }
  68924. }
  68925. declare module BABYLON {
  68926. /** @hidden */
  68927. export var extractHighlightsPixelShader: {
  68928. name: string;
  68929. shader: string;
  68930. };
  68931. }
  68932. declare module BABYLON {
  68933. /**
  68934. * 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.
  68935. */
  68936. export class ExtractHighlightsPostProcess extends PostProcess {
  68937. /**
  68938. * The luminance threshold, pixels below this value will be set to black.
  68939. */
  68940. threshold: number;
  68941. /** @hidden */
  68942. _exposure: number;
  68943. /**
  68944. * Post process which has the input texture to be used when performing highlight extraction
  68945. * @hidden
  68946. */
  68947. _inputPostProcess: Nullable<PostProcess>;
  68948. /**
  68949. * Gets a string identifying the name of the class
  68950. * @returns "ExtractHighlightsPostProcess" string
  68951. */
  68952. getClassName(): string;
  68953. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68954. }
  68955. }
  68956. declare module BABYLON {
  68957. /** @hidden */
  68958. export var bloomMergePixelShader: {
  68959. name: string;
  68960. shader: string;
  68961. };
  68962. }
  68963. declare module BABYLON {
  68964. /**
  68965. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68966. */
  68967. export class BloomMergePostProcess extends PostProcess {
  68968. /** Weight of the bloom to be added to the original input. */
  68969. weight: number;
  68970. /**
  68971. * Gets a string identifying the name of the class
  68972. * @returns "BloomMergePostProcess" string
  68973. */
  68974. getClassName(): string;
  68975. /**
  68976. * Creates a new instance of @see BloomMergePostProcess
  68977. * @param name The name of the effect.
  68978. * @param originalFromInput Post process which's input will be used for the merge.
  68979. * @param blurred Blurred highlights post process which's output will be used.
  68980. * @param weight Weight of the bloom to be added to the original input.
  68981. * @param options The required width/height ratio to downsize to before computing the render pass.
  68982. * @param camera The camera to apply the render pass to.
  68983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68984. * @param engine The engine which the post process will be applied. (default: current engine)
  68985. * @param reusable If the post process can be reused on the same frame. (default: false)
  68986. * @param textureType Type of textures used when performing the post process. (default: 0)
  68987. * @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)
  68988. */
  68989. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68990. /** Weight of the bloom to be added to the original input. */
  68991. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68992. }
  68993. }
  68994. declare module BABYLON {
  68995. /**
  68996. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68997. */
  68998. export class BloomEffect extends PostProcessRenderEffect {
  68999. private bloomScale;
  69000. /**
  69001. * @hidden Internal
  69002. */
  69003. _effects: Array<PostProcess>;
  69004. /**
  69005. * @hidden Internal
  69006. */
  69007. _downscale: ExtractHighlightsPostProcess;
  69008. private _blurX;
  69009. private _blurY;
  69010. private _merge;
  69011. /**
  69012. * The luminance threshold to find bright areas of the image to bloom.
  69013. */
  69014. get threshold(): number;
  69015. set threshold(value: number);
  69016. /**
  69017. * The strength of the bloom.
  69018. */
  69019. get weight(): number;
  69020. set weight(value: number);
  69021. /**
  69022. * Specifies the size of the bloom blur kernel, relative to the final output size
  69023. */
  69024. get kernel(): number;
  69025. set kernel(value: number);
  69026. /**
  69027. * Creates a new instance of @see BloomEffect
  69028. * @param scene The scene the effect belongs to.
  69029. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69030. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69031. * @param bloomWeight The the strength of bloom.
  69032. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69033. * @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)
  69034. */
  69035. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69036. /**
  69037. * Disposes each of the internal effects for a given camera.
  69038. * @param camera The camera to dispose the effect on.
  69039. */
  69040. disposeEffects(camera: Camera): void;
  69041. /**
  69042. * @hidden Internal
  69043. */
  69044. _updateEffects(): void;
  69045. /**
  69046. * Internal
  69047. * @returns if all the contained post processes are ready.
  69048. * @hidden
  69049. */
  69050. _isReady(): boolean;
  69051. }
  69052. }
  69053. declare module BABYLON {
  69054. /** @hidden */
  69055. export var chromaticAberrationPixelShader: {
  69056. name: string;
  69057. shader: string;
  69058. };
  69059. }
  69060. declare module BABYLON {
  69061. /**
  69062. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69063. */
  69064. export class ChromaticAberrationPostProcess extends PostProcess {
  69065. /**
  69066. * The amount of seperation of rgb channels (default: 30)
  69067. */
  69068. aberrationAmount: number;
  69069. /**
  69070. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69071. */
  69072. radialIntensity: number;
  69073. /**
  69074. * 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))
  69075. */
  69076. direction: Vector2;
  69077. /**
  69078. * 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))
  69079. */
  69080. centerPosition: Vector2;
  69081. /** The width of the screen to apply the effect on */
  69082. screenWidth: number;
  69083. /** The height of the screen to apply the effect on */
  69084. screenHeight: number;
  69085. /**
  69086. * Gets a string identifying the name of the class
  69087. * @returns "ChromaticAberrationPostProcess" string
  69088. */
  69089. getClassName(): string;
  69090. /**
  69091. * Creates a new instance ChromaticAberrationPostProcess
  69092. * @param name The name of the effect.
  69093. * @param screenWidth The width of the screen to apply the effect on.
  69094. * @param screenHeight The height of the screen to apply the effect on.
  69095. * @param options The required width/height ratio to downsize to before computing the render pass.
  69096. * @param camera The camera to apply the render pass to.
  69097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69098. * @param engine The engine which the post process will be applied. (default: current engine)
  69099. * @param reusable If the post process can be reused on the same frame. (default: false)
  69100. * @param textureType Type of textures used when performing the post process. (default: 0)
  69101. * @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)
  69102. */
  69103. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69104. /** @hidden */
  69105. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69106. }
  69107. }
  69108. declare module BABYLON {
  69109. /** @hidden */
  69110. export var circleOfConfusionPixelShader: {
  69111. name: string;
  69112. shader: string;
  69113. };
  69114. }
  69115. declare module BABYLON {
  69116. /**
  69117. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69118. */
  69119. export class CircleOfConfusionPostProcess extends PostProcess {
  69120. /**
  69121. * 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.
  69122. */
  69123. lensSize: number;
  69124. /**
  69125. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69126. */
  69127. fStop: number;
  69128. /**
  69129. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69130. */
  69131. focusDistance: number;
  69132. /**
  69133. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69134. */
  69135. focalLength: number;
  69136. /**
  69137. * Gets a string identifying the name of the class
  69138. * @returns "CircleOfConfusionPostProcess" string
  69139. */
  69140. getClassName(): string;
  69141. private _depthTexture;
  69142. /**
  69143. * Creates a new instance CircleOfConfusionPostProcess
  69144. * @param name The name of the effect.
  69145. * @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.
  69146. * @param options The required width/height ratio to downsize to before computing the render pass.
  69147. * @param camera The camera to apply the render pass to.
  69148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69149. * @param engine The engine which the post process will be applied. (default: current engine)
  69150. * @param reusable If the post process can be reused on the same frame. (default: false)
  69151. * @param textureType Type of textures used when performing the post process. (default: 0)
  69152. * @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)
  69153. */
  69154. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69155. /**
  69156. * 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.
  69157. */
  69158. set depthTexture(value: RenderTargetTexture);
  69159. }
  69160. }
  69161. declare module BABYLON {
  69162. /** @hidden */
  69163. export var colorCorrectionPixelShader: {
  69164. name: string;
  69165. shader: string;
  69166. };
  69167. }
  69168. declare module BABYLON {
  69169. /**
  69170. *
  69171. * This post-process allows the modification of rendered colors by using
  69172. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69173. *
  69174. * The object needs to be provided an url to a texture containing the color
  69175. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69176. * Use an image editing software to tweak the LUT to match your needs.
  69177. *
  69178. * For an example of a color LUT, see here:
  69179. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69180. * For explanations on color grading, see here:
  69181. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69182. *
  69183. */
  69184. export class ColorCorrectionPostProcess extends PostProcess {
  69185. private _colorTableTexture;
  69186. /**
  69187. * Gets the color table url used to create the LUT texture
  69188. */
  69189. colorTableUrl: string;
  69190. /**
  69191. * Gets a string identifying the name of the class
  69192. * @returns "ColorCorrectionPostProcess" string
  69193. */
  69194. getClassName(): string;
  69195. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69196. /** @hidden */
  69197. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69198. }
  69199. }
  69200. declare module BABYLON {
  69201. /** @hidden */
  69202. export var convolutionPixelShader: {
  69203. name: string;
  69204. shader: string;
  69205. };
  69206. }
  69207. declare module BABYLON {
  69208. /**
  69209. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69210. * input texture to perform effects such as edge detection or sharpening
  69211. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69212. */
  69213. export class ConvolutionPostProcess extends PostProcess {
  69214. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69215. kernel: number[];
  69216. /**
  69217. * Gets a string identifying the name of the class
  69218. * @returns "ConvolutionPostProcess" string
  69219. */
  69220. getClassName(): string;
  69221. /**
  69222. * Creates a new instance ConvolutionPostProcess
  69223. * @param name The name of the effect.
  69224. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69225. * @param options The required width/height ratio to downsize to before computing the render pass.
  69226. * @param camera The camera to apply the render pass to.
  69227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69228. * @param engine The engine which the post process will be applied. (default: current engine)
  69229. * @param reusable If the post process can be reused on the same frame. (default: false)
  69230. * @param textureType Type of textures used when performing the post process. (default: 0)
  69231. */
  69232. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69233. /** @hidden */
  69234. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69235. /**
  69236. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69237. */
  69238. static EdgeDetect0Kernel: number[];
  69239. /**
  69240. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69241. */
  69242. static EdgeDetect1Kernel: number[];
  69243. /**
  69244. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69245. */
  69246. static EdgeDetect2Kernel: number[];
  69247. /**
  69248. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69249. */
  69250. static SharpenKernel: number[];
  69251. /**
  69252. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69253. */
  69254. static EmbossKernel: number[];
  69255. /**
  69256. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69257. */
  69258. static GaussianKernel: number[];
  69259. }
  69260. }
  69261. declare module BABYLON {
  69262. /**
  69263. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69264. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69265. * based on samples that have a large difference in distance than the center pixel.
  69266. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69267. */
  69268. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69269. /**
  69270. * The direction the blur should be applied
  69271. */
  69272. direction: Vector2;
  69273. /**
  69274. * Gets a string identifying the name of the class
  69275. * @returns "DepthOfFieldBlurPostProcess" string
  69276. */
  69277. getClassName(): string;
  69278. /**
  69279. * Creates a new instance CircleOfConfusionPostProcess
  69280. * @param name The name of the effect.
  69281. * @param scene The scene the effect belongs to.
  69282. * @param direction The direction the blur should be applied.
  69283. * @param kernel The size of the kernel used to blur.
  69284. * @param options The required width/height ratio to downsize to before computing the render pass.
  69285. * @param camera The camera to apply the render pass to.
  69286. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69287. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69289. * @param engine The engine which the post process will be applied. (default: current engine)
  69290. * @param reusable If the post process can be reused on the same frame. (default: false)
  69291. * @param textureType Type of textures used when performing the post process. (default: 0)
  69292. * @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)
  69293. */
  69294. 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);
  69295. }
  69296. }
  69297. declare module BABYLON {
  69298. /** @hidden */
  69299. export var depthOfFieldMergePixelShader: {
  69300. name: string;
  69301. shader: string;
  69302. };
  69303. }
  69304. declare module BABYLON {
  69305. /**
  69306. * Options to be set when merging outputs from the default pipeline.
  69307. */
  69308. export class DepthOfFieldMergePostProcessOptions {
  69309. /**
  69310. * The original image to merge on top of
  69311. */
  69312. originalFromInput: PostProcess;
  69313. /**
  69314. * Parameters to perform the merge of the depth of field effect
  69315. */
  69316. depthOfField?: {
  69317. circleOfConfusion: PostProcess;
  69318. blurSteps: Array<PostProcess>;
  69319. };
  69320. /**
  69321. * Parameters to perform the merge of bloom effect
  69322. */
  69323. bloom?: {
  69324. blurred: PostProcess;
  69325. weight: number;
  69326. };
  69327. }
  69328. /**
  69329. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69330. */
  69331. export class DepthOfFieldMergePostProcess extends PostProcess {
  69332. private blurSteps;
  69333. /**
  69334. * Gets a string identifying the name of the class
  69335. * @returns "DepthOfFieldMergePostProcess" string
  69336. */
  69337. getClassName(): string;
  69338. /**
  69339. * Creates a new instance of DepthOfFieldMergePostProcess
  69340. * @param name The name of the effect.
  69341. * @param originalFromInput Post process which's input will be used for the merge.
  69342. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69343. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69344. * @param options The required width/height ratio to downsize to before computing the render pass.
  69345. * @param camera The camera to apply the render pass to.
  69346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69347. * @param engine The engine which the post process will be applied. (default: current engine)
  69348. * @param reusable If the post process can be reused on the same frame. (default: false)
  69349. * @param textureType Type of textures used when performing the post process. (default: 0)
  69350. * @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)
  69351. */
  69352. 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);
  69353. /**
  69354. * Updates the effect with the current post process compile time values and recompiles the shader.
  69355. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69356. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69357. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69358. * @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
  69359. * @param onCompiled Called when the shader has been compiled.
  69360. * @param onError Called if there is an error when compiling a shader.
  69361. */
  69362. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69363. }
  69364. }
  69365. declare module BABYLON {
  69366. /**
  69367. * Specifies the level of max blur that should be applied when using the depth of field effect
  69368. */
  69369. export enum DepthOfFieldEffectBlurLevel {
  69370. /**
  69371. * Subtle blur
  69372. */
  69373. Low = 0,
  69374. /**
  69375. * Medium blur
  69376. */
  69377. Medium = 1,
  69378. /**
  69379. * Large blur
  69380. */
  69381. High = 2
  69382. }
  69383. /**
  69384. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69385. */
  69386. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69387. private _circleOfConfusion;
  69388. /**
  69389. * @hidden Internal, blurs from high to low
  69390. */
  69391. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69392. private _depthOfFieldBlurY;
  69393. private _dofMerge;
  69394. /**
  69395. * @hidden Internal post processes in depth of field effect
  69396. */
  69397. _effects: Array<PostProcess>;
  69398. /**
  69399. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69400. */
  69401. set focalLength(value: number);
  69402. get focalLength(): number;
  69403. /**
  69404. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69405. */
  69406. set fStop(value: number);
  69407. get fStop(): number;
  69408. /**
  69409. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69410. */
  69411. set focusDistance(value: number);
  69412. get focusDistance(): number;
  69413. /**
  69414. * 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.
  69415. */
  69416. set lensSize(value: number);
  69417. get lensSize(): number;
  69418. /**
  69419. * Creates a new instance DepthOfFieldEffect
  69420. * @param scene The scene the effect belongs to.
  69421. * @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.
  69422. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69423. * @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)
  69424. */
  69425. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69426. /**
  69427. * Get the current class name of the current effet
  69428. * @returns "DepthOfFieldEffect"
  69429. */
  69430. getClassName(): string;
  69431. /**
  69432. * 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.
  69433. */
  69434. set depthTexture(value: RenderTargetTexture);
  69435. /**
  69436. * Disposes each of the internal effects for a given camera.
  69437. * @param camera The camera to dispose the effect on.
  69438. */
  69439. disposeEffects(camera: Camera): void;
  69440. /**
  69441. * @hidden Internal
  69442. */
  69443. _updateEffects(): void;
  69444. /**
  69445. * Internal
  69446. * @returns if all the contained post processes are ready.
  69447. * @hidden
  69448. */
  69449. _isReady(): boolean;
  69450. }
  69451. }
  69452. declare module BABYLON {
  69453. /** @hidden */
  69454. export var displayPassPixelShader: {
  69455. name: string;
  69456. shader: string;
  69457. };
  69458. }
  69459. declare module BABYLON {
  69460. /**
  69461. * DisplayPassPostProcess which produces an output the same as it's input
  69462. */
  69463. export class DisplayPassPostProcess extends PostProcess {
  69464. /**
  69465. * Gets a string identifying the name of the class
  69466. * @returns "DisplayPassPostProcess" string
  69467. */
  69468. getClassName(): string;
  69469. /**
  69470. * Creates the DisplayPassPostProcess
  69471. * @param name The name of the effect.
  69472. * @param options The required width/height ratio to downsize to before computing the render pass.
  69473. * @param camera The camera to apply the render pass to.
  69474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69475. * @param engine The engine which the post process will be applied. (default: current engine)
  69476. * @param reusable If the post process can be reused on the same frame. (default: false)
  69477. */
  69478. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69479. /** @hidden */
  69480. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69481. }
  69482. }
  69483. declare module BABYLON {
  69484. /** @hidden */
  69485. export var filterPixelShader: {
  69486. name: string;
  69487. shader: string;
  69488. };
  69489. }
  69490. declare module BABYLON {
  69491. /**
  69492. * Applies a kernel filter to the image
  69493. */
  69494. export class FilterPostProcess extends PostProcess {
  69495. /** The matrix to be applied to the image */
  69496. kernelMatrix: Matrix;
  69497. /**
  69498. * Gets a string identifying the name of the class
  69499. * @returns "FilterPostProcess" string
  69500. */
  69501. getClassName(): string;
  69502. /**
  69503. *
  69504. * @param name The name of the effect.
  69505. * @param kernelMatrix The matrix to be applied to the image
  69506. * @param options The required width/height ratio to downsize to before computing the render pass.
  69507. * @param camera The camera to apply the render pass to.
  69508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69509. * @param engine The engine which the post process will be applied. (default: current engine)
  69510. * @param reusable If the post process can be reused on the same frame. (default: false)
  69511. */
  69512. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69513. /** @hidden */
  69514. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69515. }
  69516. }
  69517. declare module BABYLON {
  69518. /** @hidden */
  69519. export var fxaaPixelShader: {
  69520. name: string;
  69521. shader: string;
  69522. };
  69523. }
  69524. declare module BABYLON {
  69525. /** @hidden */
  69526. export var fxaaVertexShader: {
  69527. name: string;
  69528. shader: string;
  69529. };
  69530. }
  69531. declare module BABYLON {
  69532. /**
  69533. * Fxaa post process
  69534. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69535. */
  69536. export class FxaaPostProcess extends PostProcess {
  69537. /**
  69538. * Gets a string identifying the name of the class
  69539. * @returns "FxaaPostProcess" string
  69540. */
  69541. getClassName(): string;
  69542. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69543. private _getDefines;
  69544. /** @hidden */
  69545. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69546. }
  69547. }
  69548. declare module BABYLON {
  69549. /** @hidden */
  69550. export var grainPixelShader: {
  69551. name: string;
  69552. shader: string;
  69553. };
  69554. }
  69555. declare module BABYLON {
  69556. /**
  69557. * The GrainPostProcess adds noise to the image at mid luminance levels
  69558. */
  69559. export class GrainPostProcess extends PostProcess {
  69560. /**
  69561. * The intensity of the grain added (default: 30)
  69562. */
  69563. intensity: number;
  69564. /**
  69565. * If the grain should be randomized on every frame
  69566. */
  69567. animated: boolean;
  69568. /**
  69569. * Gets a string identifying the name of the class
  69570. * @returns "GrainPostProcess" string
  69571. */
  69572. getClassName(): string;
  69573. /**
  69574. * Creates a new instance of @see GrainPostProcess
  69575. * @param name The name of the effect.
  69576. * @param options The required width/height ratio to downsize to before computing the render pass.
  69577. * @param camera The camera to apply the render pass to.
  69578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69579. * @param engine The engine which the post process will be applied. (default: current engine)
  69580. * @param reusable If the post process can be reused on the same frame. (default: false)
  69581. * @param textureType Type of textures used when performing the post process. (default: 0)
  69582. * @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)
  69583. */
  69584. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69585. /** @hidden */
  69586. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69587. }
  69588. }
  69589. declare module BABYLON {
  69590. /** @hidden */
  69591. export var highlightsPixelShader: {
  69592. name: string;
  69593. shader: string;
  69594. };
  69595. }
  69596. declare module BABYLON {
  69597. /**
  69598. * Extracts highlights from the image
  69599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69600. */
  69601. export class HighlightsPostProcess extends PostProcess {
  69602. /**
  69603. * Gets a string identifying the name of the class
  69604. * @returns "HighlightsPostProcess" string
  69605. */
  69606. getClassName(): string;
  69607. /**
  69608. * Extracts highlights from the image
  69609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69610. * @param name The name of the effect.
  69611. * @param options The required width/height ratio to downsize to before computing the render pass.
  69612. * @param camera The camera to apply the render pass to.
  69613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69614. * @param engine The engine which the post process will be applied. (default: current engine)
  69615. * @param reusable If the post process can be reused on the same frame. (default: false)
  69616. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69617. */
  69618. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69619. }
  69620. }
  69621. declare module BABYLON {
  69622. /** @hidden */
  69623. export var mrtFragmentDeclaration: {
  69624. name: string;
  69625. shader: string;
  69626. };
  69627. }
  69628. declare module BABYLON {
  69629. /** @hidden */
  69630. export var geometryPixelShader: {
  69631. name: string;
  69632. shader: string;
  69633. };
  69634. }
  69635. declare module BABYLON {
  69636. /** @hidden */
  69637. export var geometryVertexShader: {
  69638. name: string;
  69639. shader: string;
  69640. };
  69641. }
  69642. declare module BABYLON {
  69643. /** @hidden */
  69644. interface ISavedTransformationMatrix {
  69645. world: Matrix;
  69646. viewProjection: Matrix;
  69647. }
  69648. /**
  69649. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69650. */
  69651. export class GeometryBufferRenderer {
  69652. /**
  69653. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69654. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69655. */
  69656. static readonly POSITION_TEXTURE_TYPE: number;
  69657. /**
  69658. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69659. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69660. */
  69661. static readonly VELOCITY_TEXTURE_TYPE: number;
  69662. /**
  69663. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69664. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69665. */
  69666. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69667. /**
  69668. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69669. * in order to compute objects velocities when enableVelocity is set to "true"
  69670. * @hidden
  69671. */
  69672. _previousTransformationMatrices: {
  69673. [index: number]: ISavedTransformationMatrix;
  69674. };
  69675. /**
  69676. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69677. * in order to compute objects velocities when enableVelocity is set to "true"
  69678. * @hidden
  69679. */
  69680. _previousBonesTransformationMatrices: {
  69681. [index: number]: Float32Array;
  69682. };
  69683. /**
  69684. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69685. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69686. */
  69687. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69688. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69689. renderTransparentMeshes: boolean;
  69690. private _scene;
  69691. private _resizeObserver;
  69692. private _multiRenderTarget;
  69693. private _ratio;
  69694. private _enablePosition;
  69695. private _enableVelocity;
  69696. private _enableReflectivity;
  69697. private _positionIndex;
  69698. private _velocityIndex;
  69699. private _reflectivityIndex;
  69700. protected _effect: Effect;
  69701. protected _cachedDefines: string;
  69702. /**
  69703. * Set the render list (meshes to be rendered) used in the G buffer.
  69704. */
  69705. set renderList(meshes: Mesh[]);
  69706. /**
  69707. * Gets wether or not G buffer are supported by the running hardware.
  69708. * This requires draw buffer supports
  69709. */
  69710. get isSupported(): boolean;
  69711. /**
  69712. * Returns the index of the given texture type in the G-Buffer textures array
  69713. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69714. * @returns the index of the given texture type in the G-Buffer textures array
  69715. */
  69716. getTextureIndex(textureType: number): number;
  69717. /**
  69718. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69719. */
  69720. get enablePosition(): boolean;
  69721. /**
  69722. * Sets whether or not objects positions are enabled for the G buffer.
  69723. */
  69724. set enablePosition(enable: boolean);
  69725. /**
  69726. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69727. */
  69728. get enableVelocity(): boolean;
  69729. /**
  69730. * Sets wether or not objects velocities are enabled for the G buffer.
  69731. */
  69732. set enableVelocity(enable: boolean);
  69733. /**
  69734. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69735. */
  69736. get enableReflectivity(): boolean;
  69737. /**
  69738. * Sets wether or not objects roughness are enabled for the G buffer.
  69739. */
  69740. set enableReflectivity(enable: boolean);
  69741. /**
  69742. * Gets the scene associated with the buffer.
  69743. */
  69744. get scene(): Scene;
  69745. /**
  69746. * Gets the ratio used by the buffer during its creation.
  69747. * How big is the buffer related to the main canvas.
  69748. */
  69749. get ratio(): number;
  69750. /** @hidden */
  69751. static _SceneComponentInitialization: (scene: Scene) => void;
  69752. /**
  69753. * Creates a new G Buffer for the scene
  69754. * @param scene The scene the buffer belongs to
  69755. * @param ratio How big is the buffer related to the main canvas.
  69756. */
  69757. constructor(scene: Scene, ratio?: number);
  69758. /**
  69759. * Checks wether everything is ready to render a submesh to the G buffer.
  69760. * @param subMesh the submesh to check readiness for
  69761. * @param useInstances is the mesh drawn using instance or not
  69762. * @returns true if ready otherwise false
  69763. */
  69764. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69765. /**
  69766. * Gets the current underlying G Buffer.
  69767. * @returns the buffer
  69768. */
  69769. getGBuffer(): MultiRenderTarget;
  69770. /**
  69771. * Gets the number of samples used to render the buffer (anti aliasing).
  69772. */
  69773. get samples(): number;
  69774. /**
  69775. * Sets the number of samples used to render the buffer (anti aliasing).
  69776. */
  69777. set samples(value: number);
  69778. /**
  69779. * Disposes the renderer and frees up associated resources.
  69780. */
  69781. dispose(): void;
  69782. protected _createRenderTargets(): void;
  69783. private _copyBonesTransformationMatrices;
  69784. }
  69785. }
  69786. declare module BABYLON {
  69787. interface Scene {
  69788. /** @hidden (Backing field) */
  69789. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69790. /**
  69791. * Gets or Sets the current geometry buffer associated to the scene.
  69792. */
  69793. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69794. /**
  69795. * Enables a GeometryBufferRender and associates it with the scene
  69796. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69797. * @returns the GeometryBufferRenderer
  69798. */
  69799. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69800. /**
  69801. * Disables the GeometryBufferRender associated with the scene
  69802. */
  69803. disableGeometryBufferRenderer(): void;
  69804. }
  69805. /**
  69806. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69807. * in several rendering techniques.
  69808. */
  69809. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69810. /**
  69811. * The component name helpful to identify the component in the list of scene components.
  69812. */
  69813. readonly name: string;
  69814. /**
  69815. * The scene the component belongs to.
  69816. */
  69817. scene: Scene;
  69818. /**
  69819. * Creates a new instance of the component for the given scene
  69820. * @param scene Defines the scene to register the component in
  69821. */
  69822. constructor(scene: Scene);
  69823. /**
  69824. * Registers the component in a given scene
  69825. */
  69826. register(): void;
  69827. /**
  69828. * Rebuilds the elements related to this component in case of
  69829. * context lost for instance.
  69830. */
  69831. rebuild(): void;
  69832. /**
  69833. * Disposes the component and the associated ressources
  69834. */
  69835. dispose(): void;
  69836. private _gatherRenderTargets;
  69837. }
  69838. }
  69839. declare module BABYLON {
  69840. /** @hidden */
  69841. export var motionBlurPixelShader: {
  69842. name: string;
  69843. shader: string;
  69844. };
  69845. }
  69846. declare module BABYLON {
  69847. /**
  69848. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69849. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69850. * As an example, all you have to do is to create the post-process:
  69851. * var mb = new BABYLON.MotionBlurPostProcess(
  69852. * 'mb', // The name of the effect.
  69853. * scene, // The scene containing the objects to blur according to their velocity.
  69854. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69855. * camera // The camera to apply the render pass to.
  69856. * );
  69857. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69858. */
  69859. export class MotionBlurPostProcess extends PostProcess {
  69860. /**
  69861. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69862. */
  69863. motionStrength: number;
  69864. /**
  69865. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69866. */
  69867. get motionBlurSamples(): number;
  69868. /**
  69869. * Sets the number of iterations to be used for motion blur quality
  69870. */
  69871. set motionBlurSamples(samples: number);
  69872. private _motionBlurSamples;
  69873. private _geometryBufferRenderer;
  69874. /**
  69875. * Gets a string identifying the name of the class
  69876. * @returns "MotionBlurPostProcess" string
  69877. */
  69878. getClassName(): string;
  69879. /**
  69880. * Creates a new instance MotionBlurPostProcess
  69881. * @param name The name of the effect.
  69882. * @param scene The scene containing the objects to blur according to their velocity.
  69883. * @param options The required width/height ratio to downsize to before computing the render pass.
  69884. * @param camera The camera to apply the render pass to.
  69885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69886. * @param engine The engine which the post process will be applied. (default: current engine)
  69887. * @param reusable If the post process can be reused on the same frame. (default: false)
  69888. * @param textureType Type of textures used when performing the post process. (default: 0)
  69889. * @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)
  69890. */
  69891. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69892. /**
  69893. * Excludes the given skinned mesh from computing bones velocities.
  69894. * 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.
  69895. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69896. */
  69897. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69898. /**
  69899. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69900. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69901. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69902. */
  69903. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69904. /**
  69905. * Disposes the post process.
  69906. * @param camera The camera to dispose the post process on.
  69907. */
  69908. dispose(camera?: Camera): void;
  69909. /** @hidden */
  69910. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  69911. }
  69912. }
  69913. declare module BABYLON {
  69914. /** @hidden */
  69915. export var refractionPixelShader: {
  69916. name: string;
  69917. shader: string;
  69918. };
  69919. }
  69920. declare module BABYLON {
  69921. /**
  69922. * Post process which applies a refractin texture
  69923. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69924. */
  69925. export class RefractionPostProcess extends PostProcess {
  69926. private _refTexture;
  69927. private _ownRefractionTexture;
  69928. /** the base color of the refraction (used to taint the rendering) */
  69929. color: Color3;
  69930. /** simulated refraction depth */
  69931. depth: number;
  69932. /** the coefficient of the base color (0 to remove base color tainting) */
  69933. colorLevel: number;
  69934. /** Gets the url used to load the refraction texture */
  69935. refractionTextureUrl: string;
  69936. /**
  69937. * Gets or sets the refraction texture
  69938. * Please note that you are responsible for disposing the texture if you set it manually
  69939. */
  69940. get refractionTexture(): Texture;
  69941. set refractionTexture(value: Texture);
  69942. /**
  69943. * Gets a string identifying the name of the class
  69944. * @returns "RefractionPostProcess" string
  69945. */
  69946. getClassName(): string;
  69947. /**
  69948. * Initializes the RefractionPostProcess
  69949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69950. * @param name The name of the effect.
  69951. * @param refractionTextureUrl Url of the refraction texture to use
  69952. * @param color the base color of the refraction (used to taint the rendering)
  69953. * @param depth simulated refraction depth
  69954. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69955. * @param camera The camera to apply the render pass to.
  69956. * @param options The required width/height ratio to downsize to before computing the render pass.
  69957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69958. * @param engine The engine which the post process will be applied. (default: current engine)
  69959. * @param reusable If the post process can be reused on the same frame. (default: false)
  69960. */
  69961. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69962. /**
  69963. * Disposes of the post process
  69964. * @param camera Camera to dispose post process on
  69965. */
  69966. dispose(camera: Camera): void;
  69967. /** @hidden */
  69968. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  69969. }
  69970. }
  69971. declare module BABYLON {
  69972. /** @hidden */
  69973. export var sharpenPixelShader: {
  69974. name: string;
  69975. shader: string;
  69976. };
  69977. }
  69978. declare module BABYLON {
  69979. /**
  69980. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69981. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69982. */
  69983. export class SharpenPostProcess extends PostProcess {
  69984. /**
  69985. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69986. */
  69987. colorAmount: number;
  69988. /**
  69989. * How much sharpness should be applied (default: 0.3)
  69990. */
  69991. edgeAmount: number;
  69992. /**
  69993. * Gets a string identifying the name of the class
  69994. * @returns "SharpenPostProcess" string
  69995. */
  69996. getClassName(): string;
  69997. /**
  69998. * Creates a new instance ConvolutionPostProcess
  69999. * @param name The name of the effect.
  70000. * @param options The required width/height ratio to downsize to before computing the render pass.
  70001. * @param camera The camera to apply the render pass to.
  70002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70003. * @param engine The engine which the post process will be applied. (default: current engine)
  70004. * @param reusable If the post process can be reused on the same frame. (default: false)
  70005. * @param textureType Type of textures used when performing the post process. (default: 0)
  70006. * @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)
  70007. */
  70008. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70009. /** @hidden */
  70010. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70011. }
  70012. }
  70013. declare module BABYLON {
  70014. /**
  70015. * PostProcessRenderPipeline
  70016. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70017. */
  70018. export class PostProcessRenderPipeline {
  70019. private engine;
  70020. private _renderEffects;
  70021. private _renderEffectsForIsolatedPass;
  70022. /**
  70023. * List of inspectable custom properties (used by the Inspector)
  70024. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70025. */
  70026. inspectableCustomProperties: IInspectable[];
  70027. /**
  70028. * @hidden
  70029. */
  70030. protected _cameras: Camera[];
  70031. /** @hidden */
  70032. _name: string;
  70033. /**
  70034. * Gets pipeline name
  70035. */
  70036. get name(): string;
  70037. /** Gets the list of attached cameras */
  70038. get cameras(): Camera[];
  70039. /**
  70040. * Initializes a PostProcessRenderPipeline
  70041. * @param engine engine to add the pipeline to
  70042. * @param name name of the pipeline
  70043. */
  70044. constructor(engine: Engine, name: string);
  70045. /**
  70046. * Gets the class name
  70047. * @returns "PostProcessRenderPipeline"
  70048. */
  70049. getClassName(): string;
  70050. /**
  70051. * If all the render effects in the pipeline are supported
  70052. */
  70053. get isSupported(): boolean;
  70054. /**
  70055. * Adds an effect to the pipeline
  70056. * @param renderEffect the effect to add
  70057. */
  70058. addEffect(renderEffect: PostProcessRenderEffect): void;
  70059. /** @hidden */
  70060. _rebuild(): void;
  70061. /** @hidden */
  70062. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70063. /** @hidden */
  70064. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70065. /** @hidden */
  70066. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70067. /** @hidden */
  70068. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70069. /** @hidden */
  70070. _attachCameras(cameras: Camera, unique: boolean): void;
  70071. /** @hidden */
  70072. _attachCameras(cameras: Camera[], unique: boolean): void;
  70073. /** @hidden */
  70074. _detachCameras(cameras: Camera): void;
  70075. /** @hidden */
  70076. _detachCameras(cameras: Nullable<Camera[]>): void;
  70077. /** @hidden */
  70078. _update(): void;
  70079. /** @hidden */
  70080. _reset(): void;
  70081. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70082. /**
  70083. * Sets the required values to the prepass renderer.
  70084. * @param prePassRenderer defines the prepass renderer to setup.
  70085. * @returns true if the pre pass is needed.
  70086. */
  70087. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70088. /**
  70089. * Disposes of the pipeline
  70090. */
  70091. dispose(): void;
  70092. }
  70093. }
  70094. declare module BABYLON {
  70095. /**
  70096. * PostProcessRenderPipelineManager class
  70097. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70098. */
  70099. export class PostProcessRenderPipelineManager {
  70100. private _renderPipelines;
  70101. /**
  70102. * Initializes a PostProcessRenderPipelineManager
  70103. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70104. */
  70105. constructor();
  70106. /**
  70107. * Gets the list of supported render pipelines
  70108. */
  70109. get supportedPipelines(): PostProcessRenderPipeline[];
  70110. /**
  70111. * Adds a pipeline to the manager
  70112. * @param renderPipeline The pipeline to add
  70113. */
  70114. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70115. /**
  70116. * Attaches a camera to the pipeline
  70117. * @param renderPipelineName The name of the pipeline to attach to
  70118. * @param cameras the camera to attach
  70119. * @param unique if the camera can be attached multiple times to the pipeline
  70120. */
  70121. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70122. /**
  70123. * Detaches a camera from the pipeline
  70124. * @param renderPipelineName The name of the pipeline to detach from
  70125. * @param cameras the camera to detach
  70126. */
  70127. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70128. /**
  70129. * Enables an effect by name on a pipeline
  70130. * @param renderPipelineName the name of the pipeline to enable the effect in
  70131. * @param renderEffectName the name of the effect to enable
  70132. * @param cameras the cameras that the effect should be enabled on
  70133. */
  70134. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70135. /**
  70136. * Disables an effect by name on a pipeline
  70137. * @param renderPipelineName the name of the pipeline to disable the effect in
  70138. * @param renderEffectName the name of the effect to disable
  70139. * @param cameras the cameras that the effect should be disabled on
  70140. */
  70141. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70142. /**
  70143. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70144. */
  70145. update(): void;
  70146. /** @hidden */
  70147. _rebuild(): void;
  70148. /**
  70149. * Disposes of the manager and pipelines
  70150. */
  70151. dispose(): void;
  70152. }
  70153. }
  70154. declare module BABYLON {
  70155. interface Scene {
  70156. /** @hidden (Backing field) */
  70157. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70158. /**
  70159. * Gets the postprocess render pipeline manager
  70160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70161. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70162. */
  70163. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70164. }
  70165. /**
  70166. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70167. */
  70168. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70169. /**
  70170. * The component name helpfull to identify the component in the list of scene components.
  70171. */
  70172. readonly name: string;
  70173. /**
  70174. * The scene the component belongs to.
  70175. */
  70176. scene: Scene;
  70177. /**
  70178. * Creates a new instance of the component for the given scene
  70179. * @param scene Defines the scene to register the component in
  70180. */
  70181. constructor(scene: Scene);
  70182. /**
  70183. * Registers the component in a given scene
  70184. */
  70185. register(): void;
  70186. /**
  70187. * Rebuilds the elements related to this component in case of
  70188. * context lost for instance.
  70189. */
  70190. rebuild(): void;
  70191. /**
  70192. * Disposes the component and the associated ressources
  70193. */
  70194. dispose(): void;
  70195. private _gatherRenderTargets;
  70196. }
  70197. }
  70198. declare module BABYLON {
  70199. /**
  70200. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70201. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70202. */
  70203. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70204. private _scene;
  70205. private _camerasToBeAttached;
  70206. /**
  70207. * ID of the sharpen post process,
  70208. */
  70209. private readonly SharpenPostProcessId;
  70210. /**
  70211. * @ignore
  70212. * ID of the image processing post process;
  70213. */
  70214. readonly ImageProcessingPostProcessId: string;
  70215. /**
  70216. * @ignore
  70217. * ID of the Fast Approximate Anti-Aliasing post process;
  70218. */
  70219. readonly FxaaPostProcessId: string;
  70220. /**
  70221. * ID of the chromatic aberration post process,
  70222. */
  70223. private readonly ChromaticAberrationPostProcessId;
  70224. /**
  70225. * ID of the grain post process
  70226. */
  70227. private readonly GrainPostProcessId;
  70228. /**
  70229. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70230. */
  70231. sharpen: SharpenPostProcess;
  70232. private _sharpenEffect;
  70233. private bloom;
  70234. /**
  70235. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70236. */
  70237. depthOfField: DepthOfFieldEffect;
  70238. /**
  70239. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70240. */
  70241. fxaa: FxaaPostProcess;
  70242. /**
  70243. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70244. */
  70245. imageProcessing: ImageProcessingPostProcess;
  70246. /**
  70247. * Chromatic aberration post process which will shift rgb colors in the image
  70248. */
  70249. chromaticAberration: ChromaticAberrationPostProcess;
  70250. private _chromaticAberrationEffect;
  70251. /**
  70252. * Grain post process which add noise to the image
  70253. */
  70254. grain: GrainPostProcess;
  70255. private _grainEffect;
  70256. /**
  70257. * Glow post process which adds a glow to emissive areas of the image
  70258. */
  70259. private _glowLayer;
  70260. /**
  70261. * Animations which can be used to tweak settings over a period of time
  70262. */
  70263. animations: Animation[];
  70264. private _imageProcessingConfigurationObserver;
  70265. private _sharpenEnabled;
  70266. private _bloomEnabled;
  70267. private _depthOfFieldEnabled;
  70268. private _depthOfFieldBlurLevel;
  70269. private _fxaaEnabled;
  70270. private _imageProcessingEnabled;
  70271. private _defaultPipelineTextureType;
  70272. private _bloomScale;
  70273. private _chromaticAberrationEnabled;
  70274. private _grainEnabled;
  70275. private _buildAllowed;
  70276. /**
  70277. * Gets active scene
  70278. */
  70279. get scene(): Scene;
  70280. /**
  70281. * Enable or disable the sharpen process from the pipeline
  70282. */
  70283. set sharpenEnabled(enabled: boolean);
  70284. get sharpenEnabled(): boolean;
  70285. private _resizeObserver;
  70286. private _hardwareScaleLevel;
  70287. private _bloomKernel;
  70288. /**
  70289. * Specifies the size of the bloom blur kernel, relative to the final output size
  70290. */
  70291. get bloomKernel(): number;
  70292. set bloomKernel(value: number);
  70293. /**
  70294. * Specifies the weight of the bloom in the final rendering
  70295. */
  70296. private _bloomWeight;
  70297. /**
  70298. * Specifies the luma threshold for the area that will be blurred by the bloom
  70299. */
  70300. private _bloomThreshold;
  70301. private _hdr;
  70302. /**
  70303. * The strength of the bloom.
  70304. */
  70305. set bloomWeight(value: number);
  70306. get bloomWeight(): number;
  70307. /**
  70308. * The strength of the bloom.
  70309. */
  70310. set bloomThreshold(value: number);
  70311. get bloomThreshold(): number;
  70312. /**
  70313. * The scale of the bloom, lower value will provide better performance.
  70314. */
  70315. set bloomScale(value: number);
  70316. get bloomScale(): number;
  70317. /**
  70318. * Enable or disable the bloom from the pipeline
  70319. */
  70320. set bloomEnabled(enabled: boolean);
  70321. get bloomEnabled(): boolean;
  70322. private _rebuildBloom;
  70323. /**
  70324. * If the depth of field is enabled.
  70325. */
  70326. get depthOfFieldEnabled(): boolean;
  70327. set depthOfFieldEnabled(enabled: boolean);
  70328. /**
  70329. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70330. */
  70331. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70332. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70333. /**
  70334. * If the anti aliasing is enabled.
  70335. */
  70336. set fxaaEnabled(enabled: boolean);
  70337. get fxaaEnabled(): boolean;
  70338. private _samples;
  70339. /**
  70340. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70341. */
  70342. set samples(sampleCount: number);
  70343. get samples(): number;
  70344. /**
  70345. * If image processing is enabled.
  70346. */
  70347. set imageProcessingEnabled(enabled: boolean);
  70348. get imageProcessingEnabled(): boolean;
  70349. /**
  70350. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70351. */
  70352. set glowLayerEnabled(enabled: boolean);
  70353. get glowLayerEnabled(): boolean;
  70354. /**
  70355. * Gets the glow layer (or null if not defined)
  70356. */
  70357. get glowLayer(): Nullable<GlowLayer>;
  70358. /**
  70359. * Enable or disable the chromaticAberration process from the pipeline
  70360. */
  70361. set chromaticAberrationEnabled(enabled: boolean);
  70362. get chromaticAberrationEnabled(): boolean;
  70363. /**
  70364. * Enable or disable the grain process from the pipeline
  70365. */
  70366. set grainEnabled(enabled: boolean);
  70367. get grainEnabled(): boolean;
  70368. /**
  70369. * @constructor
  70370. * @param name - The rendering pipeline name (default: "")
  70371. * @param hdr - If high dynamic range textures should be used (default: true)
  70372. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70373. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70374. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70375. */
  70376. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70377. /**
  70378. * Get the class name
  70379. * @returns "DefaultRenderingPipeline"
  70380. */
  70381. getClassName(): string;
  70382. /**
  70383. * Force the compilation of the entire pipeline.
  70384. */
  70385. prepare(): void;
  70386. private _hasCleared;
  70387. private _prevPostProcess;
  70388. private _prevPrevPostProcess;
  70389. private _setAutoClearAndTextureSharing;
  70390. private _depthOfFieldSceneObserver;
  70391. private _buildPipeline;
  70392. private _disposePostProcesses;
  70393. /**
  70394. * Adds a camera to the pipeline
  70395. * @param camera the camera to be added
  70396. */
  70397. addCamera(camera: Camera): void;
  70398. /**
  70399. * Removes a camera from the pipeline
  70400. * @param camera the camera to remove
  70401. */
  70402. removeCamera(camera: Camera): void;
  70403. /**
  70404. * Dispose of the pipeline and stop all post processes
  70405. */
  70406. dispose(): void;
  70407. /**
  70408. * Serialize the rendering pipeline (Used when exporting)
  70409. * @returns the serialized object
  70410. */
  70411. serialize(): any;
  70412. /**
  70413. * Parse the serialized pipeline
  70414. * @param source Source pipeline.
  70415. * @param scene The scene to load the pipeline to.
  70416. * @param rootUrl The URL of the serialized pipeline.
  70417. * @returns An instantiated pipeline from the serialized object.
  70418. */
  70419. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70420. }
  70421. }
  70422. declare module BABYLON {
  70423. /** @hidden */
  70424. export var lensHighlightsPixelShader: {
  70425. name: string;
  70426. shader: string;
  70427. };
  70428. }
  70429. declare module BABYLON {
  70430. /** @hidden */
  70431. export var depthOfFieldPixelShader: {
  70432. name: string;
  70433. shader: string;
  70434. };
  70435. }
  70436. declare module BABYLON {
  70437. /**
  70438. * BABYLON.JS Chromatic Aberration GLSL Shader
  70439. * Author: Olivier Guyot
  70440. * Separates very slightly R, G and B colors on the edges of the screen
  70441. * Inspired by Francois Tarlier & Martins Upitis
  70442. */
  70443. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70444. /**
  70445. * @ignore
  70446. * The chromatic aberration PostProcess id in the pipeline
  70447. */
  70448. LensChromaticAberrationEffect: string;
  70449. /**
  70450. * @ignore
  70451. * The highlights enhancing PostProcess id in the pipeline
  70452. */
  70453. HighlightsEnhancingEffect: string;
  70454. /**
  70455. * @ignore
  70456. * The depth-of-field PostProcess id in the pipeline
  70457. */
  70458. LensDepthOfFieldEffect: string;
  70459. private _scene;
  70460. private _depthTexture;
  70461. private _grainTexture;
  70462. private _chromaticAberrationPostProcess;
  70463. private _highlightsPostProcess;
  70464. private _depthOfFieldPostProcess;
  70465. private _edgeBlur;
  70466. private _grainAmount;
  70467. private _chromaticAberration;
  70468. private _distortion;
  70469. private _highlightsGain;
  70470. private _highlightsThreshold;
  70471. private _dofDistance;
  70472. private _dofAperture;
  70473. private _dofDarken;
  70474. private _dofPentagon;
  70475. private _blurNoise;
  70476. /**
  70477. * @constructor
  70478. *
  70479. * Effect parameters are as follow:
  70480. * {
  70481. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70482. * edge_blur: number; // from 0 to x (1 for realism)
  70483. * distortion: number; // from 0 to x (1 for realism)
  70484. * grain_amount: number; // from 0 to 1
  70485. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70486. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70487. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70488. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70489. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70490. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70491. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70492. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70493. * }
  70494. * Note: if an effect parameter is unset, effect is disabled
  70495. *
  70496. * @param name The rendering pipeline name
  70497. * @param parameters - An object containing all parameters (see above)
  70498. * @param scene The scene linked to this pipeline
  70499. * @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)
  70500. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70501. */
  70502. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70503. /**
  70504. * Get the class name
  70505. * @returns "LensRenderingPipeline"
  70506. */
  70507. getClassName(): string;
  70508. /**
  70509. * Gets associated scene
  70510. */
  70511. get scene(): Scene;
  70512. /**
  70513. * Gets or sets the edge blur
  70514. */
  70515. get edgeBlur(): number;
  70516. set edgeBlur(value: number);
  70517. /**
  70518. * Gets or sets the grain amount
  70519. */
  70520. get grainAmount(): number;
  70521. set grainAmount(value: number);
  70522. /**
  70523. * Gets or sets the chromatic aberration amount
  70524. */
  70525. get chromaticAberration(): number;
  70526. set chromaticAberration(value: number);
  70527. /**
  70528. * Gets or sets the depth of field aperture
  70529. */
  70530. get dofAperture(): number;
  70531. set dofAperture(value: number);
  70532. /**
  70533. * Gets or sets the edge distortion
  70534. */
  70535. get edgeDistortion(): number;
  70536. set edgeDistortion(value: number);
  70537. /**
  70538. * Gets or sets the depth of field distortion
  70539. */
  70540. get dofDistortion(): number;
  70541. set dofDistortion(value: number);
  70542. /**
  70543. * Gets or sets the darken out of focus amount
  70544. */
  70545. get darkenOutOfFocus(): number;
  70546. set darkenOutOfFocus(value: number);
  70547. /**
  70548. * Gets or sets a boolean indicating if blur noise is enabled
  70549. */
  70550. get blurNoise(): boolean;
  70551. set blurNoise(value: boolean);
  70552. /**
  70553. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70554. */
  70555. get pentagonBokeh(): boolean;
  70556. set pentagonBokeh(value: boolean);
  70557. /**
  70558. * Gets or sets the highlight grain amount
  70559. */
  70560. get highlightsGain(): number;
  70561. set highlightsGain(value: number);
  70562. /**
  70563. * Gets or sets the highlight threshold
  70564. */
  70565. get highlightsThreshold(): number;
  70566. set highlightsThreshold(value: number);
  70567. /**
  70568. * Sets the amount of blur at the edges
  70569. * @param amount blur amount
  70570. */
  70571. setEdgeBlur(amount: number): void;
  70572. /**
  70573. * Sets edge blur to 0
  70574. */
  70575. disableEdgeBlur(): void;
  70576. /**
  70577. * Sets the amout of grain
  70578. * @param amount Amount of grain
  70579. */
  70580. setGrainAmount(amount: number): void;
  70581. /**
  70582. * Set grain amount to 0
  70583. */
  70584. disableGrain(): void;
  70585. /**
  70586. * Sets the chromatic aberration amount
  70587. * @param amount amount of chromatic aberration
  70588. */
  70589. setChromaticAberration(amount: number): void;
  70590. /**
  70591. * Sets chromatic aberration amount to 0
  70592. */
  70593. disableChromaticAberration(): void;
  70594. /**
  70595. * Sets the EdgeDistortion amount
  70596. * @param amount amount of EdgeDistortion
  70597. */
  70598. setEdgeDistortion(amount: number): void;
  70599. /**
  70600. * Sets edge distortion to 0
  70601. */
  70602. disableEdgeDistortion(): void;
  70603. /**
  70604. * Sets the FocusDistance amount
  70605. * @param amount amount of FocusDistance
  70606. */
  70607. setFocusDistance(amount: number): void;
  70608. /**
  70609. * Disables depth of field
  70610. */
  70611. disableDepthOfField(): void;
  70612. /**
  70613. * Sets the Aperture amount
  70614. * @param amount amount of Aperture
  70615. */
  70616. setAperture(amount: number): void;
  70617. /**
  70618. * Sets the DarkenOutOfFocus amount
  70619. * @param amount amount of DarkenOutOfFocus
  70620. */
  70621. setDarkenOutOfFocus(amount: number): void;
  70622. private _pentagonBokehIsEnabled;
  70623. /**
  70624. * Creates a pentagon bokeh effect
  70625. */
  70626. enablePentagonBokeh(): void;
  70627. /**
  70628. * Disables the pentagon bokeh effect
  70629. */
  70630. disablePentagonBokeh(): void;
  70631. /**
  70632. * Enables noise blur
  70633. */
  70634. enableNoiseBlur(): void;
  70635. /**
  70636. * Disables noise blur
  70637. */
  70638. disableNoiseBlur(): void;
  70639. /**
  70640. * Sets the HighlightsGain amount
  70641. * @param amount amount of HighlightsGain
  70642. */
  70643. setHighlightsGain(amount: number): void;
  70644. /**
  70645. * Sets the HighlightsThreshold amount
  70646. * @param amount amount of HighlightsThreshold
  70647. */
  70648. setHighlightsThreshold(amount: number): void;
  70649. /**
  70650. * Disables highlights
  70651. */
  70652. disableHighlights(): void;
  70653. /**
  70654. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70655. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70656. */
  70657. dispose(disableDepthRender?: boolean): void;
  70658. private _createChromaticAberrationPostProcess;
  70659. private _createHighlightsPostProcess;
  70660. private _createDepthOfFieldPostProcess;
  70661. private _createGrainTexture;
  70662. }
  70663. }
  70664. declare module BABYLON {
  70665. /** @hidden */
  70666. export var ssao2PixelShader: {
  70667. name: string;
  70668. shader: string;
  70669. };
  70670. }
  70671. declare module BABYLON {
  70672. /** @hidden */
  70673. export var ssaoCombinePixelShader: {
  70674. name: string;
  70675. shader: string;
  70676. };
  70677. }
  70678. declare module BABYLON {
  70679. /**
  70680. * Render pipeline to produce ssao effect
  70681. */
  70682. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70683. /**
  70684. * @ignore
  70685. * The PassPostProcess id in the pipeline that contains the original scene color
  70686. */
  70687. SSAOOriginalSceneColorEffect: string;
  70688. /**
  70689. * @ignore
  70690. * The SSAO PostProcess id in the pipeline
  70691. */
  70692. SSAORenderEffect: string;
  70693. /**
  70694. * @ignore
  70695. * The horizontal blur PostProcess id in the pipeline
  70696. */
  70697. SSAOBlurHRenderEffect: string;
  70698. /**
  70699. * @ignore
  70700. * The vertical blur PostProcess id in the pipeline
  70701. */
  70702. SSAOBlurVRenderEffect: string;
  70703. /**
  70704. * @ignore
  70705. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70706. */
  70707. SSAOCombineRenderEffect: string;
  70708. /**
  70709. * The output strength of the SSAO post-process. Default value is 1.0.
  70710. */
  70711. totalStrength: number;
  70712. /**
  70713. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70714. */
  70715. maxZ: number;
  70716. /**
  70717. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70718. */
  70719. minZAspect: number;
  70720. private _samples;
  70721. /**
  70722. * Number of samples used for the SSAO calculations. Default value is 8
  70723. */
  70724. set samples(n: number);
  70725. get samples(): number;
  70726. private _textureSamples;
  70727. /**
  70728. * Number of samples to use for antialiasing
  70729. */
  70730. set textureSamples(n: number);
  70731. get textureSamples(): number;
  70732. /**
  70733. * Force rendering the geometry through geometry buffer
  70734. */
  70735. private _forceGeometryBuffer;
  70736. /**
  70737. * Ratio object used for SSAO ratio and blur ratio
  70738. */
  70739. private _ratio;
  70740. /**
  70741. * Dynamically generated sphere sampler.
  70742. */
  70743. private _sampleSphere;
  70744. /**
  70745. * Blur filter offsets
  70746. */
  70747. private _samplerOffsets;
  70748. private _expensiveBlur;
  70749. /**
  70750. * If bilateral blur should be used
  70751. */
  70752. set expensiveBlur(b: boolean);
  70753. get expensiveBlur(): boolean;
  70754. /**
  70755. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70756. */
  70757. radius: number;
  70758. /**
  70759. * The base color of the SSAO post-process
  70760. * The final result is "base + ssao" between [0, 1]
  70761. */
  70762. base: number;
  70763. /**
  70764. * Support test.
  70765. */
  70766. static get IsSupported(): boolean;
  70767. private _scene;
  70768. private _randomTexture;
  70769. private _originalColorPostProcess;
  70770. private _ssaoPostProcess;
  70771. private _blurHPostProcess;
  70772. private _blurVPostProcess;
  70773. private _ssaoCombinePostProcess;
  70774. private _prePassRenderer;
  70775. /**
  70776. * Gets active scene
  70777. */
  70778. get scene(): Scene;
  70779. /**
  70780. * @constructor
  70781. * @param name The rendering pipeline name
  70782. * @param scene The scene linked to this pipeline
  70783. * @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 }
  70784. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70785. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70786. */
  70787. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70788. /**
  70789. * Get the class name
  70790. * @returns "SSAO2RenderingPipeline"
  70791. */
  70792. getClassName(): string;
  70793. /**
  70794. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70795. */
  70796. dispose(disableGeometryBufferRenderer?: boolean): void;
  70797. private _createBlurPostProcess;
  70798. /** @hidden */
  70799. _rebuild(): void;
  70800. private _bits;
  70801. private _radicalInverse_VdC;
  70802. private _hammersley;
  70803. private _hemisphereSample_uniform;
  70804. private _generateHemisphere;
  70805. private _getDefinesForSSAO;
  70806. private _createSSAOPostProcess;
  70807. private _createSSAOCombinePostProcess;
  70808. private _createRandomTexture;
  70809. /**
  70810. * Serialize the rendering pipeline (Used when exporting)
  70811. * @returns the serialized object
  70812. */
  70813. serialize(): any;
  70814. /**
  70815. * Parse the serialized pipeline
  70816. * @param source Source pipeline.
  70817. * @param scene The scene to load the pipeline to.
  70818. * @param rootUrl The URL of the serialized pipeline.
  70819. * @returns An instantiated pipeline from the serialized object.
  70820. */
  70821. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70822. /**
  70823. * Sets the required values to the prepass renderer.
  70824. * @param prePassRenderer defines the prepass renderer to setup
  70825. * @returns true if the pre pass is needed.
  70826. */
  70827. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70828. }
  70829. }
  70830. declare module BABYLON {
  70831. /** @hidden */
  70832. export var ssaoPixelShader: {
  70833. name: string;
  70834. shader: string;
  70835. };
  70836. }
  70837. declare module BABYLON {
  70838. /**
  70839. * Render pipeline to produce ssao effect
  70840. */
  70841. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70842. /**
  70843. * @ignore
  70844. * The PassPostProcess id in the pipeline that contains the original scene color
  70845. */
  70846. SSAOOriginalSceneColorEffect: string;
  70847. /**
  70848. * @ignore
  70849. * The SSAO PostProcess id in the pipeline
  70850. */
  70851. SSAORenderEffect: string;
  70852. /**
  70853. * @ignore
  70854. * The horizontal blur PostProcess id in the pipeline
  70855. */
  70856. SSAOBlurHRenderEffect: string;
  70857. /**
  70858. * @ignore
  70859. * The vertical blur PostProcess id in the pipeline
  70860. */
  70861. SSAOBlurVRenderEffect: string;
  70862. /**
  70863. * @ignore
  70864. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70865. */
  70866. SSAOCombineRenderEffect: string;
  70867. /**
  70868. * The output strength of the SSAO post-process. Default value is 1.0.
  70869. */
  70870. totalStrength: number;
  70871. /**
  70872. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70873. */
  70874. radius: number;
  70875. /**
  70876. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70877. * Must not be equal to fallOff and superior to fallOff.
  70878. * Default value is 0.0075
  70879. */
  70880. area: number;
  70881. /**
  70882. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70883. * Must not be equal to area and inferior to area.
  70884. * Default value is 0.000001
  70885. */
  70886. fallOff: number;
  70887. /**
  70888. * The base color of the SSAO post-process
  70889. * The final result is "base + ssao" between [0, 1]
  70890. */
  70891. base: number;
  70892. private _scene;
  70893. private _depthTexture;
  70894. private _randomTexture;
  70895. private _originalColorPostProcess;
  70896. private _ssaoPostProcess;
  70897. private _blurHPostProcess;
  70898. private _blurVPostProcess;
  70899. private _ssaoCombinePostProcess;
  70900. private _firstUpdate;
  70901. /**
  70902. * Gets active scene
  70903. */
  70904. get scene(): Scene;
  70905. /**
  70906. * @constructor
  70907. * @param name - The rendering pipeline name
  70908. * @param scene - The scene linked to this pipeline
  70909. * @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 }
  70910. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70911. */
  70912. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70913. /**
  70914. * Get the class name
  70915. * @returns "SSAORenderingPipeline"
  70916. */
  70917. getClassName(): string;
  70918. /**
  70919. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70920. */
  70921. dispose(disableDepthRender?: boolean): void;
  70922. private _createBlurPostProcess;
  70923. /** @hidden */
  70924. _rebuild(): void;
  70925. private _createSSAOPostProcess;
  70926. private _createSSAOCombinePostProcess;
  70927. private _createRandomTexture;
  70928. }
  70929. }
  70930. declare module BABYLON {
  70931. /** @hidden */
  70932. export var screenSpaceReflectionPixelShader: {
  70933. name: string;
  70934. shader: string;
  70935. };
  70936. }
  70937. declare module BABYLON {
  70938. /**
  70939. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70940. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70941. */
  70942. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70943. /**
  70944. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70945. */
  70946. threshold: number;
  70947. /**
  70948. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70949. */
  70950. strength: number;
  70951. /**
  70952. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70953. */
  70954. reflectionSpecularFalloffExponent: number;
  70955. /**
  70956. * 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]
  70957. */
  70958. step: number;
  70959. /**
  70960. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70961. */
  70962. roughnessFactor: number;
  70963. private _geometryBufferRenderer;
  70964. private _enableSmoothReflections;
  70965. private _reflectionSamples;
  70966. private _smoothSteps;
  70967. /**
  70968. * Gets a string identifying the name of the class
  70969. * @returns "ScreenSpaceReflectionPostProcess" string
  70970. */
  70971. getClassName(): string;
  70972. /**
  70973. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70974. * @param name The name of the effect.
  70975. * @param scene The scene containing the objects to calculate reflections.
  70976. * @param options The required width/height ratio to downsize to before computing the render pass.
  70977. * @param camera The camera to apply the render pass to.
  70978. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70979. * @param engine The engine which the post process will be applied. (default: current engine)
  70980. * @param reusable If the post process can be reused on the same frame. (default: false)
  70981. * @param textureType Type of textures used when performing the post process. (default: 0)
  70982. * @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)
  70983. */
  70984. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70985. /**
  70986. * Gets wether or not smoothing reflections is enabled.
  70987. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70988. */
  70989. get enableSmoothReflections(): boolean;
  70990. /**
  70991. * Sets wether or not smoothing reflections is enabled.
  70992. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70993. */
  70994. set enableSmoothReflections(enabled: boolean);
  70995. /**
  70996. * Gets the number of samples taken while computing reflections. More samples count is high,
  70997. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70998. */
  70999. get reflectionSamples(): number;
  71000. /**
  71001. * Sets the number of samples taken while computing reflections. More samples count is high,
  71002. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71003. */
  71004. set reflectionSamples(samples: number);
  71005. /**
  71006. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71007. * more the post-process will require GPU power and can generate a drop in FPS.
  71008. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71009. */
  71010. get smoothSteps(): number;
  71011. set smoothSteps(steps: number);
  71012. private _updateEffectDefines;
  71013. /** @hidden */
  71014. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71015. }
  71016. }
  71017. declare module BABYLON {
  71018. /** @hidden */
  71019. export var standardPixelShader: {
  71020. name: string;
  71021. shader: string;
  71022. };
  71023. }
  71024. declare module BABYLON {
  71025. /**
  71026. * Standard rendering pipeline
  71027. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71028. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71029. */
  71030. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71031. /**
  71032. * Public members
  71033. */
  71034. /**
  71035. * Post-process which contains the original scene color before the pipeline applies all the effects
  71036. */
  71037. originalPostProcess: Nullable<PostProcess>;
  71038. /**
  71039. * Post-process used to down scale an image x4
  71040. */
  71041. downSampleX4PostProcess: Nullable<PostProcess>;
  71042. /**
  71043. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71044. */
  71045. brightPassPostProcess: Nullable<PostProcess>;
  71046. /**
  71047. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71048. */
  71049. blurHPostProcesses: PostProcess[];
  71050. /**
  71051. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71052. */
  71053. blurVPostProcesses: PostProcess[];
  71054. /**
  71055. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71056. */
  71057. textureAdderPostProcess: Nullable<PostProcess>;
  71058. /**
  71059. * Post-process used to create volumetric lighting effect
  71060. */
  71061. volumetricLightPostProcess: Nullable<PostProcess>;
  71062. /**
  71063. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71064. */
  71065. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71066. /**
  71067. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71068. */
  71069. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71070. /**
  71071. * Post-process used to merge the volumetric light effect and the real scene color
  71072. */
  71073. volumetricLightMergePostProces: Nullable<PostProcess>;
  71074. /**
  71075. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71076. */
  71077. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71078. /**
  71079. * Base post-process used to calculate the average luminance of the final image for HDR
  71080. */
  71081. luminancePostProcess: Nullable<PostProcess>;
  71082. /**
  71083. * Post-processes used to create down sample post-processes in order to get
  71084. * the average luminance of the final image for HDR
  71085. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71086. */
  71087. luminanceDownSamplePostProcesses: PostProcess[];
  71088. /**
  71089. * Post-process used to create a HDR effect (light adaptation)
  71090. */
  71091. hdrPostProcess: Nullable<PostProcess>;
  71092. /**
  71093. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71094. */
  71095. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71096. /**
  71097. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71098. */
  71099. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71100. /**
  71101. * Post-process used to merge the final HDR post-process and the real scene color
  71102. */
  71103. hdrFinalPostProcess: Nullable<PostProcess>;
  71104. /**
  71105. * Post-process used to create a lens flare effect
  71106. */
  71107. lensFlarePostProcess: Nullable<PostProcess>;
  71108. /**
  71109. * Post-process that merges the result of the lens flare post-process and the real scene color
  71110. */
  71111. lensFlareComposePostProcess: Nullable<PostProcess>;
  71112. /**
  71113. * Post-process used to create a motion blur effect
  71114. */
  71115. motionBlurPostProcess: Nullable<PostProcess>;
  71116. /**
  71117. * Post-process used to create a depth of field effect
  71118. */
  71119. depthOfFieldPostProcess: Nullable<PostProcess>;
  71120. /**
  71121. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71122. */
  71123. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71124. /**
  71125. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71126. */
  71127. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71128. /**
  71129. * Represents the brightness threshold in order to configure the illuminated surfaces
  71130. */
  71131. brightThreshold: number;
  71132. /**
  71133. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71134. */
  71135. blurWidth: number;
  71136. /**
  71137. * Sets if the blur for highlighted surfaces must be only horizontal
  71138. */
  71139. horizontalBlur: boolean;
  71140. /**
  71141. * Gets the overall exposure used by the pipeline
  71142. */
  71143. get exposure(): number;
  71144. /**
  71145. * Sets the overall exposure used by the pipeline
  71146. */
  71147. set exposure(value: number);
  71148. /**
  71149. * Texture used typically to simulate "dirty" on camera lens
  71150. */
  71151. lensTexture: Nullable<Texture>;
  71152. /**
  71153. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71154. */
  71155. volumetricLightCoefficient: number;
  71156. /**
  71157. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71158. */
  71159. volumetricLightPower: number;
  71160. /**
  71161. * Used the set the blur intensity to smooth the volumetric lights
  71162. */
  71163. volumetricLightBlurScale: number;
  71164. /**
  71165. * Light (spot or directional) used to generate the volumetric lights rays
  71166. * The source light must have a shadow generate so the pipeline can get its
  71167. * depth map
  71168. */
  71169. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71170. /**
  71171. * For eye adaptation, represents the minimum luminance the eye can see
  71172. */
  71173. hdrMinimumLuminance: number;
  71174. /**
  71175. * For eye adaptation, represents the decrease luminance speed
  71176. */
  71177. hdrDecreaseRate: number;
  71178. /**
  71179. * For eye adaptation, represents the increase luminance speed
  71180. */
  71181. hdrIncreaseRate: number;
  71182. /**
  71183. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71184. */
  71185. get hdrAutoExposure(): boolean;
  71186. /**
  71187. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71188. */
  71189. set hdrAutoExposure(value: boolean);
  71190. /**
  71191. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71192. */
  71193. lensColorTexture: Nullable<Texture>;
  71194. /**
  71195. * The overall strengh for the lens flare effect
  71196. */
  71197. lensFlareStrength: number;
  71198. /**
  71199. * Dispersion coefficient for lens flare ghosts
  71200. */
  71201. lensFlareGhostDispersal: number;
  71202. /**
  71203. * Main lens flare halo width
  71204. */
  71205. lensFlareHaloWidth: number;
  71206. /**
  71207. * Based on the lens distortion effect, defines how much the lens flare result
  71208. * is distorted
  71209. */
  71210. lensFlareDistortionStrength: number;
  71211. /**
  71212. * Configures the blur intensity used for for lens flare (halo)
  71213. */
  71214. lensFlareBlurWidth: number;
  71215. /**
  71216. * Lens star texture must be used to simulate rays on the flares and is available
  71217. * in the documentation
  71218. */
  71219. lensStarTexture: Nullable<Texture>;
  71220. /**
  71221. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71222. * flare effect by taking account of the dirt texture
  71223. */
  71224. lensFlareDirtTexture: Nullable<Texture>;
  71225. /**
  71226. * Represents the focal length for the depth of field effect
  71227. */
  71228. depthOfFieldDistance: number;
  71229. /**
  71230. * Represents the blur intensity for the blurred part of the depth of field effect
  71231. */
  71232. depthOfFieldBlurWidth: number;
  71233. /**
  71234. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71235. */
  71236. get motionStrength(): number;
  71237. /**
  71238. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71239. */
  71240. set motionStrength(strength: number);
  71241. /**
  71242. * Gets wether or not the motion blur post-process is object based or screen based.
  71243. */
  71244. get objectBasedMotionBlur(): boolean;
  71245. /**
  71246. * Sets wether or not the motion blur post-process should be object based or screen based
  71247. */
  71248. set objectBasedMotionBlur(value: boolean);
  71249. /**
  71250. * List of animations for the pipeline (IAnimatable implementation)
  71251. */
  71252. animations: Animation[];
  71253. /**
  71254. * Private members
  71255. */
  71256. private _scene;
  71257. private _currentDepthOfFieldSource;
  71258. private _basePostProcess;
  71259. private _fixedExposure;
  71260. private _currentExposure;
  71261. private _hdrAutoExposure;
  71262. private _hdrCurrentLuminance;
  71263. private _motionStrength;
  71264. private _isObjectBasedMotionBlur;
  71265. private _floatTextureType;
  71266. private _camerasToBeAttached;
  71267. private _ratio;
  71268. private _bloomEnabled;
  71269. private _depthOfFieldEnabled;
  71270. private _vlsEnabled;
  71271. private _lensFlareEnabled;
  71272. private _hdrEnabled;
  71273. private _motionBlurEnabled;
  71274. private _fxaaEnabled;
  71275. private _screenSpaceReflectionsEnabled;
  71276. private _motionBlurSamples;
  71277. private _volumetricLightStepsCount;
  71278. private _samples;
  71279. /**
  71280. * @ignore
  71281. * Specifies if the bloom pipeline is enabled
  71282. */
  71283. get BloomEnabled(): boolean;
  71284. set BloomEnabled(enabled: boolean);
  71285. /**
  71286. * @ignore
  71287. * Specifies if the depth of field pipeline is enabed
  71288. */
  71289. get DepthOfFieldEnabled(): boolean;
  71290. set DepthOfFieldEnabled(enabled: boolean);
  71291. /**
  71292. * @ignore
  71293. * Specifies if the lens flare pipeline is enabed
  71294. */
  71295. get LensFlareEnabled(): boolean;
  71296. set LensFlareEnabled(enabled: boolean);
  71297. /**
  71298. * @ignore
  71299. * Specifies if the HDR pipeline is enabled
  71300. */
  71301. get HDREnabled(): boolean;
  71302. set HDREnabled(enabled: boolean);
  71303. /**
  71304. * @ignore
  71305. * Specifies if the volumetric lights scattering effect is enabled
  71306. */
  71307. get VLSEnabled(): boolean;
  71308. set VLSEnabled(enabled: boolean);
  71309. /**
  71310. * @ignore
  71311. * Specifies if the motion blur effect is enabled
  71312. */
  71313. get MotionBlurEnabled(): boolean;
  71314. set MotionBlurEnabled(enabled: boolean);
  71315. /**
  71316. * Specifies if anti-aliasing is enabled
  71317. */
  71318. get fxaaEnabled(): boolean;
  71319. set fxaaEnabled(enabled: boolean);
  71320. /**
  71321. * Specifies if screen space reflections are enabled.
  71322. */
  71323. get screenSpaceReflectionsEnabled(): boolean;
  71324. set screenSpaceReflectionsEnabled(enabled: boolean);
  71325. /**
  71326. * Specifies the number of steps used to calculate the volumetric lights
  71327. * Typically in interval [50, 200]
  71328. */
  71329. get volumetricLightStepsCount(): number;
  71330. set volumetricLightStepsCount(count: number);
  71331. /**
  71332. * Specifies the number of samples used for the motion blur effect
  71333. * Typically in interval [16, 64]
  71334. */
  71335. get motionBlurSamples(): number;
  71336. set motionBlurSamples(samples: number);
  71337. /**
  71338. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71339. */
  71340. get samples(): number;
  71341. set samples(sampleCount: number);
  71342. /**
  71343. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71344. * @constructor
  71345. * @param name The rendering pipeline name
  71346. * @param scene The scene linked to this pipeline
  71347. * @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)
  71348. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71349. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71350. */
  71351. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71352. private _buildPipeline;
  71353. private _createDownSampleX4PostProcess;
  71354. private _createBrightPassPostProcess;
  71355. private _createBlurPostProcesses;
  71356. private _createTextureAdderPostProcess;
  71357. private _createVolumetricLightPostProcess;
  71358. private _createLuminancePostProcesses;
  71359. private _createHdrPostProcess;
  71360. private _createLensFlarePostProcess;
  71361. private _createDepthOfFieldPostProcess;
  71362. private _createMotionBlurPostProcess;
  71363. private _getDepthTexture;
  71364. private _disposePostProcesses;
  71365. /**
  71366. * Dispose of the pipeline and stop all post processes
  71367. */
  71368. dispose(): void;
  71369. /**
  71370. * Serialize the rendering pipeline (Used when exporting)
  71371. * @returns the serialized object
  71372. */
  71373. serialize(): any;
  71374. /**
  71375. * Parse the serialized pipeline
  71376. * @param source Source pipeline.
  71377. * @param scene The scene to load the pipeline to.
  71378. * @param rootUrl The URL of the serialized pipeline.
  71379. * @returns An instantiated pipeline from the serialized object.
  71380. */
  71381. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71382. /**
  71383. * Luminance steps
  71384. */
  71385. static LuminanceSteps: number;
  71386. }
  71387. }
  71388. declare module BABYLON {
  71389. /** @hidden */
  71390. export var stereoscopicInterlacePixelShader: {
  71391. name: string;
  71392. shader: string;
  71393. };
  71394. }
  71395. declare module BABYLON {
  71396. /**
  71397. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71398. */
  71399. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71400. private _stepSize;
  71401. private _passedProcess;
  71402. /**
  71403. * Gets a string identifying the name of the class
  71404. * @returns "StereoscopicInterlacePostProcessI" string
  71405. */
  71406. getClassName(): string;
  71407. /**
  71408. * Initializes a StereoscopicInterlacePostProcessI
  71409. * @param name The name of the effect.
  71410. * @param rigCameras The rig cameras to be appled to the post process
  71411. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71412. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71414. * @param engine The engine which the post process will be applied. (default: current engine)
  71415. * @param reusable If the post process can be reused on the same frame. (default: false)
  71416. */
  71417. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71418. }
  71419. /**
  71420. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71421. */
  71422. export class StereoscopicInterlacePostProcess extends PostProcess {
  71423. private _stepSize;
  71424. private _passedProcess;
  71425. /**
  71426. * Gets a string identifying the name of the class
  71427. * @returns "StereoscopicInterlacePostProcess" string
  71428. */
  71429. getClassName(): string;
  71430. /**
  71431. * Initializes a StereoscopicInterlacePostProcess
  71432. * @param name The name of the effect.
  71433. * @param rigCameras The rig cameras to be appled to the post process
  71434. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71436. * @param engine The engine which the post process will be applied. (default: current engine)
  71437. * @param reusable If the post process can be reused on the same frame. (default: false)
  71438. */
  71439. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71440. }
  71441. }
  71442. declare module BABYLON {
  71443. /** @hidden */
  71444. export var tonemapPixelShader: {
  71445. name: string;
  71446. shader: string;
  71447. };
  71448. }
  71449. declare module BABYLON {
  71450. /** Defines operator used for tonemapping */
  71451. export enum TonemappingOperator {
  71452. /** Hable */
  71453. Hable = 0,
  71454. /** Reinhard */
  71455. Reinhard = 1,
  71456. /** HejiDawson */
  71457. HejiDawson = 2,
  71458. /** Photographic */
  71459. Photographic = 3
  71460. }
  71461. /**
  71462. * Defines a post process to apply tone mapping
  71463. */
  71464. export class TonemapPostProcess extends PostProcess {
  71465. private _operator;
  71466. /** Defines the required exposure adjustement */
  71467. exposureAdjustment: number;
  71468. /**
  71469. * Gets a string identifying the name of the class
  71470. * @returns "TonemapPostProcess" string
  71471. */
  71472. getClassName(): string;
  71473. /**
  71474. * Creates a new TonemapPostProcess
  71475. * @param name defines the name of the postprocess
  71476. * @param _operator defines the operator to use
  71477. * @param exposureAdjustment defines the required exposure adjustement
  71478. * @param camera defines the camera to use (can be null)
  71479. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71480. * @param engine defines the hosting engine (can be ignore if camera is set)
  71481. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71482. */
  71483. constructor(name: string, _operator: TonemappingOperator,
  71484. /** Defines the required exposure adjustement */
  71485. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71486. }
  71487. }
  71488. declare module BABYLON {
  71489. /** @hidden */
  71490. export var volumetricLightScatteringPixelShader: {
  71491. name: string;
  71492. shader: string;
  71493. };
  71494. }
  71495. declare module BABYLON {
  71496. /** @hidden */
  71497. export var volumetricLightScatteringPassVertexShader: {
  71498. name: string;
  71499. shader: string;
  71500. };
  71501. }
  71502. declare module BABYLON {
  71503. /** @hidden */
  71504. export var volumetricLightScatteringPassPixelShader: {
  71505. name: string;
  71506. shader: string;
  71507. };
  71508. }
  71509. declare module BABYLON {
  71510. /**
  71511. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71512. */
  71513. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71514. private _volumetricLightScatteringPass;
  71515. private _volumetricLightScatteringRTT;
  71516. private _viewPort;
  71517. private _screenCoordinates;
  71518. private _cachedDefines;
  71519. /**
  71520. * If not undefined, the mesh position is computed from the attached node position
  71521. */
  71522. attachedNode: {
  71523. position: Vector3;
  71524. };
  71525. /**
  71526. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71527. */
  71528. customMeshPosition: Vector3;
  71529. /**
  71530. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71531. */
  71532. useCustomMeshPosition: boolean;
  71533. /**
  71534. * If the post-process should inverse the light scattering direction
  71535. */
  71536. invert: boolean;
  71537. /**
  71538. * The internal mesh used by the post-process
  71539. */
  71540. mesh: Mesh;
  71541. /**
  71542. * @hidden
  71543. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71544. */
  71545. get useDiffuseColor(): boolean;
  71546. set useDiffuseColor(useDiffuseColor: boolean);
  71547. /**
  71548. * Array containing the excluded meshes not rendered in the internal pass
  71549. */
  71550. excludedMeshes: AbstractMesh[];
  71551. /**
  71552. * Controls the overall intensity of the post-process
  71553. */
  71554. exposure: number;
  71555. /**
  71556. * Dissipates each sample's contribution in range [0, 1]
  71557. */
  71558. decay: number;
  71559. /**
  71560. * Controls the overall intensity of each sample
  71561. */
  71562. weight: number;
  71563. /**
  71564. * Controls the density of each sample
  71565. */
  71566. density: number;
  71567. /**
  71568. * @constructor
  71569. * @param name The post-process name
  71570. * @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)
  71571. * @param camera The camera that the post-process will be attached to
  71572. * @param mesh The mesh used to create the light scattering
  71573. * @param samples The post-process quality, default 100
  71574. * @param samplingModeThe post-process filtering mode
  71575. * @param engine The babylon engine
  71576. * @param reusable If the post-process is reusable
  71577. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71578. */
  71579. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71580. /**
  71581. * Returns the string "VolumetricLightScatteringPostProcess"
  71582. * @returns "VolumetricLightScatteringPostProcess"
  71583. */
  71584. getClassName(): string;
  71585. private _isReady;
  71586. /**
  71587. * Sets the new light position for light scattering effect
  71588. * @param position The new custom light position
  71589. */
  71590. setCustomMeshPosition(position: Vector3): void;
  71591. /**
  71592. * Returns the light position for light scattering effect
  71593. * @return Vector3 The custom light position
  71594. */
  71595. getCustomMeshPosition(): Vector3;
  71596. /**
  71597. * Disposes the internal assets and detaches the post-process from the camera
  71598. */
  71599. dispose(camera: Camera): void;
  71600. /**
  71601. * Returns the render target texture used by the post-process
  71602. * @return the render target texture used by the post-process
  71603. */
  71604. getPass(): RenderTargetTexture;
  71605. private _meshExcluded;
  71606. private _createPass;
  71607. private _updateMeshScreenCoordinates;
  71608. /**
  71609. * Creates a default mesh for the Volumeric Light Scattering post-process
  71610. * @param name The mesh name
  71611. * @param scene The scene where to create the mesh
  71612. * @return the default mesh
  71613. */
  71614. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71615. }
  71616. }
  71617. declare module BABYLON {
  71618. /** @hidden */
  71619. export var screenSpaceCurvaturePixelShader: {
  71620. name: string;
  71621. shader: string;
  71622. };
  71623. }
  71624. declare module BABYLON {
  71625. /**
  71626. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71627. */
  71628. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71629. /**
  71630. * Defines how much ridge the curvature effect displays.
  71631. */
  71632. ridge: number;
  71633. /**
  71634. * Defines how much valley the curvature effect displays.
  71635. */
  71636. valley: number;
  71637. private _geometryBufferRenderer;
  71638. /**
  71639. * Gets a string identifying the name of the class
  71640. * @returns "ScreenSpaceCurvaturePostProcess" string
  71641. */
  71642. getClassName(): string;
  71643. /**
  71644. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71645. * @param name The name of the effect.
  71646. * @param scene The scene containing the objects to blur according to their velocity.
  71647. * @param options The required width/height ratio to downsize to before computing the render pass.
  71648. * @param camera The camera to apply the render pass to.
  71649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71650. * @param engine The engine which the post process will be applied. (default: current engine)
  71651. * @param reusable If the post process can be reused on the same frame. (default: false)
  71652. * @param textureType Type of textures used when performing the post process. (default: 0)
  71653. * @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)
  71654. */
  71655. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71656. /**
  71657. * Support test.
  71658. */
  71659. static get IsSupported(): boolean;
  71660. /** @hidden */
  71661. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71662. }
  71663. }
  71664. declare module BABYLON {
  71665. interface Scene {
  71666. /** @hidden (Backing field) */
  71667. _boundingBoxRenderer: BoundingBoxRenderer;
  71668. /** @hidden (Backing field) */
  71669. _forceShowBoundingBoxes: boolean;
  71670. /**
  71671. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71672. */
  71673. forceShowBoundingBoxes: boolean;
  71674. /**
  71675. * Gets the bounding box renderer associated with the scene
  71676. * @returns a BoundingBoxRenderer
  71677. */
  71678. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71679. }
  71680. interface AbstractMesh {
  71681. /** @hidden (Backing field) */
  71682. _showBoundingBox: boolean;
  71683. /**
  71684. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71685. */
  71686. showBoundingBox: boolean;
  71687. }
  71688. /**
  71689. * Component responsible of rendering the bounding box of the meshes in a scene.
  71690. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71691. */
  71692. export class BoundingBoxRenderer implements ISceneComponent {
  71693. /**
  71694. * The component name helpfull to identify the component in the list of scene components.
  71695. */
  71696. readonly name: string;
  71697. /**
  71698. * The scene the component belongs to.
  71699. */
  71700. scene: Scene;
  71701. /**
  71702. * Color of the bounding box lines placed in front of an object
  71703. */
  71704. frontColor: Color3;
  71705. /**
  71706. * Color of the bounding box lines placed behind an object
  71707. */
  71708. backColor: Color3;
  71709. /**
  71710. * Defines if the renderer should show the back lines or not
  71711. */
  71712. showBackLines: boolean;
  71713. /**
  71714. * Observable raised before rendering a bounding box
  71715. */
  71716. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71717. /**
  71718. * Observable raised after rendering a bounding box
  71719. */
  71720. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71721. /**
  71722. * @hidden
  71723. */
  71724. renderList: SmartArray<BoundingBox>;
  71725. private _colorShader;
  71726. private _vertexBuffers;
  71727. private _indexBuffer;
  71728. private _fillIndexBuffer;
  71729. private _fillIndexData;
  71730. /**
  71731. * Instantiates a new bounding box renderer in a scene.
  71732. * @param scene the scene the renderer renders in
  71733. */
  71734. constructor(scene: Scene);
  71735. /**
  71736. * Registers the component in a given scene
  71737. */
  71738. register(): void;
  71739. private _evaluateSubMesh;
  71740. private _activeMesh;
  71741. private _prepareRessources;
  71742. private _createIndexBuffer;
  71743. /**
  71744. * Rebuilds the elements related to this component in case of
  71745. * context lost for instance.
  71746. */
  71747. rebuild(): void;
  71748. /**
  71749. * @hidden
  71750. */
  71751. reset(): void;
  71752. /**
  71753. * Render the bounding boxes of a specific rendering group
  71754. * @param renderingGroupId defines the rendering group to render
  71755. */
  71756. render(renderingGroupId: number): void;
  71757. /**
  71758. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71759. * @param mesh Define the mesh to render the occlusion bounding box for
  71760. */
  71761. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71762. /**
  71763. * Dispose and release the resources attached to this renderer.
  71764. */
  71765. dispose(): void;
  71766. }
  71767. }
  71768. declare module BABYLON {
  71769. interface Scene {
  71770. /** @hidden (Backing field) */
  71771. _depthRenderer: {
  71772. [id: string]: DepthRenderer;
  71773. };
  71774. /**
  71775. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71776. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71777. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71778. * @returns the created depth renderer
  71779. */
  71780. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71781. /**
  71782. * Disables a depth renderer for a given camera
  71783. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71784. */
  71785. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71786. }
  71787. /**
  71788. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71789. * in several rendering techniques.
  71790. */
  71791. export class DepthRendererSceneComponent implements ISceneComponent {
  71792. /**
  71793. * The component name helpfull to identify the component in the list of scene components.
  71794. */
  71795. readonly name: string;
  71796. /**
  71797. * The scene the component belongs to.
  71798. */
  71799. scene: Scene;
  71800. /**
  71801. * Creates a new instance of the component for the given scene
  71802. * @param scene Defines the scene to register the component in
  71803. */
  71804. constructor(scene: Scene);
  71805. /**
  71806. * Registers the component in a given scene
  71807. */
  71808. register(): void;
  71809. /**
  71810. * Rebuilds the elements related to this component in case of
  71811. * context lost for instance.
  71812. */
  71813. rebuild(): void;
  71814. /**
  71815. * Disposes the component and the associated ressources
  71816. */
  71817. dispose(): void;
  71818. private _gatherRenderTargets;
  71819. private _gatherActiveCameraRenderTargets;
  71820. }
  71821. }
  71822. declare module BABYLON {
  71823. interface AbstractScene {
  71824. /** @hidden (Backing field) */
  71825. _prePassRenderer: Nullable<PrePassRenderer>;
  71826. /**
  71827. * Gets or Sets the current prepass renderer associated to the scene.
  71828. */
  71829. prePassRenderer: Nullable<PrePassRenderer>;
  71830. /**
  71831. * Enables the prepass and associates it with the scene
  71832. * @returns the PrePassRenderer
  71833. */
  71834. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71835. /**
  71836. * Disables the prepass associated with the scene
  71837. */
  71838. disablePrePassRenderer(): void;
  71839. }
  71840. /**
  71841. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71842. * in several rendering techniques.
  71843. */
  71844. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71845. /**
  71846. * The component name helpful to identify the component in the list of scene components.
  71847. */
  71848. readonly name: string;
  71849. /**
  71850. * The scene the component belongs to.
  71851. */
  71852. scene: Scene;
  71853. /**
  71854. * Creates a new instance of the component for the given scene
  71855. * @param scene Defines the scene to register the component in
  71856. */
  71857. constructor(scene: Scene);
  71858. /**
  71859. * Registers the component in a given scene
  71860. */
  71861. register(): void;
  71862. private _beforeCameraDraw;
  71863. private _afterCameraDraw;
  71864. private _beforeClearStage;
  71865. /**
  71866. * Serializes the component data to the specified json object
  71867. * @param serializationObject The object to serialize to
  71868. */
  71869. serialize(serializationObject: any): void;
  71870. /**
  71871. * Adds all the elements from the container to the scene
  71872. * @param container the container holding the elements
  71873. */
  71874. addFromContainer(container: AbstractScene): void;
  71875. /**
  71876. * Removes all the elements in the container from the scene
  71877. * @param container contains the elements to remove
  71878. * @param dispose if the removed element should be disposed (default: false)
  71879. */
  71880. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71881. /**
  71882. * Rebuilds the elements related to this component in case of
  71883. * context lost for instance.
  71884. */
  71885. rebuild(): void;
  71886. /**
  71887. * Disposes the component and the associated ressources
  71888. */
  71889. dispose(): void;
  71890. }
  71891. }
  71892. declare module BABYLON {
  71893. /** @hidden */
  71894. export var outlinePixelShader: {
  71895. name: string;
  71896. shader: string;
  71897. };
  71898. }
  71899. declare module BABYLON {
  71900. /** @hidden */
  71901. export var outlineVertexShader: {
  71902. name: string;
  71903. shader: string;
  71904. };
  71905. }
  71906. declare module BABYLON {
  71907. interface Scene {
  71908. /** @hidden */
  71909. _outlineRenderer: OutlineRenderer;
  71910. /**
  71911. * Gets the outline renderer associated with the scene
  71912. * @returns a OutlineRenderer
  71913. */
  71914. getOutlineRenderer(): OutlineRenderer;
  71915. }
  71916. interface AbstractMesh {
  71917. /** @hidden (Backing field) */
  71918. _renderOutline: boolean;
  71919. /**
  71920. * Gets or sets a boolean indicating if the outline must be rendered as well
  71921. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71922. */
  71923. renderOutline: boolean;
  71924. /** @hidden (Backing field) */
  71925. _renderOverlay: boolean;
  71926. /**
  71927. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71928. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71929. */
  71930. renderOverlay: boolean;
  71931. }
  71932. /**
  71933. * This class is responsible to draw bothe outline/overlay of meshes.
  71934. * It should not be used directly but through the available method on mesh.
  71935. */
  71936. export class OutlineRenderer implements ISceneComponent {
  71937. /**
  71938. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71939. */
  71940. private static _StencilReference;
  71941. /**
  71942. * The name of the component. Each component must have a unique name.
  71943. */
  71944. name: string;
  71945. /**
  71946. * The scene the component belongs to.
  71947. */
  71948. scene: Scene;
  71949. /**
  71950. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71951. */
  71952. zOffset: number;
  71953. private _engine;
  71954. private _effect;
  71955. private _cachedDefines;
  71956. private _savedDepthWrite;
  71957. /**
  71958. * Instantiates a new outline renderer. (There could be only one per scene).
  71959. * @param scene Defines the scene it belongs to
  71960. */
  71961. constructor(scene: Scene);
  71962. /**
  71963. * Register the component to one instance of a scene.
  71964. */
  71965. register(): void;
  71966. /**
  71967. * Rebuilds the elements related to this component in case of
  71968. * context lost for instance.
  71969. */
  71970. rebuild(): void;
  71971. /**
  71972. * Disposes the component and the associated ressources.
  71973. */
  71974. dispose(): void;
  71975. /**
  71976. * Renders the outline in the canvas.
  71977. * @param subMesh Defines the sumesh to render
  71978. * @param batch Defines the batch of meshes in case of instances
  71979. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71980. */
  71981. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71982. /**
  71983. * Returns whether or not the outline renderer is ready for a given submesh.
  71984. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71985. * @param subMesh Defines the submesh to check readyness for
  71986. * @param useInstances Defines wheter wee are trying to render instances or not
  71987. * @returns true if ready otherwise false
  71988. */
  71989. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71990. private _beforeRenderingMesh;
  71991. private _afterRenderingMesh;
  71992. }
  71993. }
  71994. declare module BABYLON {
  71995. /**
  71996. * Defines the basic options interface of a Sprite Frame Source Size.
  71997. */
  71998. export interface ISpriteJSONSpriteSourceSize {
  71999. /**
  72000. * number of the original width of the Frame
  72001. */
  72002. w: number;
  72003. /**
  72004. * number of the original height of the Frame
  72005. */
  72006. h: number;
  72007. }
  72008. /**
  72009. * Defines the basic options interface of a Sprite Frame Data.
  72010. */
  72011. export interface ISpriteJSONSpriteFrameData {
  72012. /**
  72013. * number of the x offset of the Frame
  72014. */
  72015. x: number;
  72016. /**
  72017. * number of the y offset of the Frame
  72018. */
  72019. y: number;
  72020. /**
  72021. * number of the width of the Frame
  72022. */
  72023. w: number;
  72024. /**
  72025. * number of the height of the Frame
  72026. */
  72027. h: number;
  72028. }
  72029. /**
  72030. * Defines the basic options interface of a JSON Sprite.
  72031. */
  72032. export interface ISpriteJSONSprite {
  72033. /**
  72034. * string name of the Frame
  72035. */
  72036. filename: string;
  72037. /**
  72038. * ISpriteJSONSpriteFrame basic object of the frame data
  72039. */
  72040. frame: ISpriteJSONSpriteFrameData;
  72041. /**
  72042. * boolean to flag is the frame was rotated.
  72043. */
  72044. rotated: boolean;
  72045. /**
  72046. * boolean to flag is the frame was trimmed.
  72047. */
  72048. trimmed: boolean;
  72049. /**
  72050. * ISpriteJSONSpriteFrame basic object of the source data
  72051. */
  72052. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72053. /**
  72054. * ISpriteJSONSpriteFrame basic object of the source data
  72055. */
  72056. sourceSize: ISpriteJSONSpriteSourceSize;
  72057. }
  72058. /**
  72059. * Defines the basic options interface of a JSON atlas.
  72060. */
  72061. export interface ISpriteJSONAtlas {
  72062. /**
  72063. * Array of objects that contain the frame data.
  72064. */
  72065. frames: Array<ISpriteJSONSprite>;
  72066. /**
  72067. * object basic object containing the sprite meta data.
  72068. */
  72069. meta?: object;
  72070. }
  72071. }
  72072. declare module BABYLON {
  72073. /** @hidden */
  72074. export var spriteMapPixelShader: {
  72075. name: string;
  72076. shader: string;
  72077. };
  72078. }
  72079. declare module BABYLON {
  72080. /** @hidden */
  72081. export var spriteMapVertexShader: {
  72082. name: string;
  72083. shader: string;
  72084. };
  72085. }
  72086. declare module BABYLON {
  72087. /**
  72088. * Defines the basic options interface of a SpriteMap
  72089. */
  72090. export interface ISpriteMapOptions {
  72091. /**
  72092. * Vector2 of the number of cells in the grid.
  72093. */
  72094. stageSize?: Vector2;
  72095. /**
  72096. * Vector2 of the size of the output plane in World Units.
  72097. */
  72098. outputSize?: Vector2;
  72099. /**
  72100. * Vector3 of the position of the output plane in World Units.
  72101. */
  72102. outputPosition?: Vector3;
  72103. /**
  72104. * Vector3 of the rotation of the output plane.
  72105. */
  72106. outputRotation?: Vector3;
  72107. /**
  72108. * number of layers that the system will reserve in resources.
  72109. */
  72110. layerCount?: number;
  72111. /**
  72112. * number of max animation frames a single cell will reserve in resources.
  72113. */
  72114. maxAnimationFrames?: number;
  72115. /**
  72116. * number cell index of the base tile when the system compiles.
  72117. */
  72118. baseTile?: number;
  72119. /**
  72120. * boolean flip the sprite after its been repositioned by the framing data.
  72121. */
  72122. flipU?: boolean;
  72123. /**
  72124. * Vector3 scalar of the global RGB values of the SpriteMap.
  72125. */
  72126. colorMultiply?: Vector3;
  72127. }
  72128. /**
  72129. * Defines the IDisposable interface in order to be cleanable from resources.
  72130. */
  72131. export interface ISpriteMap extends IDisposable {
  72132. /**
  72133. * String name of the SpriteMap.
  72134. */
  72135. name: string;
  72136. /**
  72137. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72138. */
  72139. atlasJSON: ISpriteJSONAtlas;
  72140. /**
  72141. * Texture of the SpriteMap.
  72142. */
  72143. spriteSheet: Texture;
  72144. /**
  72145. * The parameters to initialize the SpriteMap with.
  72146. */
  72147. options: ISpriteMapOptions;
  72148. }
  72149. /**
  72150. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72151. */
  72152. export class SpriteMap implements ISpriteMap {
  72153. /** The Name of the spriteMap */
  72154. name: string;
  72155. /** The JSON file with the frame and meta data */
  72156. atlasJSON: ISpriteJSONAtlas;
  72157. /** The systems Sprite Sheet Texture */
  72158. spriteSheet: Texture;
  72159. /** Arguments passed with the Constructor */
  72160. options: ISpriteMapOptions;
  72161. /** Public Sprite Storage array, parsed from atlasJSON */
  72162. sprites: Array<ISpriteJSONSprite>;
  72163. /** Returns the Number of Sprites in the System */
  72164. get spriteCount(): number;
  72165. /** Returns the Position of Output Plane*/
  72166. get position(): Vector3;
  72167. /** Returns the Position of Output Plane*/
  72168. set position(v: Vector3);
  72169. /** Returns the Rotation of Output Plane*/
  72170. get rotation(): Vector3;
  72171. /** Returns the Rotation of Output Plane*/
  72172. set rotation(v: Vector3);
  72173. /** Sets the AnimationMap*/
  72174. get animationMap(): RawTexture;
  72175. /** Sets the AnimationMap*/
  72176. set animationMap(v: RawTexture);
  72177. /** Scene that the SpriteMap was created in */
  72178. private _scene;
  72179. /** Texture Buffer of Float32 that holds tile frame data*/
  72180. private _frameMap;
  72181. /** Texture Buffers of Float32 that holds tileMap data*/
  72182. private _tileMaps;
  72183. /** Texture Buffer of Float32 that holds Animation Data*/
  72184. private _animationMap;
  72185. /** Custom ShaderMaterial Central to the System*/
  72186. private _material;
  72187. /** Custom ShaderMaterial Central to the System*/
  72188. private _output;
  72189. /** Systems Time Ticker*/
  72190. private _time;
  72191. /**
  72192. * Creates a new SpriteMap
  72193. * @param name defines the SpriteMaps Name
  72194. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72195. * @param spriteSheet is the Texture that the Sprites are on.
  72196. * @param options a basic deployment configuration
  72197. * @param scene The Scene that the map is deployed on
  72198. */
  72199. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72200. /**
  72201. * Returns tileID location
  72202. * @returns Vector2 the cell position ID
  72203. */
  72204. getTileID(): Vector2;
  72205. /**
  72206. * Gets the UV location of the mouse over the SpriteMap.
  72207. * @returns Vector2 the UV position of the mouse interaction
  72208. */
  72209. getMousePosition(): Vector2;
  72210. /**
  72211. * Creates the "frame" texture Buffer
  72212. * -------------------------------------
  72213. * Structure of frames
  72214. * "filename": "Falling-Water-2.png",
  72215. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72216. * "rotated": true,
  72217. * "trimmed": true,
  72218. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72219. * "sourceSize": {"w":32,"h":32}
  72220. * @returns RawTexture of the frameMap
  72221. */
  72222. private _createFrameBuffer;
  72223. /**
  72224. * Creates the tileMap texture Buffer
  72225. * @param buffer normally and array of numbers, or a false to generate from scratch
  72226. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72227. * @returns RawTexture of the tileMap
  72228. */
  72229. private _createTileBuffer;
  72230. /**
  72231. * Modifies the data of the tileMaps
  72232. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72233. * @param pos is the iVector2 Coordinates of the Tile
  72234. * @param tile The SpriteIndex of the new Tile
  72235. */
  72236. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72237. /**
  72238. * Creates the animationMap texture Buffer
  72239. * @param buffer normally and array of numbers, or a false to generate from scratch
  72240. * @returns RawTexture of the animationMap
  72241. */
  72242. private _createTileAnimationBuffer;
  72243. /**
  72244. * Modifies the data of the animationMap
  72245. * @param cellID is the Index of the Sprite
  72246. * @param _frame is the target Animation frame
  72247. * @param toCell is the Target Index of the next frame of the animation
  72248. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72249. * @param speed is a global scalar of the time variable on the map.
  72250. */
  72251. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72252. /**
  72253. * Exports the .tilemaps file
  72254. */
  72255. saveTileMaps(): void;
  72256. /**
  72257. * Imports the .tilemaps file
  72258. * @param url of the .tilemaps file
  72259. */
  72260. loadTileMaps(url: string): void;
  72261. /**
  72262. * Release associated resources
  72263. */
  72264. dispose(): void;
  72265. }
  72266. }
  72267. declare module BABYLON {
  72268. /**
  72269. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72270. * @see https://doc.babylonjs.com/babylon101/sprites
  72271. */
  72272. export class SpritePackedManager extends SpriteManager {
  72273. /** defines the packed manager's name */
  72274. name: string;
  72275. /**
  72276. * Creates a new sprite manager from a packed sprite sheet
  72277. * @param name defines the manager's name
  72278. * @param imgUrl defines the sprite sheet url
  72279. * @param capacity defines the maximum allowed number of sprites
  72280. * @param scene defines the hosting scene
  72281. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72282. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72283. * @param samplingMode defines the smapling mode to use with spritesheet
  72284. * @param fromPacked set to true; do not alter
  72285. */
  72286. constructor(
  72287. /** defines the packed manager's name */
  72288. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72289. }
  72290. }
  72291. declare module BABYLON {
  72292. /**
  72293. * Defines the list of states available for a task inside a AssetsManager
  72294. */
  72295. export enum AssetTaskState {
  72296. /**
  72297. * Initialization
  72298. */
  72299. INIT = 0,
  72300. /**
  72301. * Running
  72302. */
  72303. RUNNING = 1,
  72304. /**
  72305. * Done
  72306. */
  72307. DONE = 2,
  72308. /**
  72309. * Error
  72310. */
  72311. ERROR = 3
  72312. }
  72313. /**
  72314. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72315. */
  72316. export abstract class AbstractAssetTask {
  72317. /**
  72318. * Task name
  72319. */ name: string;
  72320. /**
  72321. * Callback called when the task is successful
  72322. */
  72323. onSuccess: (task: any) => void;
  72324. /**
  72325. * Callback called when the task is not successful
  72326. */
  72327. onError: (task: any, message?: string, exception?: any) => void;
  72328. /**
  72329. * Creates a new AssetsManager
  72330. * @param name defines the name of the task
  72331. */
  72332. constructor(
  72333. /**
  72334. * Task name
  72335. */ name: string);
  72336. private _isCompleted;
  72337. private _taskState;
  72338. private _errorObject;
  72339. /**
  72340. * Get if the task is completed
  72341. */
  72342. get isCompleted(): boolean;
  72343. /**
  72344. * Gets the current state of the task
  72345. */
  72346. get taskState(): AssetTaskState;
  72347. /**
  72348. * Gets the current error object (if task is in error)
  72349. */
  72350. get errorObject(): {
  72351. message?: string;
  72352. exception?: any;
  72353. };
  72354. /**
  72355. * Internal only
  72356. * @hidden
  72357. */
  72358. _setErrorObject(message?: string, exception?: any): void;
  72359. /**
  72360. * Execute the current task
  72361. * @param scene defines the scene where you want your assets to be loaded
  72362. * @param onSuccess is a callback called when the task is successfully executed
  72363. * @param onError is a callback called if an error occurs
  72364. */
  72365. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72366. /**
  72367. * Execute the current task
  72368. * @param scene defines the scene where you want your assets to be loaded
  72369. * @param onSuccess is a callback called when the task is successfully executed
  72370. * @param onError is a callback called if an error occurs
  72371. */
  72372. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72373. /**
  72374. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72375. * This can be used with failed tasks that have the reason for failure fixed.
  72376. */
  72377. reset(): void;
  72378. private onErrorCallback;
  72379. private onDoneCallback;
  72380. }
  72381. /**
  72382. * Define the interface used by progress events raised during assets loading
  72383. */
  72384. export interface IAssetsProgressEvent {
  72385. /**
  72386. * Defines the number of remaining tasks to process
  72387. */
  72388. remainingCount: number;
  72389. /**
  72390. * Defines the total number of tasks
  72391. */
  72392. totalCount: number;
  72393. /**
  72394. * Defines the task that was just processed
  72395. */
  72396. task: AbstractAssetTask;
  72397. }
  72398. /**
  72399. * Class used to share progress information about assets loading
  72400. */
  72401. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72402. /**
  72403. * Defines the number of remaining tasks to process
  72404. */
  72405. remainingCount: number;
  72406. /**
  72407. * Defines the total number of tasks
  72408. */
  72409. totalCount: number;
  72410. /**
  72411. * Defines the task that was just processed
  72412. */
  72413. task: AbstractAssetTask;
  72414. /**
  72415. * Creates a AssetsProgressEvent
  72416. * @param remainingCount defines the number of remaining tasks to process
  72417. * @param totalCount defines the total number of tasks
  72418. * @param task defines the task that was just processed
  72419. */
  72420. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72421. }
  72422. /**
  72423. * Define a task used by AssetsManager to load assets into a container
  72424. */
  72425. export class ContainerAssetTask extends AbstractAssetTask {
  72426. /**
  72427. * Defines the name of the task
  72428. */
  72429. name: string;
  72430. /**
  72431. * Defines the list of mesh's names you want to load
  72432. */
  72433. meshesNames: any;
  72434. /**
  72435. * Defines the root url to use as a base to load your meshes and associated resources
  72436. */
  72437. rootUrl: string;
  72438. /**
  72439. * Defines the filename or File of the scene to load from
  72440. */
  72441. sceneFilename: string | File;
  72442. /**
  72443. * Get the loaded asset container
  72444. */
  72445. loadedContainer: AssetContainer;
  72446. /**
  72447. * Gets the list of loaded meshes
  72448. */
  72449. loadedMeshes: Array<AbstractMesh>;
  72450. /**
  72451. * Gets the list of loaded particle systems
  72452. */
  72453. loadedParticleSystems: Array<IParticleSystem>;
  72454. /**
  72455. * Gets the list of loaded skeletons
  72456. */
  72457. loadedSkeletons: Array<Skeleton>;
  72458. /**
  72459. * Gets the list of loaded animation groups
  72460. */
  72461. loadedAnimationGroups: Array<AnimationGroup>;
  72462. /**
  72463. * Callback called when the task is successful
  72464. */
  72465. onSuccess: (task: ContainerAssetTask) => void;
  72466. /**
  72467. * Callback called when the task is successful
  72468. */
  72469. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72470. /**
  72471. * Creates a new ContainerAssetTask
  72472. * @param name defines the name of the task
  72473. * @param meshesNames defines the list of mesh's names you want to load
  72474. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72475. * @param sceneFilename defines the filename or File of the scene to load from
  72476. */
  72477. constructor(
  72478. /**
  72479. * Defines the name of the task
  72480. */
  72481. name: string,
  72482. /**
  72483. * Defines the list of mesh's names you want to load
  72484. */
  72485. meshesNames: any,
  72486. /**
  72487. * Defines the root url to use as a base to load your meshes and associated resources
  72488. */
  72489. rootUrl: string,
  72490. /**
  72491. * Defines the filename or File of the scene to load from
  72492. */
  72493. sceneFilename: string | File);
  72494. /**
  72495. * Execute the current task
  72496. * @param scene defines the scene where you want your assets to be loaded
  72497. * @param onSuccess is a callback called when the task is successfully executed
  72498. * @param onError is a callback called if an error occurs
  72499. */
  72500. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72501. }
  72502. /**
  72503. * Define a task used by AssetsManager to load meshes
  72504. */
  72505. export class MeshAssetTask extends AbstractAssetTask {
  72506. /**
  72507. * Defines the name of the task
  72508. */
  72509. name: string;
  72510. /**
  72511. * Defines the list of mesh's names you want to load
  72512. */
  72513. meshesNames: any;
  72514. /**
  72515. * Defines the root url to use as a base to load your meshes and associated resources
  72516. */
  72517. rootUrl: string;
  72518. /**
  72519. * Defines the filename or File of the scene to load from
  72520. */
  72521. sceneFilename: string | File;
  72522. /**
  72523. * Gets the list of loaded meshes
  72524. */
  72525. loadedMeshes: Array<AbstractMesh>;
  72526. /**
  72527. * Gets the list of loaded particle systems
  72528. */
  72529. loadedParticleSystems: Array<IParticleSystem>;
  72530. /**
  72531. * Gets the list of loaded skeletons
  72532. */
  72533. loadedSkeletons: Array<Skeleton>;
  72534. /**
  72535. * Gets the list of loaded animation groups
  72536. */
  72537. loadedAnimationGroups: Array<AnimationGroup>;
  72538. /**
  72539. * Callback called when the task is successful
  72540. */
  72541. onSuccess: (task: MeshAssetTask) => void;
  72542. /**
  72543. * Callback called when the task is successful
  72544. */
  72545. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72546. /**
  72547. * Creates a new MeshAssetTask
  72548. * @param name defines the name of the task
  72549. * @param meshesNames defines the list of mesh's names you want to load
  72550. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72551. * @param sceneFilename defines the filename or File of the scene to load from
  72552. */
  72553. constructor(
  72554. /**
  72555. * Defines the name of the task
  72556. */
  72557. name: string,
  72558. /**
  72559. * Defines the list of mesh's names you want to load
  72560. */
  72561. meshesNames: any,
  72562. /**
  72563. * Defines the root url to use as a base to load your meshes and associated resources
  72564. */
  72565. rootUrl: string,
  72566. /**
  72567. * Defines the filename or File of the scene to load from
  72568. */
  72569. sceneFilename: string | File);
  72570. /**
  72571. * Execute the current task
  72572. * @param scene defines the scene where you want your assets to be loaded
  72573. * @param onSuccess is a callback called when the task is successfully executed
  72574. * @param onError is a callback called if an error occurs
  72575. */
  72576. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72577. }
  72578. /**
  72579. * Define a task used by AssetsManager to load text content
  72580. */
  72581. export class TextFileAssetTask extends AbstractAssetTask {
  72582. /**
  72583. * Defines the name of the task
  72584. */
  72585. name: string;
  72586. /**
  72587. * Defines the location of the file to load
  72588. */
  72589. url: string;
  72590. /**
  72591. * Gets the loaded text string
  72592. */
  72593. text: string;
  72594. /**
  72595. * Callback called when the task is successful
  72596. */
  72597. onSuccess: (task: TextFileAssetTask) => void;
  72598. /**
  72599. * Callback called when the task is successful
  72600. */
  72601. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72602. /**
  72603. * Creates a new TextFileAssetTask object
  72604. * @param name defines the name of the task
  72605. * @param url defines the location of the file to load
  72606. */
  72607. constructor(
  72608. /**
  72609. * Defines the name of the task
  72610. */
  72611. name: string,
  72612. /**
  72613. * Defines the location of the file to load
  72614. */
  72615. url: string);
  72616. /**
  72617. * Execute the current task
  72618. * @param scene defines the scene where you want your assets to be loaded
  72619. * @param onSuccess is a callback called when the task is successfully executed
  72620. * @param onError is a callback called if an error occurs
  72621. */
  72622. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72623. }
  72624. /**
  72625. * Define a task used by AssetsManager to load binary data
  72626. */
  72627. export class BinaryFileAssetTask extends AbstractAssetTask {
  72628. /**
  72629. * Defines the name of the task
  72630. */
  72631. name: string;
  72632. /**
  72633. * Defines the location of the file to load
  72634. */
  72635. url: string;
  72636. /**
  72637. * Gets the lodaded data (as an array buffer)
  72638. */
  72639. data: ArrayBuffer;
  72640. /**
  72641. * Callback called when the task is successful
  72642. */
  72643. onSuccess: (task: BinaryFileAssetTask) => void;
  72644. /**
  72645. * Callback called when the task is successful
  72646. */
  72647. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72648. /**
  72649. * Creates a new BinaryFileAssetTask object
  72650. * @param name defines the name of the new task
  72651. * @param url defines the location of the file to load
  72652. */
  72653. constructor(
  72654. /**
  72655. * Defines the name of the task
  72656. */
  72657. name: string,
  72658. /**
  72659. * Defines the location of the file to load
  72660. */
  72661. url: string);
  72662. /**
  72663. * Execute the current task
  72664. * @param scene defines the scene where you want your assets to be loaded
  72665. * @param onSuccess is a callback called when the task is successfully executed
  72666. * @param onError is a callback called if an error occurs
  72667. */
  72668. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72669. }
  72670. /**
  72671. * Define a task used by AssetsManager to load images
  72672. */
  72673. export class ImageAssetTask extends AbstractAssetTask {
  72674. /**
  72675. * Defines the name of the task
  72676. */
  72677. name: string;
  72678. /**
  72679. * Defines the location of the image to load
  72680. */
  72681. url: string;
  72682. /**
  72683. * Gets the loaded images
  72684. */
  72685. image: HTMLImageElement;
  72686. /**
  72687. * Callback called when the task is successful
  72688. */
  72689. onSuccess: (task: ImageAssetTask) => void;
  72690. /**
  72691. * Callback called when the task is successful
  72692. */
  72693. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72694. /**
  72695. * Creates a new ImageAssetTask
  72696. * @param name defines the name of the task
  72697. * @param url defines the location of the image to load
  72698. */
  72699. constructor(
  72700. /**
  72701. * Defines the name of the task
  72702. */
  72703. name: string,
  72704. /**
  72705. * Defines the location of the image to load
  72706. */
  72707. url: string);
  72708. /**
  72709. * Execute the current task
  72710. * @param scene defines the scene where you want your assets to be loaded
  72711. * @param onSuccess is a callback called when the task is successfully executed
  72712. * @param onError is a callback called if an error occurs
  72713. */
  72714. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72715. }
  72716. /**
  72717. * Defines the interface used by texture loading tasks
  72718. */
  72719. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72720. /**
  72721. * Gets the loaded texture
  72722. */
  72723. texture: TEX;
  72724. }
  72725. /**
  72726. * Define a task used by AssetsManager to load 2D textures
  72727. */
  72728. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72729. /**
  72730. * Defines the name of the task
  72731. */
  72732. name: string;
  72733. /**
  72734. * Defines the location of the file to load
  72735. */
  72736. url: string;
  72737. /**
  72738. * Defines if mipmap should not be generated (default is false)
  72739. */
  72740. noMipmap?: boolean | undefined;
  72741. /**
  72742. * Defines if texture must be inverted on Y axis (default is true)
  72743. */
  72744. invertY: boolean;
  72745. /**
  72746. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72747. */
  72748. samplingMode: number;
  72749. /**
  72750. * Gets the loaded texture
  72751. */
  72752. texture: Texture;
  72753. /**
  72754. * Callback called when the task is successful
  72755. */
  72756. onSuccess: (task: TextureAssetTask) => void;
  72757. /**
  72758. * Callback called when the task is successful
  72759. */
  72760. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72761. /**
  72762. * Creates a new TextureAssetTask object
  72763. * @param name defines the name of the task
  72764. * @param url defines the location of the file to load
  72765. * @param noMipmap defines if mipmap should not be generated (default is false)
  72766. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72767. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72768. */
  72769. constructor(
  72770. /**
  72771. * Defines the name of the task
  72772. */
  72773. name: string,
  72774. /**
  72775. * Defines the location of the file to load
  72776. */
  72777. url: string,
  72778. /**
  72779. * Defines if mipmap should not be generated (default is false)
  72780. */
  72781. noMipmap?: boolean | undefined,
  72782. /**
  72783. * Defines if texture must be inverted on Y axis (default is true)
  72784. */
  72785. invertY?: boolean,
  72786. /**
  72787. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72788. */
  72789. samplingMode?: number);
  72790. /**
  72791. * Execute the current task
  72792. * @param scene defines the scene where you want your assets to be loaded
  72793. * @param onSuccess is a callback called when the task is successfully executed
  72794. * @param onError is a callback called if an error occurs
  72795. */
  72796. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72797. }
  72798. /**
  72799. * Define a task used by AssetsManager to load cube textures
  72800. */
  72801. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72802. /**
  72803. * Defines the name of the task
  72804. */
  72805. name: string;
  72806. /**
  72807. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72808. */
  72809. url: string;
  72810. /**
  72811. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72812. */
  72813. extensions?: string[] | undefined;
  72814. /**
  72815. * Defines if mipmaps should not be generated (default is false)
  72816. */
  72817. noMipmap?: boolean | undefined;
  72818. /**
  72819. * Defines the explicit list of files (undefined by default)
  72820. */
  72821. files?: string[] | undefined;
  72822. /**
  72823. * Gets the loaded texture
  72824. */
  72825. texture: CubeTexture;
  72826. /**
  72827. * Callback called when the task is successful
  72828. */
  72829. onSuccess: (task: CubeTextureAssetTask) => void;
  72830. /**
  72831. * Callback called when the task is successful
  72832. */
  72833. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72834. /**
  72835. * Creates a new CubeTextureAssetTask
  72836. * @param name defines the name of the task
  72837. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72838. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72839. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72840. * @param files defines the explicit list of files (undefined by default)
  72841. */
  72842. constructor(
  72843. /**
  72844. * Defines the name of the task
  72845. */
  72846. name: string,
  72847. /**
  72848. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72849. */
  72850. url: string,
  72851. /**
  72852. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72853. */
  72854. extensions?: string[] | undefined,
  72855. /**
  72856. * Defines if mipmaps should not be generated (default is false)
  72857. */
  72858. noMipmap?: boolean | undefined,
  72859. /**
  72860. * Defines the explicit list of files (undefined by default)
  72861. */
  72862. files?: string[] | undefined);
  72863. /**
  72864. * Execute the current task
  72865. * @param scene defines the scene where you want your assets to be loaded
  72866. * @param onSuccess is a callback called when the task is successfully executed
  72867. * @param onError is a callback called if an error occurs
  72868. */
  72869. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72870. }
  72871. /**
  72872. * Define a task used by AssetsManager to load HDR cube textures
  72873. */
  72874. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72875. /**
  72876. * Defines the name of the task
  72877. */
  72878. name: string;
  72879. /**
  72880. * Defines the location of the file to load
  72881. */
  72882. url: string;
  72883. /**
  72884. * Defines the desired size (the more it increases the longer the generation will be)
  72885. */
  72886. size: number;
  72887. /**
  72888. * Defines if mipmaps should not be generated (default is false)
  72889. */
  72890. noMipmap: boolean;
  72891. /**
  72892. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72893. */
  72894. generateHarmonics: boolean;
  72895. /**
  72896. * 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)
  72897. */
  72898. gammaSpace: boolean;
  72899. /**
  72900. * Internal Use Only
  72901. */
  72902. reserved: boolean;
  72903. /**
  72904. * Gets the loaded texture
  72905. */
  72906. texture: HDRCubeTexture;
  72907. /**
  72908. * Callback called when the task is successful
  72909. */
  72910. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72911. /**
  72912. * Callback called when the task is successful
  72913. */
  72914. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72915. /**
  72916. * Creates a new HDRCubeTextureAssetTask object
  72917. * @param name defines the name of the task
  72918. * @param url defines the location of the file to load
  72919. * @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.
  72920. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72921. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72922. * @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)
  72923. * @param reserved Internal use only
  72924. */
  72925. constructor(
  72926. /**
  72927. * Defines the name of the task
  72928. */
  72929. name: string,
  72930. /**
  72931. * Defines the location of the file to load
  72932. */
  72933. url: string,
  72934. /**
  72935. * Defines the desired size (the more it increases the longer the generation will be)
  72936. */
  72937. size: number,
  72938. /**
  72939. * Defines if mipmaps should not be generated (default is false)
  72940. */
  72941. noMipmap?: boolean,
  72942. /**
  72943. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72944. */
  72945. generateHarmonics?: boolean,
  72946. /**
  72947. * 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)
  72948. */
  72949. gammaSpace?: boolean,
  72950. /**
  72951. * Internal Use Only
  72952. */
  72953. reserved?: boolean);
  72954. /**
  72955. * Execute the current task
  72956. * @param scene defines the scene where you want your assets to be loaded
  72957. * @param onSuccess is a callback called when the task is successfully executed
  72958. * @param onError is a callback called if an error occurs
  72959. */
  72960. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72961. }
  72962. /**
  72963. * Define a task used by AssetsManager to load Equirectangular cube textures
  72964. */
  72965. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72966. /**
  72967. * Defines the name of the task
  72968. */
  72969. name: string;
  72970. /**
  72971. * Defines the location of the file to load
  72972. */
  72973. url: string;
  72974. /**
  72975. * Defines the desired size (the more it increases the longer the generation will be)
  72976. */
  72977. size: number;
  72978. /**
  72979. * Defines if mipmaps should not be generated (default is false)
  72980. */
  72981. noMipmap: boolean;
  72982. /**
  72983. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72984. * but the standard material would require them in Gamma space) (default is true)
  72985. */
  72986. gammaSpace: boolean;
  72987. /**
  72988. * Gets the loaded texture
  72989. */
  72990. texture: EquiRectangularCubeTexture;
  72991. /**
  72992. * Callback called when the task is successful
  72993. */
  72994. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72995. /**
  72996. * Callback called when the task is successful
  72997. */
  72998. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72999. /**
  73000. * Creates a new EquiRectangularCubeTextureAssetTask object
  73001. * @param name defines the name of the task
  73002. * @param url defines the location of the file to load
  73003. * @param size defines the desired size (the more it increases the longer the generation will be)
  73004. * If the size is omitted this implies you are using a preprocessed cubemap.
  73005. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73006. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73007. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73008. * (default is true)
  73009. */
  73010. constructor(
  73011. /**
  73012. * Defines the name of the task
  73013. */
  73014. name: string,
  73015. /**
  73016. * Defines the location of the file to load
  73017. */
  73018. url: string,
  73019. /**
  73020. * Defines the desired size (the more it increases the longer the generation will be)
  73021. */
  73022. size: number,
  73023. /**
  73024. * Defines if mipmaps should not be generated (default is false)
  73025. */
  73026. noMipmap?: boolean,
  73027. /**
  73028. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73029. * but the standard material would require them in Gamma space) (default is true)
  73030. */
  73031. gammaSpace?: boolean);
  73032. /**
  73033. * Execute the current task
  73034. * @param scene defines the scene where you want your assets to be loaded
  73035. * @param onSuccess is a callback called when the task is successfully executed
  73036. * @param onError is a callback called if an error occurs
  73037. */
  73038. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73039. }
  73040. /**
  73041. * This class can be used to easily import assets into a scene
  73042. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73043. */
  73044. export class AssetsManager {
  73045. private _scene;
  73046. private _isLoading;
  73047. protected _tasks: AbstractAssetTask[];
  73048. protected _waitingTasksCount: number;
  73049. protected _totalTasksCount: number;
  73050. /**
  73051. * Callback called when all tasks are processed
  73052. */
  73053. onFinish: (tasks: AbstractAssetTask[]) => void;
  73054. /**
  73055. * Callback called when a task is successful
  73056. */
  73057. onTaskSuccess: (task: AbstractAssetTask) => void;
  73058. /**
  73059. * Callback called when a task had an error
  73060. */
  73061. onTaskError: (task: AbstractAssetTask) => void;
  73062. /**
  73063. * Callback called when a task is done (whatever the result is)
  73064. */
  73065. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73066. /**
  73067. * Observable called when all tasks are processed
  73068. */
  73069. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73070. /**
  73071. * Observable called when a task had an error
  73072. */
  73073. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73074. /**
  73075. * Observable called when all tasks were executed
  73076. */
  73077. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73078. /**
  73079. * Observable called when a task is done (whatever the result is)
  73080. */
  73081. onProgressObservable: Observable<IAssetsProgressEvent>;
  73082. /**
  73083. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73084. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73085. */
  73086. useDefaultLoadingScreen: boolean;
  73087. /**
  73088. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73089. * when all assets have been downloaded.
  73090. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73091. */
  73092. autoHideLoadingUI: boolean;
  73093. /**
  73094. * Creates a new AssetsManager
  73095. * @param scene defines the scene to work on
  73096. */
  73097. constructor(scene: Scene);
  73098. /**
  73099. * Add a ContainerAssetTask to the list of active tasks
  73100. * @param taskName defines the name of the new task
  73101. * @param meshesNames defines the name of meshes to load
  73102. * @param rootUrl defines the root url to use to locate files
  73103. * @param sceneFilename defines the filename of the scene file
  73104. * @returns a new ContainerAssetTask object
  73105. */
  73106. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73107. /**
  73108. * Add a MeshAssetTask to the list of active tasks
  73109. * @param taskName defines the name of the new task
  73110. * @param meshesNames defines the name of meshes to load
  73111. * @param rootUrl defines the root url to use to locate files
  73112. * @param sceneFilename defines the filename of the scene file
  73113. * @returns a new MeshAssetTask object
  73114. */
  73115. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73116. /**
  73117. * Add a TextFileAssetTask to the list of active tasks
  73118. * @param taskName defines the name of the new task
  73119. * @param url defines the url of the file to load
  73120. * @returns a new TextFileAssetTask object
  73121. */
  73122. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73123. /**
  73124. * Add a BinaryFileAssetTask to the list of active tasks
  73125. * @param taskName defines the name of the new task
  73126. * @param url defines the url of the file to load
  73127. * @returns a new BinaryFileAssetTask object
  73128. */
  73129. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73130. /**
  73131. * Add a ImageAssetTask to the list of active tasks
  73132. * @param taskName defines the name of the new task
  73133. * @param url defines the url of the file to load
  73134. * @returns a new ImageAssetTask object
  73135. */
  73136. addImageTask(taskName: string, url: string): ImageAssetTask;
  73137. /**
  73138. * Add a TextureAssetTask to the list of active tasks
  73139. * @param taskName defines the name of the new task
  73140. * @param url defines the url of the file to load
  73141. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73142. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73143. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73144. * @returns a new TextureAssetTask object
  73145. */
  73146. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73147. /**
  73148. * Add a CubeTextureAssetTask to the list of active tasks
  73149. * @param taskName defines the name of the new task
  73150. * @param url defines the url of the file to load
  73151. * @param extensions defines the extension to use to load the cube map (can be null)
  73152. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73153. * @param files defines the list of files to load (can be null)
  73154. * @returns a new CubeTextureAssetTask object
  73155. */
  73156. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73157. /**
  73158. *
  73159. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73160. * @param taskName defines the name of the new task
  73161. * @param url defines the url of the file to load
  73162. * @param size defines the size you want for the cubemap (can be null)
  73163. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73164. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73165. * @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)
  73166. * @param reserved Internal use only
  73167. * @returns a new HDRCubeTextureAssetTask object
  73168. */
  73169. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73170. /**
  73171. *
  73172. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73173. * @param taskName defines the name of the new task
  73174. * @param url defines the url of the file to load
  73175. * @param size defines the size you want for the cubemap (can be null)
  73176. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73177. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73178. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73179. * @returns a new EquiRectangularCubeTextureAssetTask object
  73180. */
  73181. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73182. /**
  73183. * Remove a task from the assets manager.
  73184. * @param task the task to remove
  73185. */
  73186. removeTask(task: AbstractAssetTask): void;
  73187. private _decreaseWaitingTasksCount;
  73188. private _runTask;
  73189. /**
  73190. * Reset the AssetsManager and remove all tasks
  73191. * @return the current instance of the AssetsManager
  73192. */
  73193. reset(): AssetsManager;
  73194. /**
  73195. * Start the loading process
  73196. * @return the current instance of the AssetsManager
  73197. */
  73198. load(): AssetsManager;
  73199. /**
  73200. * Start the loading process as an async operation
  73201. * @return a promise returning the list of failed tasks
  73202. */
  73203. loadAsync(): Promise<void>;
  73204. }
  73205. }
  73206. declare module BABYLON {
  73207. /**
  73208. * Wrapper class for promise with external resolve and reject.
  73209. */
  73210. export class Deferred<T> {
  73211. /**
  73212. * The promise associated with this deferred object.
  73213. */
  73214. readonly promise: Promise<T>;
  73215. private _resolve;
  73216. private _reject;
  73217. /**
  73218. * The resolve method of the promise associated with this deferred object.
  73219. */
  73220. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73221. /**
  73222. * The reject method of the promise associated with this deferred object.
  73223. */
  73224. get reject(): (reason?: any) => void;
  73225. /**
  73226. * Constructor for this deferred object.
  73227. */
  73228. constructor();
  73229. }
  73230. }
  73231. declare module BABYLON {
  73232. /**
  73233. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73234. */
  73235. export class MeshExploder {
  73236. private _centerMesh;
  73237. private _meshes;
  73238. private _meshesOrigins;
  73239. private _toCenterVectors;
  73240. private _scaledDirection;
  73241. private _newPosition;
  73242. private _centerPosition;
  73243. /**
  73244. * Explodes meshes from a center mesh.
  73245. * @param meshes The meshes to explode.
  73246. * @param centerMesh The mesh to be center of explosion.
  73247. */
  73248. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73249. private _setCenterMesh;
  73250. /**
  73251. * Get class name
  73252. * @returns "MeshExploder"
  73253. */
  73254. getClassName(): string;
  73255. /**
  73256. * "Exploded meshes"
  73257. * @returns Array of meshes with the centerMesh at index 0.
  73258. */
  73259. getMeshes(): Array<Mesh>;
  73260. /**
  73261. * Explodes meshes giving a specific direction
  73262. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73263. */
  73264. explode(direction?: number): void;
  73265. }
  73266. }
  73267. declare module BABYLON {
  73268. /**
  73269. * Class used to help managing file picking and drag'n'drop
  73270. */
  73271. export class FilesInput {
  73272. /**
  73273. * List of files ready to be loaded
  73274. */
  73275. static get FilesToLoad(): {
  73276. [key: string]: File;
  73277. };
  73278. /**
  73279. * Callback called when a file is processed
  73280. */
  73281. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73282. private _engine;
  73283. private _currentScene;
  73284. private _sceneLoadedCallback;
  73285. private _progressCallback;
  73286. private _additionalRenderLoopLogicCallback;
  73287. private _textureLoadingCallback;
  73288. private _startingProcessingFilesCallback;
  73289. private _onReloadCallback;
  73290. private _errorCallback;
  73291. private _elementToMonitor;
  73292. private _sceneFileToLoad;
  73293. private _filesToLoad;
  73294. /**
  73295. * Creates a new FilesInput
  73296. * @param engine defines the rendering engine
  73297. * @param scene defines the hosting scene
  73298. * @param sceneLoadedCallback callback called when scene is loaded
  73299. * @param progressCallback callback called to track progress
  73300. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73301. * @param textureLoadingCallback callback called when a texture is loading
  73302. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73303. * @param onReloadCallback callback called when a reload is requested
  73304. * @param errorCallback callback call if an error occurs
  73305. */
  73306. 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>);
  73307. private _dragEnterHandler;
  73308. private _dragOverHandler;
  73309. private _dropHandler;
  73310. /**
  73311. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73312. * @param elementToMonitor defines the DOM element to track
  73313. */
  73314. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73315. /** Gets the current list of files to load */
  73316. get filesToLoad(): File[];
  73317. /**
  73318. * Release all associated resources
  73319. */
  73320. dispose(): void;
  73321. private renderFunction;
  73322. private drag;
  73323. private drop;
  73324. private _traverseFolder;
  73325. private _processFiles;
  73326. /**
  73327. * Load files from a drop event
  73328. * @param event defines the drop event to use as source
  73329. */
  73330. loadFiles(event: any): void;
  73331. private _processReload;
  73332. /**
  73333. * Reload the current scene from the loaded files
  73334. */
  73335. reload(): void;
  73336. }
  73337. }
  73338. declare module BABYLON {
  73339. /**
  73340. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73341. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73342. */
  73343. export class SceneOptimization {
  73344. /**
  73345. * Defines the priority of this optimization (0 by default which means first in the list)
  73346. */
  73347. priority: number;
  73348. /**
  73349. * Gets a string describing the action executed by the current optimization
  73350. * @returns description string
  73351. */
  73352. getDescription(): string;
  73353. /**
  73354. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73355. * @param scene defines the current scene where to apply this optimization
  73356. * @param optimizer defines the current optimizer
  73357. * @returns true if everything that can be done was applied
  73358. */
  73359. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73360. /**
  73361. * Creates the SceneOptimization object
  73362. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73363. * @param desc defines the description associated with the optimization
  73364. */
  73365. constructor(
  73366. /**
  73367. * Defines the priority of this optimization (0 by default which means first in the list)
  73368. */
  73369. priority?: number);
  73370. }
  73371. /**
  73372. * Defines an optimization used to reduce the size of render target textures
  73373. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73374. */
  73375. export class TextureOptimization extends SceneOptimization {
  73376. /**
  73377. * Defines the priority of this optimization (0 by default which means first in the list)
  73378. */
  73379. priority: number;
  73380. /**
  73381. * 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
  73382. */
  73383. maximumSize: number;
  73384. /**
  73385. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73386. */
  73387. step: number;
  73388. /**
  73389. * Gets a string describing the action executed by the current optimization
  73390. * @returns description string
  73391. */
  73392. getDescription(): string;
  73393. /**
  73394. * Creates the TextureOptimization object
  73395. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73396. * @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
  73397. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73398. */
  73399. constructor(
  73400. /**
  73401. * Defines the priority of this optimization (0 by default which means first in the list)
  73402. */
  73403. priority?: number,
  73404. /**
  73405. * 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
  73406. */
  73407. maximumSize?: number,
  73408. /**
  73409. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73410. */
  73411. step?: number);
  73412. /**
  73413. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73414. * @param scene defines the current scene where to apply this optimization
  73415. * @param optimizer defines the current optimizer
  73416. * @returns true if everything that can be done was applied
  73417. */
  73418. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73419. }
  73420. /**
  73421. * Defines an optimization used to increase or decrease the rendering resolution
  73422. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73423. */
  73424. export class HardwareScalingOptimization extends SceneOptimization {
  73425. /**
  73426. * Defines the priority of this optimization (0 by default which means first in the list)
  73427. */
  73428. priority: number;
  73429. /**
  73430. * Defines the maximum scale to use (2 by default)
  73431. */
  73432. maximumScale: number;
  73433. /**
  73434. * Defines the step to use between two passes (0.5 by default)
  73435. */
  73436. step: number;
  73437. private _currentScale;
  73438. private _directionOffset;
  73439. /**
  73440. * Gets a string describing the action executed by the current optimization
  73441. * @return description string
  73442. */
  73443. getDescription(): string;
  73444. /**
  73445. * Creates the HardwareScalingOptimization object
  73446. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73447. * @param maximumScale defines the maximum scale to use (2 by default)
  73448. * @param step defines the step to use between two passes (0.5 by default)
  73449. */
  73450. constructor(
  73451. /**
  73452. * Defines the priority of this optimization (0 by default which means first in the list)
  73453. */
  73454. priority?: number,
  73455. /**
  73456. * Defines the maximum scale to use (2 by default)
  73457. */
  73458. maximumScale?: number,
  73459. /**
  73460. * Defines the step to use between two passes (0.5 by default)
  73461. */
  73462. step?: number);
  73463. /**
  73464. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73465. * @param scene defines the current scene where to apply this optimization
  73466. * @param optimizer defines the current optimizer
  73467. * @returns true if everything that can be done was applied
  73468. */
  73469. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73470. }
  73471. /**
  73472. * Defines an optimization used to remove shadows
  73473. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73474. */
  73475. export class ShadowsOptimization extends SceneOptimization {
  73476. /**
  73477. * Gets a string describing the action executed by the current optimization
  73478. * @return description string
  73479. */
  73480. getDescription(): string;
  73481. /**
  73482. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73483. * @param scene defines the current scene where to apply this optimization
  73484. * @param optimizer defines the current optimizer
  73485. * @returns true if everything that can be done was applied
  73486. */
  73487. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73488. }
  73489. /**
  73490. * Defines an optimization used to turn post-processes off
  73491. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73492. */
  73493. export class PostProcessesOptimization extends SceneOptimization {
  73494. /**
  73495. * Gets a string describing the action executed by the current optimization
  73496. * @return description string
  73497. */
  73498. getDescription(): string;
  73499. /**
  73500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73501. * @param scene defines the current scene where to apply this optimization
  73502. * @param optimizer defines the current optimizer
  73503. * @returns true if everything that can be done was applied
  73504. */
  73505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73506. }
  73507. /**
  73508. * Defines an optimization used to turn lens flares off
  73509. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73510. */
  73511. export class LensFlaresOptimization extends SceneOptimization {
  73512. /**
  73513. * Gets a string describing the action executed by the current optimization
  73514. * @return description string
  73515. */
  73516. getDescription(): string;
  73517. /**
  73518. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73519. * @param scene defines the current scene where to apply this optimization
  73520. * @param optimizer defines the current optimizer
  73521. * @returns true if everything that can be done was applied
  73522. */
  73523. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73524. }
  73525. /**
  73526. * Defines an optimization based on user defined callback.
  73527. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73528. */
  73529. export class CustomOptimization extends SceneOptimization {
  73530. /**
  73531. * Callback called to apply the custom optimization.
  73532. */
  73533. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73534. /**
  73535. * Callback called to get custom description
  73536. */
  73537. onGetDescription: () => string;
  73538. /**
  73539. * Gets a string describing the action executed by the current optimization
  73540. * @returns description string
  73541. */
  73542. getDescription(): string;
  73543. /**
  73544. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73545. * @param scene defines the current scene where to apply this optimization
  73546. * @param optimizer defines the current optimizer
  73547. * @returns true if everything that can be done was applied
  73548. */
  73549. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73550. }
  73551. /**
  73552. * Defines an optimization used to turn particles off
  73553. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73554. */
  73555. export class ParticlesOptimization extends SceneOptimization {
  73556. /**
  73557. * Gets a string describing the action executed by the current optimization
  73558. * @return description string
  73559. */
  73560. getDescription(): string;
  73561. /**
  73562. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73563. * @param scene defines the current scene where to apply this optimization
  73564. * @param optimizer defines the current optimizer
  73565. * @returns true if everything that can be done was applied
  73566. */
  73567. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73568. }
  73569. /**
  73570. * Defines an optimization used to turn render targets off
  73571. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73572. */
  73573. export class RenderTargetsOptimization extends SceneOptimization {
  73574. /**
  73575. * Gets a string describing the action executed by the current optimization
  73576. * @return description string
  73577. */
  73578. getDescription(): string;
  73579. /**
  73580. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73581. * @param scene defines the current scene where to apply this optimization
  73582. * @param optimizer defines the current optimizer
  73583. * @returns true if everything that can be done was applied
  73584. */
  73585. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73586. }
  73587. /**
  73588. * Defines an optimization used to merge meshes with compatible materials
  73589. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73590. */
  73591. export class MergeMeshesOptimization extends SceneOptimization {
  73592. private static _UpdateSelectionTree;
  73593. /**
  73594. * Gets or sets a boolean which defines if optimization octree has to be updated
  73595. */
  73596. static get UpdateSelectionTree(): boolean;
  73597. /**
  73598. * Gets or sets a boolean which defines if optimization octree has to be updated
  73599. */
  73600. static set UpdateSelectionTree(value: boolean);
  73601. /**
  73602. * Gets a string describing the action executed by the current optimization
  73603. * @return description string
  73604. */
  73605. getDescription(): string;
  73606. private _canBeMerged;
  73607. /**
  73608. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73609. * @param scene defines the current scene where to apply this optimization
  73610. * @param optimizer defines the current optimizer
  73611. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73612. * @returns true if everything that can be done was applied
  73613. */
  73614. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73615. }
  73616. /**
  73617. * Defines a list of options used by SceneOptimizer
  73618. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73619. */
  73620. export class SceneOptimizerOptions {
  73621. /**
  73622. * Defines the target frame rate to reach (60 by default)
  73623. */
  73624. targetFrameRate: number;
  73625. /**
  73626. * Defines the interval between two checkes (2000ms by default)
  73627. */
  73628. trackerDuration: number;
  73629. /**
  73630. * Gets the list of optimizations to apply
  73631. */
  73632. optimizations: SceneOptimization[];
  73633. /**
  73634. * Creates a new list of options used by SceneOptimizer
  73635. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73636. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73637. */
  73638. constructor(
  73639. /**
  73640. * Defines the target frame rate to reach (60 by default)
  73641. */
  73642. targetFrameRate?: number,
  73643. /**
  73644. * Defines the interval between two checkes (2000ms by default)
  73645. */
  73646. trackerDuration?: number);
  73647. /**
  73648. * Add a new optimization
  73649. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73650. * @returns the current SceneOptimizerOptions
  73651. */
  73652. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73653. /**
  73654. * Add a new custom optimization
  73655. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73656. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73657. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73658. * @returns the current SceneOptimizerOptions
  73659. */
  73660. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73661. /**
  73662. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73663. * @param targetFrameRate defines the target frame rate (60 by default)
  73664. * @returns a SceneOptimizerOptions object
  73665. */
  73666. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73667. /**
  73668. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73669. * @param targetFrameRate defines the target frame rate (60 by default)
  73670. * @returns a SceneOptimizerOptions object
  73671. */
  73672. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73673. /**
  73674. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73675. * @param targetFrameRate defines the target frame rate (60 by default)
  73676. * @returns a SceneOptimizerOptions object
  73677. */
  73678. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73679. }
  73680. /**
  73681. * Class used to run optimizations in order to reach a target frame rate
  73682. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73683. */
  73684. export class SceneOptimizer implements IDisposable {
  73685. private _isRunning;
  73686. private _options;
  73687. private _scene;
  73688. private _currentPriorityLevel;
  73689. private _targetFrameRate;
  73690. private _trackerDuration;
  73691. private _currentFrameRate;
  73692. private _sceneDisposeObserver;
  73693. private _improvementMode;
  73694. /**
  73695. * Defines an observable called when the optimizer reaches the target frame rate
  73696. */
  73697. onSuccessObservable: Observable<SceneOptimizer>;
  73698. /**
  73699. * Defines an observable called when the optimizer enables an optimization
  73700. */
  73701. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73702. /**
  73703. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73704. */
  73705. onFailureObservable: Observable<SceneOptimizer>;
  73706. /**
  73707. * Gets a boolean indicating if the optimizer is in improvement mode
  73708. */
  73709. get isInImprovementMode(): boolean;
  73710. /**
  73711. * Gets the current priority level (0 at start)
  73712. */
  73713. get currentPriorityLevel(): number;
  73714. /**
  73715. * Gets the current frame rate checked by the SceneOptimizer
  73716. */
  73717. get currentFrameRate(): number;
  73718. /**
  73719. * Gets or sets the current target frame rate (60 by default)
  73720. */
  73721. get targetFrameRate(): number;
  73722. /**
  73723. * Gets or sets the current target frame rate (60 by default)
  73724. */
  73725. set targetFrameRate(value: number);
  73726. /**
  73727. * Gets or sets the current interval between two checks (every 2000ms by default)
  73728. */
  73729. get trackerDuration(): number;
  73730. /**
  73731. * Gets or sets the current interval between two checks (every 2000ms by default)
  73732. */
  73733. set trackerDuration(value: number);
  73734. /**
  73735. * Gets the list of active optimizations
  73736. */
  73737. get optimizations(): SceneOptimization[];
  73738. /**
  73739. * Creates a new SceneOptimizer
  73740. * @param scene defines the scene to work on
  73741. * @param options defines the options to use with the SceneOptimizer
  73742. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73743. * @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)
  73744. */
  73745. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73746. /**
  73747. * Stops the current optimizer
  73748. */
  73749. stop(): void;
  73750. /**
  73751. * Reset the optimizer to initial step (current priority level = 0)
  73752. */
  73753. reset(): void;
  73754. /**
  73755. * Start the optimizer. By default it will try to reach a specific framerate
  73756. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73757. */
  73758. start(): void;
  73759. private _checkCurrentState;
  73760. /**
  73761. * Release all resources
  73762. */
  73763. dispose(): void;
  73764. /**
  73765. * Helper function to create a SceneOptimizer with one single line of code
  73766. * @param scene defines the scene to work on
  73767. * @param options defines the options to use with the SceneOptimizer
  73768. * @param onSuccess defines a callback to call on success
  73769. * @param onFailure defines a callback to call on failure
  73770. * @returns the new SceneOptimizer object
  73771. */
  73772. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73773. }
  73774. }
  73775. declare module BABYLON {
  73776. /**
  73777. * Class used to serialize a scene into a string
  73778. */
  73779. export class SceneSerializer {
  73780. /**
  73781. * Clear cache used by a previous serialization
  73782. */
  73783. static ClearCache(): void;
  73784. /**
  73785. * Serialize a scene into a JSON compatible object
  73786. * @param scene defines the scene to serialize
  73787. * @returns a JSON compatible object
  73788. */
  73789. static Serialize(scene: Scene): any;
  73790. /**
  73791. * Serialize a mesh into a JSON compatible object
  73792. * @param toSerialize defines the mesh to serialize
  73793. * @param withParents defines if parents must be serialized as well
  73794. * @param withChildren defines if children must be serialized as well
  73795. * @returns a JSON compatible object
  73796. */
  73797. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73798. }
  73799. }
  73800. declare module BABYLON {
  73801. /**
  73802. * Class used to host texture specific utilities
  73803. */
  73804. export class TextureTools {
  73805. /**
  73806. * Uses the GPU to create a copy texture rescaled at a given size
  73807. * @param texture Texture to copy from
  73808. * @param width defines the desired width
  73809. * @param height defines the desired height
  73810. * @param useBilinearMode defines if bilinear mode has to be used
  73811. * @return the generated texture
  73812. */
  73813. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73814. }
  73815. }
  73816. declare module BABYLON {
  73817. /**
  73818. * This represents the different options available for the video capture.
  73819. */
  73820. export interface VideoRecorderOptions {
  73821. /** Defines the mime type of the video. */
  73822. mimeType: string;
  73823. /** Defines the FPS the video should be recorded at. */
  73824. fps: number;
  73825. /** Defines the chunk size for the recording data. */
  73826. recordChunckSize: number;
  73827. /** The audio tracks to attach to the recording. */
  73828. audioTracks?: MediaStreamTrack[];
  73829. }
  73830. /**
  73831. * This can help with recording videos from BabylonJS.
  73832. * This is based on the available WebRTC functionalities of the browser.
  73833. *
  73834. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73835. */
  73836. export class VideoRecorder {
  73837. private static readonly _defaultOptions;
  73838. /**
  73839. * Returns whether or not the VideoRecorder is available in your browser.
  73840. * @param engine Defines the Babylon Engine.
  73841. * @returns true if supported otherwise false.
  73842. */
  73843. static IsSupported(engine: Engine): boolean;
  73844. private readonly _options;
  73845. private _canvas;
  73846. private _mediaRecorder;
  73847. private _recordedChunks;
  73848. private _fileName;
  73849. private _resolve;
  73850. private _reject;
  73851. /**
  73852. * True when a recording is already in progress.
  73853. */
  73854. get isRecording(): boolean;
  73855. /**
  73856. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73857. * @param engine Defines the BabylonJS Engine you wish to record.
  73858. * @param options Defines options that can be used to customize the capture.
  73859. */
  73860. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73861. /**
  73862. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73863. */
  73864. stopRecording(): void;
  73865. /**
  73866. * Starts recording the canvas for a max duration specified in parameters.
  73867. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73868. * If null no automatic download will start and you can rely on the promise to get the data back.
  73869. * @param maxDuration Defines the maximum recording time in seconds.
  73870. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73871. * @return A promise callback at the end of the recording with the video data in Blob.
  73872. */
  73873. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73874. /**
  73875. * Releases internal resources used during the recording.
  73876. */
  73877. dispose(): void;
  73878. private _handleDataAvailable;
  73879. private _handleError;
  73880. private _handleStop;
  73881. }
  73882. }
  73883. declare module BABYLON {
  73884. /**
  73885. * Class containing a set of static utilities functions for screenshots
  73886. */
  73887. export class ScreenshotTools {
  73888. /**
  73889. * Captures a screenshot of the current rendering
  73890. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73891. * @param engine defines the rendering engine
  73892. * @param camera defines the source camera
  73893. * @param size This parameter can be set to a single number or to an object with the
  73894. * following (optional) properties: precision, width, height. If a single number is passed,
  73895. * it will be used for both width and height. If an object is passed, the screenshot size
  73896. * will be derived from the parameters. The precision property is a multiplier allowing
  73897. * rendering at a higher or lower resolution
  73898. * @param successCallback defines the callback receives a single parameter which contains the
  73899. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73900. * src parameter of an <img> to display it
  73901. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73902. * Check your browser for supported MIME types
  73903. */
  73904. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73905. /**
  73906. * Captures a screenshot of the current rendering
  73907. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73908. * @param engine defines the rendering engine
  73909. * @param camera defines the source camera
  73910. * @param size This parameter can be set to a single number or to an object with the
  73911. * following (optional) properties: precision, width, height. If a single number is passed,
  73912. * it will be used for both width and height. If an object is passed, the screenshot size
  73913. * will be derived from the parameters. The precision property is a multiplier allowing
  73914. * rendering at a higher or lower resolution
  73915. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73916. * Check your browser for supported MIME types
  73917. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73918. * to the src parameter of an <img> to display it
  73919. */
  73920. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73921. /**
  73922. * Generates an image screenshot from the specified camera.
  73923. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73924. * @param engine The engine to use for rendering
  73925. * @param camera The camera to use for rendering
  73926. * @param size This parameter can be set to a single number or to an object with the
  73927. * following (optional) properties: precision, width, height. If a single number is passed,
  73928. * it will be used for both width and height. If an object is passed, the screenshot size
  73929. * will be derived from the parameters. The precision property is a multiplier allowing
  73930. * rendering at a higher or lower resolution
  73931. * @param successCallback The callback receives a single parameter which contains the
  73932. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73933. * src parameter of an <img> to display it
  73934. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73935. * Check your browser for supported MIME types
  73936. * @param samples Texture samples (default: 1)
  73937. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73938. * @param fileName A name for for the downloaded file.
  73939. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73940. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  73941. */
  73942. 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;
  73943. /**
  73944. * Generates an image screenshot from the specified camera.
  73945. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73946. * @param engine The engine to use for rendering
  73947. * @param camera The camera to use for rendering
  73948. * @param size This parameter can be set to a single number or to an object with the
  73949. * following (optional) properties: precision, width, height. If a single number is passed,
  73950. * it will be used for both width and height. If an object is passed, the screenshot size
  73951. * will be derived from the parameters. The precision property is a multiplier allowing
  73952. * rendering at a higher or lower resolution
  73953. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73954. * Check your browser for supported MIME types
  73955. * @param samples Texture samples (default: 1)
  73956. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73957. * @param fileName A name for for the downloaded file.
  73958. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73959. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73960. * to the src parameter of an <img> to display it
  73961. */
  73962. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73963. /**
  73964. * Gets height and width for screenshot size
  73965. * @private
  73966. */
  73967. private static _getScreenshotSize;
  73968. }
  73969. }
  73970. declare module BABYLON {
  73971. /**
  73972. * Interface for a data buffer
  73973. */
  73974. export interface IDataBuffer {
  73975. /**
  73976. * Reads bytes from the data buffer.
  73977. * @param byteOffset The byte offset to read
  73978. * @param byteLength The byte length to read
  73979. * @returns A promise that resolves when the bytes are read
  73980. */
  73981. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73982. /**
  73983. * The byte length of the buffer.
  73984. */
  73985. readonly byteLength: number;
  73986. }
  73987. /**
  73988. * Utility class for reading from a data buffer
  73989. */
  73990. export class DataReader {
  73991. /**
  73992. * The data buffer associated with this data reader.
  73993. */
  73994. readonly buffer: IDataBuffer;
  73995. /**
  73996. * The current byte offset from the beginning of the data buffer.
  73997. */
  73998. byteOffset: number;
  73999. private _dataView;
  74000. private _dataByteOffset;
  74001. /**
  74002. * Constructor
  74003. * @param buffer The buffer to read
  74004. */
  74005. constructor(buffer: IDataBuffer);
  74006. /**
  74007. * Loads the given byte length.
  74008. * @param byteLength The byte length to load
  74009. * @returns A promise that resolves when the load is complete
  74010. */
  74011. loadAsync(byteLength: number): Promise<void>;
  74012. /**
  74013. * Read a unsigned 32-bit integer from the currently loaded data range.
  74014. * @returns The 32-bit integer read
  74015. */
  74016. readUint32(): number;
  74017. /**
  74018. * Read a byte array from the currently loaded data range.
  74019. * @param byteLength The byte length to read
  74020. * @returns The byte array read
  74021. */
  74022. readUint8Array(byteLength: number): Uint8Array;
  74023. /**
  74024. * Read a string from the currently loaded data range.
  74025. * @param byteLength The byte length to read
  74026. * @returns The string read
  74027. */
  74028. readString(byteLength: number): string;
  74029. /**
  74030. * Skips the given byte length the currently loaded data range.
  74031. * @param byteLength The byte length to skip
  74032. */
  74033. skipBytes(byteLength: number): void;
  74034. }
  74035. }
  74036. declare module BABYLON {
  74037. /**
  74038. * Class for storing data to local storage if available or in-memory storage otherwise
  74039. */
  74040. export class DataStorage {
  74041. private static _Storage;
  74042. private static _GetStorage;
  74043. /**
  74044. * Reads a string from the data storage
  74045. * @param key The key to read
  74046. * @param defaultValue The value if the key doesn't exist
  74047. * @returns The string value
  74048. */
  74049. static ReadString(key: string, defaultValue: string): string;
  74050. /**
  74051. * Writes a string to the data storage
  74052. * @param key The key to write
  74053. * @param value The value to write
  74054. */
  74055. static WriteString(key: string, value: string): void;
  74056. /**
  74057. * Reads a boolean from the data storage
  74058. * @param key The key to read
  74059. * @param defaultValue The value if the key doesn't exist
  74060. * @returns The boolean value
  74061. */
  74062. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74063. /**
  74064. * Writes a boolean to the data storage
  74065. * @param key The key to write
  74066. * @param value The value to write
  74067. */
  74068. static WriteBoolean(key: string, value: boolean): void;
  74069. /**
  74070. * Reads a number from the data storage
  74071. * @param key The key to read
  74072. * @param defaultValue The value if the key doesn't exist
  74073. * @returns The number value
  74074. */
  74075. static ReadNumber(key: string, defaultValue: number): number;
  74076. /**
  74077. * Writes a number to the data storage
  74078. * @param key The key to write
  74079. * @param value The value to write
  74080. */
  74081. static WriteNumber(key: string, value: number): void;
  74082. }
  74083. }
  74084. declare module BABYLON {
  74085. /**
  74086. * Class used to record delta files between 2 scene states
  74087. */
  74088. export class SceneRecorder {
  74089. private _trackedScene;
  74090. private _savedJSON;
  74091. /**
  74092. * Track a given scene. This means the current scene state will be considered the original state
  74093. * @param scene defines the scene to track
  74094. */
  74095. track(scene: Scene): void;
  74096. /**
  74097. * Get the delta between current state and original state
  74098. * @returns a string containing the delta
  74099. */
  74100. getDelta(): any;
  74101. private _compareArray;
  74102. private _compareObjects;
  74103. private _compareCollections;
  74104. private static GetShadowGeneratorById;
  74105. /**
  74106. * Apply a given delta to a given scene
  74107. * @param deltaJSON defines the JSON containing the delta
  74108. * @param scene defines the scene to apply the delta to
  74109. */
  74110. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74111. private static _ApplyPropertiesToEntity;
  74112. private static _ApplyDeltaForEntity;
  74113. }
  74114. }
  74115. declare module BABYLON {
  74116. /**
  74117. * An interface for all Hit test features
  74118. */
  74119. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74120. /**
  74121. * Triggered when new babylon (transformed) hit test results are available
  74122. */
  74123. onHitTestResultObservable: Observable<T[]>;
  74124. }
  74125. /**
  74126. * Options used for hit testing
  74127. */
  74128. export interface IWebXRLegacyHitTestOptions {
  74129. /**
  74130. * Only test when user interacted with the scene. Default - hit test every frame
  74131. */
  74132. testOnPointerDownOnly?: boolean;
  74133. /**
  74134. * The node to use to transform the local results to world coordinates
  74135. */
  74136. worldParentNode?: TransformNode;
  74137. }
  74138. /**
  74139. * Interface defining the babylon result of raycasting/hit-test
  74140. */
  74141. export interface IWebXRLegacyHitResult {
  74142. /**
  74143. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74144. */
  74145. transformationMatrix: Matrix;
  74146. /**
  74147. * The native hit test result
  74148. */
  74149. xrHitResult: XRHitResult | XRHitTestResult;
  74150. }
  74151. /**
  74152. * The currently-working hit-test module.
  74153. * Hit test (or Ray-casting) is used to interact with the real world.
  74154. * For further information read here - https://github.com/immersive-web/hit-test
  74155. */
  74156. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74157. /**
  74158. * options to use when constructing this feature
  74159. */
  74160. readonly options: IWebXRLegacyHitTestOptions;
  74161. private _direction;
  74162. private _mat;
  74163. private _onSelectEnabled;
  74164. private _origin;
  74165. /**
  74166. * The module's name
  74167. */
  74168. static readonly Name: string;
  74169. /**
  74170. * The (Babylon) version of this module.
  74171. * This is an integer representing the implementation version.
  74172. * This number does not correspond to the WebXR specs version
  74173. */
  74174. static readonly Version: number;
  74175. /**
  74176. * Populated with the last native XR Hit Results
  74177. */
  74178. lastNativeXRHitResults: XRHitResult[];
  74179. /**
  74180. * Triggered when new babylon (transformed) hit test results are available
  74181. */
  74182. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74183. /**
  74184. * Creates a new instance of the (legacy version) hit test feature
  74185. * @param _xrSessionManager an instance of WebXRSessionManager
  74186. * @param options options to use when constructing this feature
  74187. */
  74188. constructor(_xrSessionManager: WebXRSessionManager,
  74189. /**
  74190. * options to use when constructing this feature
  74191. */
  74192. options?: IWebXRLegacyHitTestOptions);
  74193. /**
  74194. * execute a hit test with an XR Ray
  74195. *
  74196. * @param xrSession a native xrSession that will execute this hit test
  74197. * @param xrRay the ray (position and direction) to use for ray-casting
  74198. * @param referenceSpace native XR reference space to use for the hit-test
  74199. * @param filter filter function that will filter the results
  74200. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74201. */
  74202. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74203. /**
  74204. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74205. * @param event the (select) event to use to select with
  74206. * @param referenceSpace the reference space to use for this hit test
  74207. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74208. */
  74209. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74210. /**
  74211. * attach this feature
  74212. * Will usually be called by the features manager
  74213. *
  74214. * @returns true if successful.
  74215. */
  74216. attach(): boolean;
  74217. /**
  74218. * detach this feature.
  74219. * Will usually be called by the features manager
  74220. *
  74221. * @returns true if successful.
  74222. */
  74223. detach(): boolean;
  74224. /**
  74225. * Dispose this feature and all of the resources attached
  74226. */
  74227. dispose(): void;
  74228. protected _onXRFrame(frame: XRFrame): void;
  74229. private _onHitTestResults;
  74230. private _onSelect;
  74231. }
  74232. }
  74233. declare module BABYLON {
  74234. /**
  74235. * Options used for hit testing (version 2)
  74236. */
  74237. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74238. /**
  74239. * Do not create a permanent hit test. Will usually be used when only
  74240. * transient inputs are needed.
  74241. */
  74242. disablePermanentHitTest?: boolean;
  74243. /**
  74244. * Enable transient (for example touch-based) hit test inspections
  74245. */
  74246. enableTransientHitTest?: boolean;
  74247. /**
  74248. * Offset ray for the permanent hit test
  74249. */
  74250. offsetRay?: Vector3;
  74251. /**
  74252. * Offset ray for the transient hit test
  74253. */
  74254. transientOffsetRay?: Vector3;
  74255. /**
  74256. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74257. */
  74258. useReferenceSpace?: boolean;
  74259. /**
  74260. * Override the default entity type(s) of the hit-test result
  74261. */
  74262. entityTypes?: XRHitTestTrackableType[];
  74263. }
  74264. /**
  74265. * Interface defining the babylon result of hit-test
  74266. */
  74267. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74268. /**
  74269. * The input source that generated this hit test (if transient)
  74270. */
  74271. inputSource?: XRInputSource;
  74272. /**
  74273. * Is this a transient hit test
  74274. */
  74275. isTransient?: boolean;
  74276. /**
  74277. * Position of the hit test result
  74278. */
  74279. position: Vector3;
  74280. /**
  74281. * Rotation of the hit test result
  74282. */
  74283. rotationQuaternion: Quaternion;
  74284. /**
  74285. * The native hit test result
  74286. */
  74287. xrHitResult: XRHitTestResult;
  74288. }
  74289. /**
  74290. * The currently-working hit-test module.
  74291. * Hit test (or Ray-casting) is used to interact with the real world.
  74292. * For further information read here - https://github.com/immersive-web/hit-test
  74293. *
  74294. * Tested on chrome (mobile) 80.
  74295. */
  74296. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74297. /**
  74298. * options to use when constructing this feature
  74299. */
  74300. readonly options: IWebXRHitTestOptions;
  74301. private _tmpMat;
  74302. private _tmpPos;
  74303. private _tmpQuat;
  74304. private _transientXrHitTestSource;
  74305. private _xrHitTestSource;
  74306. private initHitTestSource;
  74307. /**
  74308. * The module's name
  74309. */
  74310. static readonly Name: string;
  74311. /**
  74312. * The (Babylon) version of this module.
  74313. * This is an integer representing the implementation version.
  74314. * This number does not correspond to the WebXR specs version
  74315. */
  74316. static readonly Version: number;
  74317. /**
  74318. * When set to true, each hit test will have its own position/rotation objects
  74319. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74320. * the developers will clone them or copy them as they see fit.
  74321. */
  74322. autoCloneTransformation: boolean;
  74323. /**
  74324. * Triggered when new babylon (transformed) hit test results are available
  74325. */
  74326. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74327. /**
  74328. * Use this to temporarily pause hit test checks.
  74329. */
  74330. paused: boolean;
  74331. /**
  74332. * Creates a new instance of the hit test feature
  74333. * @param _xrSessionManager an instance of WebXRSessionManager
  74334. * @param options options to use when constructing this feature
  74335. */
  74336. constructor(_xrSessionManager: WebXRSessionManager,
  74337. /**
  74338. * options to use when constructing this feature
  74339. */
  74340. options?: IWebXRHitTestOptions);
  74341. /**
  74342. * attach this feature
  74343. * Will usually be called by the features manager
  74344. *
  74345. * @returns true if successful.
  74346. */
  74347. attach(): boolean;
  74348. /**
  74349. * detach this feature.
  74350. * Will usually be called by the features manager
  74351. *
  74352. * @returns true if successful.
  74353. */
  74354. detach(): boolean;
  74355. /**
  74356. * Dispose this feature and all of the resources attached
  74357. */
  74358. dispose(): void;
  74359. protected _onXRFrame(frame: XRFrame): void;
  74360. private _processWebXRHitTestResult;
  74361. }
  74362. }
  74363. declare module BABYLON {
  74364. /**
  74365. * Configuration options of the anchor system
  74366. */
  74367. export interface IWebXRAnchorSystemOptions {
  74368. /**
  74369. * a node that will be used to convert local to world coordinates
  74370. */
  74371. worldParentNode?: TransformNode;
  74372. /**
  74373. * If set to true a reference of the created anchors will be kept until the next session starts
  74374. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74375. */
  74376. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74377. }
  74378. /**
  74379. * A babylon container for an XR Anchor
  74380. */
  74381. export interface IWebXRAnchor {
  74382. /**
  74383. * A babylon-assigned ID for this anchor
  74384. */
  74385. id: number;
  74386. /**
  74387. * Transformation matrix to apply to an object attached to this anchor
  74388. */
  74389. transformationMatrix: Matrix;
  74390. /**
  74391. * The native anchor object
  74392. */
  74393. xrAnchor: XRAnchor;
  74394. /**
  74395. * if defined, this object will be constantly updated by the anchor's position and rotation
  74396. */
  74397. attachedNode?: TransformNode;
  74398. }
  74399. /**
  74400. * An implementation of the anchor system for WebXR.
  74401. * For further information see https://github.com/immersive-web/anchors/
  74402. */
  74403. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74404. private _options;
  74405. private _lastFrameDetected;
  74406. private _trackedAnchors;
  74407. private _referenceSpaceForFrameAnchors;
  74408. private _futureAnchors;
  74409. /**
  74410. * The module's name
  74411. */
  74412. static readonly Name: string;
  74413. /**
  74414. * The (Babylon) version of this module.
  74415. * This is an integer representing the implementation version.
  74416. * This number does not correspond to the WebXR specs version
  74417. */
  74418. static readonly Version: number;
  74419. /**
  74420. * Observers registered here will be executed when a new anchor was added to the session
  74421. */
  74422. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74423. /**
  74424. * Observers registered here will be executed when an anchor was removed from the session
  74425. */
  74426. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74427. /**
  74428. * Observers registered here will be executed when an existing anchor updates
  74429. * This can execute N times every frame
  74430. */
  74431. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74432. /**
  74433. * Set the reference space to use for anchor creation, when not using a hit test.
  74434. * Will default to the session's reference space if not defined
  74435. */
  74436. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74437. /**
  74438. * constructs a new anchor system
  74439. * @param _xrSessionManager an instance of WebXRSessionManager
  74440. * @param _options configuration object for this feature
  74441. */
  74442. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74443. private _tmpVector;
  74444. private _tmpQuaternion;
  74445. private _populateTmpTransformation;
  74446. /**
  74447. * Create a new anchor point using a hit test result at a specific point in the scene
  74448. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74449. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74450. *
  74451. * @param hitTestResult The hit test result to use for this anchor creation
  74452. * @param position an optional position offset for this anchor
  74453. * @param rotationQuaternion an optional rotation offset for this anchor
  74454. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74455. */
  74456. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74457. /**
  74458. * Add a new anchor at a specific position and rotation
  74459. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74460. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74461. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74462. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74463. *
  74464. * @param position the position in which to add an anchor
  74465. * @param rotationQuaternion an optional rotation for the anchor transformation
  74466. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74467. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74468. */
  74469. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74470. /**
  74471. * detach this feature.
  74472. * Will usually be called by the features manager
  74473. *
  74474. * @returns true if successful.
  74475. */
  74476. detach(): boolean;
  74477. /**
  74478. * Dispose this feature and all of the resources attached
  74479. */
  74480. dispose(): void;
  74481. protected _onXRFrame(frame: XRFrame): void;
  74482. /**
  74483. * avoiding using Array.find for global support.
  74484. * @param xrAnchor the plane to find in the array
  74485. */
  74486. private _findIndexInAnchorArray;
  74487. private _updateAnchorWithXRFrame;
  74488. private _createAnchorAtTransformation;
  74489. }
  74490. }
  74491. declare module BABYLON {
  74492. /**
  74493. * Options used in the plane detector module
  74494. */
  74495. export interface IWebXRPlaneDetectorOptions {
  74496. /**
  74497. * The node to use to transform the local results to world coordinates
  74498. */
  74499. worldParentNode?: TransformNode;
  74500. /**
  74501. * If set to true a reference of the created planes will be kept until the next session starts
  74502. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74503. */
  74504. doNotRemovePlanesOnSessionEnded?: boolean;
  74505. }
  74506. /**
  74507. * A babylon interface for a WebXR plane.
  74508. * A Plane is actually a polygon, built from N points in space
  74509. *
  74510. * Supported in chrome 79, not supported in canary 81 ATM
  74511. */
  74512. export interface IWebXRPlane {
  74513. /**
  74514. * a babylon-assigned ID for this polygon
  74515. */
  74516. id: number;
  74517. /**
  74518. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74519. */
  74520. polygonDefinition: Array<Vector3>;
  74521. /**
  74522. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74523. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74524. */
  74525. transformationMatrix: Matrix;
  74526. /**
  74527. * the native xr-plane object
  74528. */
  74529. xrPlane: XRPlane;
  74530. }
  74531. /**
  74532. * The plane detector is used to detect planes in the real world when in AR
  74533. * For more information see https://github.com/immersive-web/real-world-geometry/
  74534. */
  74535. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74536. private _options;
  74537. private _detectedPlanes;
  74538. private _enabled;
  74539. private _lastFrameDetected;
  74540. /**
  74541. * The module's name
  74542. */
  74543. static readonly Name: string;
  74544. /**
  74545. * The (Babylon) version of this module.
  74546. * This is an integer representing the implementation version.
  74547. * This number does not correspond to the WebXR specs version
  74548. */
  74549. static readonly Version: number;
  74550. /**
  74551. * Observers registered here will be executed when a new plane was added to the session
  74552. */
  74553. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74554. /**
  74555. * Observers registered here will be executed when a plane is no longer detected in the session
  74556. */
  74557. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74558. /**
  74559. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74560. * This can execute N times every frame
  74561. */
  74562. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74563. /**
  74564. * construct a new Plane Detector
  74565. * @param _xrSessionManager an instance of xr Session manager
  74566. * @param _options configuration to use when constructing this feature
  74567. */
  74568. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74569. /**
  74570. * detach this feature.
  74571. * Will usually be called by the features manager
  74572. *
  74573. * @returns true if successful.
  74574. */
  74575. detach(): boolean;
  74576. /**
  74577. * Dispose this feature and all of the resources attached
  74578. */
  74579. dispose(): void;
  74580. protected _onXRFrame(frame: XRFrame): void;
  74581. private _init;
  74582. private _updatePlaneWithXRPlane;
  74583. /**
  74584. * avoiding using Array.find for global support.
  74585. * @param xrPlane the plane to find in the array
  74586. */
  74587. private findIndexInPlaneArray;
  74588. }
  74589. }
  74590. declare module BABYLON {
  74591. /**
  74592. * Options interface for the background remover plugin
  74593. */
  74594. export interface IWebXRBackgroundRemoverOptions {
  74595. /**
  74596. * Further background meshes to disable when entering AR
  74597. */
  74598. backgroundMeshes?: AbstractMesh[];
  74599. /**
  74600. * flags to configure the removal of the environment helper.
  74601. * If not set, the entire background will be removed. If set, flags should be set as well.
  74602. */
  74603. environmentHelperRemovalFlags?: {
  74604. /**
  74605. * Should the skybox be removed (default false)
  74606. */
  74607. skyBox?: boolean;
  74608. /**
  74609. * Should the ground be removed (default false)
  74610. */
  74611. ground?: boolean;
  74612. };
  74613. /**
  74614. * don't disable the environment helper
  74615. */
  74616. ignoreEnvironmentHelper?: boolean;
  74617. }
  74618. /**
  74619. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74620. */
  74621. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74622. /**
  74623. * read-only options to be used in this module
  74624. */
  74625. readonly options: IWebXRBackgroundRemoverOptions;
  74626. /**
  74627. * The module's name
  74628. */
  74629. static readonly Name: string;
  74630. /**
  74631. * The (Babylon) version of this module.
  74632. * This is an integer representing the implementation version.
  74633. * This number does not correspond to the WebXR specs version
  74634. */
  74635. static readonly Version: number;
  74636. /**
  74637. * registered observers will be triggered when the background state changes
  74638. */
  74639. onBackgroundStateChangedObservable: Observable<boolean>;
  74640. /**
  74641. * constructs a new background remover module
  74642. * @param _xrSessionManager the session manager for this module
  74643. * @param options read-only options to be used in this module
  74644. */
  74645. constructor(_xrSessionManager: WebXRSessionManager,
  74646. /**
  74647. * read-only options to be used in this module
  74648. */
  74649. options?: IWebXRBackgroundRemoverOptions);
  74650. /**
  74651. * attach this feature
  74652. * Will usually be called by the features manager
  74653. *
  74654. * @returns true if successful.
  74655. */
  74656. attach(): boolean;
  74657. /**
  74658. * detach this feature.
  74659. * Will usually be called by the features manager
  74660. *
  74661. * @returns true if successful.
  74662. */
  74663. detach(): boolean;
  74664. /**
  74665. * Dispose this feature and all of the resources attached
  74666. */
  74667. dispose(): void;
  74668. protected _onXRFrame(_xrFrame: XRFrame): void;
  74669. private _setBackgroundState;
  74670. }
  74671. }
  74672. declare module BABYLON {
  74673. /**
  74674. * Options for the controller physics feature
  74675. */
  74676. export class IWebXRControllerPhysicsOptions {
  74677. /**
  74678. * Should the headset get its own impostor
  74679. */
  74680. enableHeadsetImpostor?: boolean;
  74681. /**
  74682. * Optional parameters for the headset impostor
  74683. */
  74684. headsetImpostorParams?: {
  74685. /**
  74686. * The type of impostor to create. Default is sphere
  74687. */
  74688. impostorType: number;
  74689. /**
  74690. * the size of the impostor. Defaults to 10cm
  74691. */
  74692. impostorSize?: number | {
  74693. width: number;
  74694. height: number;
  74695. depth: number;
  74696. };
  74697. /**
  74698. * Friction definitions
  74699. */
  74700. friction?: number;
  74701. /**
  74702. * Restitution
  74703. */
  74704. restitution?: number;
  74705. };
  74706. /**
  74707. * The physics properties of the future impostors
  74708. */
  74709. physicsProperties?: {
  74710. /**
  74711. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74712. * Note that this requires a physics engine that supports mesh impostors!
  74713. */
  74714. useControllerMesh?: boolean;
  74715. /**
  74716. * The type of impostor to create. Default is sphere
  74717. */
  74718. impostorType?: number;
  74719. /**
  74720. * the size of the impostor. Defaults to 10cm
  74721. */
  74722. impostorSize?: number | {
  74723. width: number;
  74724. height: number;
  74725. depth: number;
  74726. };
  74727. /**
  74728. * Friction definitions
  74729. */
  74730. friction?: number;
  74731. /**
  74732. * Restitution
  74733. */
  74734. restitution?: number;
  74735. };
  74736. /**
  74737. * the xr input to use with this pointer selection
  74738. */
  74739. xrInput: WebXRInput;
  74740. }
  74741. /**
  74742. * Add physics impostor to your webxr controllers,
  74743. * including naive calculation of their linear and angular velocity
  74744. */
  74745. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74746. private readonly _options;
  74747. private _attachController;
  74748. private _controllers;
  74749. private _debugMode;
  74750. private _delta;
  74751. private _headsetImpostor?;
  74752. private _headsetMesh?;
  74753. private _lastTimestamp;
  74754. private _tmpQuaternion;
  74755. private _tmpVector;
  74756. /**
  74757. * The module's name
  74758. */
  74759. static readonly Name: string;
  74760. /**
  74761. * The (Babylon) version of this module.
  74762. * This is an integer representing the implementation version.
  74763. * This number does not correspond to the webxr specs version
  74764. */
  74765. static readonly Version: number;
  74766. /**
  74767. * Construct a new Controller Physics Feature
  74768. * @param _xrSessionManager the corresponding xr session manager
  74769. * @param _options options to create this feature with
  74770. */
  74771. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74772. /**
  74773. * @hidden
  74774. * enable debugging - will show console outputs and the impostor mesh
  74775. */
  74776. _enablePhysicsDebug(): void;
  74777. /**
  74778. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74779. * @param xrController the controller to add
  74780. */
  74781. addController(xrController: WebXRInputSource): void;
  74782. /**
  74783. * attach this feature
  74784. * Will usually be called by the features manager
  74785. *
  74786. * @returns true if successful.
  74787. */
  74788. attach(): boolean;
  74789. /**
  74790. * detach this feature.
  74791. * Will usually be called by the features manager
  74792. *
  74793. * @returns true if successful.
  74794. */
  74795. detach(): boolean;
  74796. /**
  74797. * Get the headset impostor, if enabled
  74798. * @returns the impostor
  74799. */
  74800. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74801. /**
  74802. * Get the physics impostor of a specific controller.
  74803. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74804. * @param controller the controller or the controller id of which to get the impostor
  74805. * @returns the impostor or null
  74806. */
  74807. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74808. /**
  74809. * Update the physics properties provided in the constructor
  74810. * @param newProperties the new properties object
  74811. */
  74812. setPhysicsProperties(newProperties: {
  74813. impostorType?: number;
  74814. impostorSize?: number | {
  74815. width: number;
  74816. height: number;
  74817. depth: number;
  74818. };
  74819. friction?: number;
  74820. restitution?: number;
  74821. }): void;
  74822. protected _onXRFrame(_xrFrame: any): void;
  74823. private _detachController;
  74824. }
  74825. }
  74826. declare module BABYLON {
  74827. /**
  74828. * A babylon interface for a "WebXR" feature point.
  74829. * Represents the position and confidence value of a given feature point.
  74830. */
  74831. export interface IWebXRFeaturePoint {
  74832. /**
  74833. * Represents the position of the feature point in world space.
  74834. */
  74835. position: Vector3;
  74836. /**
  74837. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  74838. */
  74839. confidenceValue: number;
  74840. }
  74841. /**
  74842. * The feature point system is used to detect feature points from real world geometry.
  74843. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  74844. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  74845. */
  74846. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  74847. private _enabled;
  74848. private _featurePointCloud;
  74849. /**
  74850. * The module's name
  74851. */
  74852. static readonly Name: string;
  74853. /**
  74854. * The (Babylon) version of this module.
  74855. * This is an integer representing the implementation version.
  74856. * This number does not correspond to the WebXR specs version
  74857. */
  74858. static readonly Version: number;
  74859. /**
  74860. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  74861. * Will notify the observers about which feature points have been added.
  74862. */
  74863. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  74864. /**
  74865. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  74866. * Will notify the observers about which feature points have been updated.
  74867. */
  74868. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  74869. /**
  74870. * The current feature point cloud maintained across frames.
  74871. */
  74872. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  74873. /**
  74874. * construct the feature point system
  74875. * @param _xrSessionManager an instance of xr Session manager
  74876. */
  74877. constructor(_xrSessionManager: WebXRSessionManager);
  74878. /**
  74879. * Detach this feature.
  74880. * Will usually be called by the features manager
  74881. *
  74882. * @returns true if successful.
  74883. */
  74884. detach(): boolean;
  74885. /**
  74886. * Dispose this feature and all of the resources attached
  74887. */
  74888. dispose(): void;
  74889. /**
  74890. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  74891. */
  74892. protected _onXRFrame(frame: XRFrame): void;
  74893. /**
  74894. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  74895. */
  74896. private _init;
  74897. }
  74898. }
  74899. declare module BABYLON {
  74900. /**
  74901. * Configuration interface for the hand tracking feature
  74902. */
  74903. export interface IWebXRHandTrackingOptions {
  74904. /**
  74905. * The xrInput that will be used as source for new hands
  74906. */
  74907. xrInput: WebXRInput;
  74908. /**
  74909. * Configuration object for the joint meshes
  74910. */
  74911. jointMeshes?: {
  74912. /**
  74913. * Should the meshes created be invisible (defaults to false)
  74914. */
  74915. invisible?: boolean;
  74916. /**
  74917. * A source mesh to be used to create instances. Defaults to a sphere.
  74918. * This mesh will be the source for all other (25) meshes.
  74919. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  74920. */
  74921. sourceMesh?: Mesh;
  74922. /**
  74923. * Should the source mesh stay visible. Defaults to false
  74924. */
  74925. keepOriginalVisible?: boolean;
  74926. /**
  74927. * Scale factor for all instances (defaults to 2)
  74928. */
  74929. scaleFactor?: number;
  74930. /**
  74931. * Should each instance have its own physics impostor
  74932. */
  74933. enablePhysics?: boolean;
  74934. /**
  74935. * If enabled, override default physics properties
  74936. */
  74937. physicsProps?: {
  74938. friction?: number;
  74939. restitution?: number;
  74940. impostorType?: number;
  74941. };
  74942. /**
  74943. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  74944. */
  74945. handMesh?: AbstractMesh;
  74946. };
  74947. }
  74948. /**
  74949. * Parts of the hands divided to writs and finger names
  74950. */
  74951. export const enum HandPart {
  74952. /**
  74953. * HandPart - Wrist
  74954. */
  74955. WRIST = "wrist",
  74956. /**
  74957. * HandPart - The THumb
  74958. */
  74959. THUMB = "thumb",
  74960. /**
  74961. * HandPart - Index finger
  74962. */
  74963. INDEX = "index",
  74964. /**
  74965. * HandPart - Middle finger
  74966. */
  74967. MIDDLE = "middle",
  74968. /**
  74969. * HandPart - Ring finger
  74970. */
  74971. RING = "ring",
  74972. /**
  74973. * HandPart - Little finger
  74974. */
  74975. LITTLE = "little"
  74976. }
  74977. /**
  74978. * Representing a single hand (with its corresponding native XRHand object)
  74979. */
  74980. export class WebXRHand implements IDisposable {
  74981. /** the controller to which the hand correlates */
  74982. readonly xrController: WebXRInputSource;
  74983. /** the meshes to be used to track the hand joints */
  74984. readonly trackedMeshes: AbstractMesh[];
  74985. /**
  74986. * Hand-parts definition (key is HandPart)
  74987. */
  74988. static HandPartsDefinition: {
  74989. [key: string]: number[];
  74990. };
  74991. /**
  74992. * Populate the HandPartsDefinition object.
  74993. * This is called as a side effect since certain browsers don't have XRHand defined.
  74994. */
  74995. static _PopulateHandPartsDefinition(): void;
  74996. /**
  74997. * Construct a new hand object
  74998. * @param xrController the controller to which the hand correlates
  74999. * @param trackedMeshes the meshes to be used to track the hand joints
  75000. */
  75001. constructor(
  75002. /** the controller to which the hand correlates */
  75003. xrController: WebXRInputSource,
  75004. /** the meshes to be used to track the hand joints */
  75005. trackedMeshes: AbstractMesh[]);
  75006. /**
  75007. * Update this hand from the latest xr frame
  75008. * @param xrFrame xrFrame to update from
  75009. * @param referenceSpace The current viewer reference space
  75010. * @param scaleFactor optional scale factor for the meshes
  75011. */
  75012. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75013. /**
  75014. * Get meshes of part of the hand
  75015. * @param part the part of hand to get
  75016. * @returns An array of meshes that correlate to the hand part requested
  75017. */
  75018. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75019. /**
  75020. * Dispose this Hand object
  75021. */
  75022. dispose(): void;
  75023. }
  75024. /**
  75025. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75026. */
  75027. export class WebXRHandTracking extends WebXRAbstractFeature {
  75028. /**
  75029. * options to use when constructing this feature
  75030. */
  75031. readonly options: IWebXRHandTrackingOptions;
  75032. private static _idCounter;
  75033. /**
  75034. * The module's name
  75035. */
  75036. static readonly Name: string;
  75037. /**
  75038. * The (Babylon) version of this module.
  75039. * This is an integer representing the implementation version.
  75040. * This number does not correspond to the WebXR specs version
  75041. */
  75042. static readonly Version: number;
  75043. /**
  75044. * This observable will notify registered observers when a new hand object was added and initialized
  75045. */
  75046. onHandAddedObservable: Observable<WebXRHand>;
  75047. /**
  75048. * This observable will notify its observers right before the hand object is disposed
  75049. */
  75050. onHandRemovedObservable: Observable<WebXRHand>;
  75051. private _hands;
  75052. /**
  75053. * Creates a new instance of the hit test feature
  75054. * @param _xrSessionManager an instance of WebXRSessionManager
  75055. * @param options options to use when constructing this feature
  75056. */
  75057. constructor(_xrSessionManager: WebXRSessionManager,
  75058. /**
  75059. * options to use when constructing this feature
  75060. */
  75061. options: IWebXRHandTrackingOptions);
  75062. /**
  75063. * Check if the needed objects are defined.
  75064. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75065. */
  75066. isCompatible(): boolean;
  75067. /**
  75068. * attach this feature
  75069. * Will usually be called by the features manager
  75070. *
  75071. * @returns true if successful.
  75072. */
  75073. attach(): boolean;
  75074. /**
  75075. * detach this feature.
  75076. * Will usually be called by the features manager
  75077. *
  75078. * @returns true if successful.
  75079. */
  75080. detach(): boolean;
  75081. /**
  75082. * Dispose this feature and all of the resources attached
  75083. */
  75084. dispose(): void;
  75085. /**
  75086. * Get the hand object according to the controller id
  75087. * @param controllerId the controller id to which we want to get the hand
  75088. * @returns null if not found or the WebXRHand object if found
  75089. */
  75090. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75091. /**
  75092. * Get a hand object according to the requested handedness
  75093. * @param handedness the handedness to request
  75094. * @returns null if not found or the WebXRHand object if found
  75095. */
  75096. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75097. protected _onXRFrame(_xrFrame: XRFrame): void;
  75098. private _attachHand;
  75099. private _detachHand;
  75100. }
  75101. }
  75102. declare module BABYLON {
  75103. /**
  75104. * The motion controller class for all microsoft mixed reality controllers
  75105. */
  75106. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75107. protected readonly _mapping: {
  75108. defaultButton: {
  75109. valueNodeName: string;
  75110. unpressedNodeName: string;
  75111. pressedNodeName: string;
  75112. };
  75113. defaultAxis: {
  75114. valueNodeName: string;
  75115. minNodeName: string;
  75116. maxNodeName: string;
  75117. };
  75118. buttons: {
  75119. "xr-standard-trigger": {
  75120. rootNodeName: string;
  75121. componentProperty: string;
  75122. states: string[];
  75123. };
  75124. "xr-standard-squeeze": {
  75125. rootNodeName: string;
  75126. componentProperty: string;
  75127. states: string[];
  75128. };
  75129. "xr-standard-touchpad": {
  75130. rootNodeName: string;
  75131. labelAnchorNodeName: string;
  75132. touchPointNodeName: string;
  75133. };
  75134. "xr-standard-thumbstick": {
  75135. rootNodeName: string;
  75136. componentProperty: string;
  75137. states: string[];
  75138. };
  75139. };
  75140. axes: {
  75141. "xr-standard-touchpad": {
  75142. "x-axis": {
  75143. rootNodeName: string;
  75144. };
  75145. "y-axis": {
  75146. rootNodeName: string;
  75147. };
  75148. };
  75149. "xr-standard-thumbstick": {
  75150. "x-axis": {
  75151. rootNodeName: string;
  75152. };
  75153. "y-axis": {
  75154. rootNodeName: string;
  75155. };
  75156. };
  75157. };
  75158. };
  75159. /**
  75160. * The base url used to load the left and right controller models
  75161. */
  75162. static MODEL_BASE_URL: string;
  75163. /**
  75164. * The name of the left controller model file
  75165. */
  75166. static MODEL_LEFT_FILENAME: string;
  75167. /**
  75168. * The name of the right controller model file
  75169. */
  75170. static MODEL_RIGHT_FILENAME: string;
  75171. profileId: string;
  75172. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75173. protected _getFilenameAndPath(): {
  75174. filename: string;
  75175. path: string;
  75176. };
  75177. protected _getModelLoadingConstraints(): boolean;
  75178. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75179. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75180. protected _updateModel(): void;
  75181. }
  75182. }
  75183. declare module BABYLON {
  75184. /**
  75185. * The motion controller class for oculus touch (quest, rift).
  75186. * This class supports legacy mapping as well the standard xr mapping
  75187. */
  75188. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75189. private _forceLegacyControllers;
  75190. private _modelRootNode;
  75191. /**
  75192. * The base url used to load the left and right controller models
  75193. */
  75194. static MODEL_BASE_URL: string;
  75195. /**
  75196. * The name of the left controller model file
  75197. */
  75198. static MODEL_LEFT_FILENAME: string;
  75199. /**
  75200. * The name of the right controller model file
  75201. */
  75202. static MODEL_RIGHT_FILENAME: string;
  75203. /**
  75204. * Base Url for the Quest controller model.
  75205. */
  75206. static QUEST_MODEL_BASE_URL: string;
  75207. profileId: string;
  75208. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75209. protected _getFilenameAndPath(): {
  75210. filename: string;
  75211. path: string;
  75212. };
  75213. protected _getModelLoadingConstraints(): boolean;
  75214. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75215. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75216. protected _updateModel(): void;
  75217. /**
  75218. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75219. * between the touch and touch 2.
  75220. */
  75221. private _isQuest;
  75222. }
  75223. }
  75224. declare module BABYLON {
  75225. /**
  75226. * The motion controller class for the standard HTC-Vive controllers
  75227. */
  75228. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75229. private _modelRootNode;
  75230. /**
  75231. * The base url used to load the left and right controller models
  75232. */
  75233. static MODEL_BASE_URL: string;
  75234. /**
  75235. * File name for the controller model.
  75236. */
  75237. static MODEL_FILENAME: string;
  75238. profileId: string;
  75239. /**
  75240. * Create a new Vive motion controller object
  75241. * @param scene the scene to use to create this controller
  75242. * @param gamepadObject the corresponding gamepad object
  75243. * @param handedness the handedness of the controller
  75244. */
  75245. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75246. protected _getFilenameAndPath(): {
  75247. filename: string;
  75248. path: string;
  75249. };
  75250. protected _getModelLoadingConstraints(): boolean;
  75251. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75252. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75253. protected _updateModel(): void;
  75254. }
  75255. }
  75256. declare module BABYLON {
  75257. /**
  75258. * A cursor which tracks a point on a path
  75259. */
  75260. export class PathCursor {
  75261. private path;
  75262. /**
  75263. * Stores path cursor callbacks for when an onchange event is triggered
  75264. */
  75265. private _onchange;
  75266. /**
  75267. * The value of the path cursor
  75268. */
  75269. value: number;
  75270. /**
  75271. * The animation array of the path cursor
  75272. */
  75273. animations: Animation[];
  75274. /**
  75275. * Initializes the path cursor
  75276. * @param path The path to track
  75277. */
  75278. constructor(path: Path2);
  75279. /**
  75280. * Gets the cursor point on the path
  75281. * @returns A point on the path cursor at the cursor location
  75282. */
  75283. getPoint(): Vector3;
  75284. /**
  75285. * Moves the cursor ahead by the step amount
  75286. * @param step The amount to move the cursor forward
  75287. * @returns This path cursor
  75288. */
  75289. moveAhead(step?: number): PathCursor;
  75290. /**
  75291. * Moves the cursor behind by the step amount
  75292. * @param step The amount to move the cursor back
  75293. * @returns This path cursor
  75294. */
  75295. moveBack(step?: number): PathCursor;
  75296. /**
  75297. * Moves the cursor by the step amount
  75298. * If the step amount is greater than one, an exception is thrown
  75299. * @param step The amount to move the cursor
  75300. * @returns This path cursor
  75301. */
  75302. move(step: number): PathCursor;
  75303. /**
  75304. * Ensures that the value is limited between zero and one
  75305. * @returns This path cursor
  75306. */
  75307. private ensureLimits;
  75308. /**
  75309. * Runs onchange callbacks on change (used by the animation engine)
  75310. * @returns This path cursor
  75311. */
  75312. private raiseOnChange;
  75313. /**
  75314. * Executes a function on change
  75315. * @param f A path cursor onchange callback
  75316. * @returns This path cursor
  75317. */
  75318. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75319. }
  75320. }
  75321. declare module BABYLON {
  75322. /** @hidden */
  75323. export var blurPixelShader: {
  75324. name: string;
  75325. shader: string;
  75326. };
  75327. }
  75328. declare module BABYLON {
  75329. /** @hidden */
  75330. export var pointCloudVertexDeclaration: {
  75331. name: string;
  75332. shader: string;
  75333. };
  75334. }
  75335. // Mixins
  75336. interface Window {
  75337. mozIndexedDB: IDBFactory;
  75338. webkitIndexedDB: IDBFactory;
  75339. msIndexedDB: IDBFactory;
  75340. webkitURL: typeof URL;
  75341. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75342. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75343. WebGLRenderingContext: WebGLRenderingContext;
  75344. MSGesture: MSGesture;
  75345. CANNON: any;
  75346. AudioContext: AudioContext;
  75347. webkitAudioContext: AudioContext;
  75348. PointerEvent: any;
  75349. Math: Math;
  75350. Uint8Array: Uint8ArrayConstructor;
  75351. Float32Array: Float32ArrayConstructor;
  75352. mozURL: typeof URL;
  75353. msURL: typeof URL;
  75354. VRFrameData: any; // WebVR, from specs 1.1
  75355. DracoDecoderModule: any;
  75356. setImmediate(handler: (...args: any[]) => void): number;
  75357. }
  75358. interface HTMLCanvasElement {
  75359. requestPointerLock(): void;
  75360. msRequestPointerLock?(): void;
  75361. mozRequestPointerLock?(): void;
  75362. webkitRequestPointerLock?(): void;
  75363. /** Track wether a record is in progress */
  75364. isRecording: boolean;
  75365. /** Capture Stream method defined by some browsers */
  75366. captureStream(fps?: number): MediaStream;
  75367. }
  75368. interface CanvasRenderingContext2D {
  75369. msImageSmoothingEnabled: boolean;
  75370. }
  75371. interface MouseEvent {
  75372. mozMovementX: number;
  75373. mozMovementY: number;
  75374. webkitMovementX: number;
  75375. webkitMovementY: number;
  75376. msMovementX: number;
  75377. msMovementY: number;
  75378. }
  75379. interface Navigator {
  75380. mozGetVRDevices: (any: any) => any;
  75381. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75382. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75383. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75384. webkitGetGamepads(): Gamepad[];
  75385. msGetGamepads(): Gamepad[];
  75386. webkitGamepads(): Gamepad[];
  75387. }
  75388. interface HTMLVideoElement {
  75389. mozSrcObject: any;
  75390. }
  75391. interface Math {
  75392. fround(x: number): number;
  75393. imul(a: number, b: number): number;
  75394. }
  75395. interface WebGLRenderingContext {
  75396. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  75397. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  75398. vertexAttribDivisor(index: number, divisor: number): void;
  75399. createVertexArray(): any;
  75400. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  75401. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  75402. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  75403. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  75404. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  75405. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  75406. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  75407. // Queries
  75408. createQuery(): WebGLQuery;
  75409. deleteQuery(query: WebGLQuery): void;
  75410. beginQuery(target: number, query: WebGLQuery): void;
  75411. endQuery(target: number): void;
  75412. getQueryParameter(query: WebGLQuery, pname: number): any;
  75413. getQuery(target: number, pname: number): any;
  75414. MAX_SAMPLES: number;
  75415. RGBA8: number;
  75416. READ_FRAMEBUFFER: number;
  75417. DRAW_FRAMEBUFFER: number;
  75418. UNIFORM_BUFFER: number;
  75419. HALF_FLOAT_OES: number;
  75420. RGBA16F: number;
  75421. RGBA32F: number;
  75422. R32F: number;
  75423. RG32F: number;
  75424. RGB32F: number;
  75425. R16F: number;
  75426. RG16F: number;
  75427. RGB16F: number;
  75428. RED: number;
  75429. RG: number;
  75430. R8: number;
  75431. RG8: number;
  75432. UNSIGNED_INT_24_8: number;
  75433. DEPTH24_STENCIL8: number;
  75434. MIN: number;
  75435. MAX: number;
  75436. /* Multiple Render Targets */
  75437. drawBuffers(buffers: number[]): void;
  75438. readBuffer(src: number): void;
  75439. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  75440. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  75441. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  75442. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  75443. // Occlusion Query
  75444. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  75445. ANY_SAMPLES_PASSED: number;
  75446. QUERY_RESULT_AVAILABLE: number;
  75447. QUERY_RESULT: number;
  75448. }
  75449. interface WebGLProgram {
  75450. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  75451. }
  75452. interface EXT_disjoint_timer_query {
  75453. QUERY_COUNTER_BITS_EXT: number;
  75454. TIME_ELAPSED_EXT: number;
  75455. TIMESTAMP_EXT: number;
  75456. GPU_DISJOINT_EXT: number;
  75457. QUERY_RESULT_EXT: number;
  75458. QUERY_RESULT_AVAILABLE_EXT: number;
  75459. queryCounterEXT(query: WebGLQuery, target: number): void;
  75460. createQueryEXT(): WebGLQuery;
  75461. beginQueryEXT(target: number, query: WebGLQuery): void;
  75462. endQueryEXT(target: number): void;
  75463. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  75464. deleteQueryEXT(query: WebGLQuery): void;
  75465. }
  75466. interface WebGLUniformLocation {
  75467. _currentState: any;
  75468. }
  75469. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  75470. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  75471. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  75472. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75473. interface WebGLRenderingContext {
  75474. readonly RASTERIZER_DISCARD: number;
  75475. readonly DEPTH_COMPONENT24: number;
  75476. readonly TEXTURE_3D: number;
  75477. readonly TEXTURE_2D_ARRAY: number;
  75478. readonly TEXTURE_COMPARE_FUNC: number;
  75479. readonly TEXTURE_COMPARE_MODE: number;
  75480. readonly COMPARE_REF_TO_TEXTURE: number;
  75481. readonly TEXTURE_WRAP_R: number;
  75482. readonly HALF_FLOAT: number;
  75483. readonly RGB8: number;
  75484. readonly RED_INTEGER: number;
  75485. readonly RG_INTEGER: number;
  75486. readonly RGB_INTEGER: number;
  75487. readonly RGBA_INTEGER: number;
  75488. readonly R8_SNORM: number;
  75489. readonly RG8_SNORM: number;
  75490. readonly RGB8_SNORM: number;
  75491. readonly RGBA8_SNORM: number;
  75492. readonly R8I: number;
  75493. readonly RG8I: number;
  75494. readonly RGB8I: number;
  75495. readonly RGBA8I: number;
  75496. readonly R8UI: number;
  75497. readonly RG8UI: number;
  75498. readonly RGB8UI: number;
  75499. readonly RGBA8UI: number;
  75500. readonly R16I: number;
  75501. readonly RG16I: number;
  75502. readonly RGB16I: number;
  75503. readonly RGBA16I: number;
  75504. readonly R16UI: number;
  75505. readonly RG16UI: number;
  75506. readonly RGB16UI: number;
  75507. readonly RGBA16UI: number;
  75508. readonly R32I: number;
  75509. readonly RG32I: number;
  75510. readonly RGB32I: number;
  75511. readonly RGBA32I: number;
  75512. readonly R32UI: number;
  75513. readonly RG32UI: number;
  75514. readonly RGB32UI: number;
  75515. readonly RGBA32UI: number;
  75516. readonly RGB10_A2UI: number;
  75517. readonly R11F_G11F_B10F: number;
  75518. readonly RGB9_E5: number;
  75519. readonly RGB10_A2: number;
  75520. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  75521. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  75522. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  75523. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75524. readonly DEPTH_COMPONENT32F: number;
  75525. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  75526. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  75527. 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;
  75528. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  75529. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  75530. readonly TRANSFORM_FEEDBACK: number;
  75531. readonly INTERLEAVED_ATTRIBS: number;
  75532. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  75533. createTransformFeedback(): WebGLTransformFeedback;
  75534. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  75535. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  75536. beginTransformFeedback(primitiveMode: number): void;
  75537. endTransformFeedback(): void;
  75538. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  75539. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75540. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75541. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75542. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75543. }
  75544. interface ImageBitmap {
  75545. readonly width: number;
  75546. readonly height: number;
  75547. close(): void;
  75548. }
  75549. interface WebGLQuery extends WebGLObject {
  75550. }
  75551. declare var WebGLQuery: {
  75552. prototype: WebGLQuery;
  75553. new(): WebGLQuery;
  75554. };
  75555. interface WebGLSampler extends WebGLObject {
  75556. }
  75557. declare var WebGLSampler: {
  75558. prototype: WebGLSampler;
  75559. new(): WebGLSampler;
  75560. };
  75561. interface WebGLSync extends WebGLObject {
  75562. }
  75563. declare var WebGLSync: {
  75564. prototype: WebGLSync;
  75565. new(): WebGLSync;
  75566. };
  75567. interface WebGLTransformFeedback extends WebGLObject {
  75568. }
  75569. declare var WebGLTransformFeedback: {
  75570. prototype: WebGLTransformFeedback;
  75571. new(): WebGLTransformFeedback;
  75572. };
  75573. interface WebGLVertexArrayObject extends WebGLObject {
  75574. }
  75575. declare var WebGLVertexArrayObject: {
  75576. prototype: WebGLVertexArrayObject;
  75577. new(): WebGLVertexArrayObject;
  75578. };
  75579. // Type definitions for WebVR API
  75580. // Project: https://w3c.github.io/webvr/
  75581. // Definitions by: six a <https://github.com/lostfictions>
  75582. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75583. interface VRDisplay extends EventTarget {
  75584. /**
  75585. * Dictionary of capabilities describing the VRDisplay.
  75586. */
  75587. readonly capabilities: VRDisplayCapabilities;
  75588. /**
  75589. * z-depth defining the far plane of the eye view frustum
  75590. * enables mapping of values in the render target depth
  75591. * attachment to scene coordinates. Initially set to 10000.0.
  75592. */
  75593. depthFar: number;
  75594. /**
  75595. * z-depth defining the near plane of the eye view frustum
  75596. * enables mapping of values in the render target depth
  75597. * attachment to scene coordinates. Initially set to 0.01.
  75598. */
  75599. depthNear: number;
  75600. /**
  75601. * An identifier for this distinct VRDisplay. Used as an
  75602. * association point in the Gamepad API.
  75603. */
  75604. readonly displayId: number;
  75605. /**
  75606. * A display name, a user-readable name identifying it.
  75607. */
  75608. readonly displayName: string;
  75609. readonly isConnected: boolean;
  75610. readonly isPresenting: boolean;
  75611. /**
  75612. * If this VRDisplay supports room-scale experiences, the optional
  75613. * stage attribute contains details on the room-scale parameters.
  75614. */
  75615. readonly stageParameters: VRStageParameters | null;
  75616. /**
  75617. * Passing the value returned by `requestAnimationFrame` to
  75618. * `cancelAnimationFrame` will unregister the callback.
  75619. * @param handle Define the hanle of the request to cancel
  75620. */
  75621. cancelAnimationFrame(handle: number): void;
  75622. /**
  75623. * Stops presenting to the VRDisplay.
  75624. * @returns a promise to know when it stopped
  75625. */
  75626. exitPresent(): Promise<void>;
  75627. /**
  75628. * Return the current VREyeParameters for the given eye.
  75629. * @param whichEye Define the eye we want the parameter for
  75630. * @returns the eye parameters
  75631. */
  75632. getEyeParameters(whichEye: string): VREyeParameters;
  75633. /**
  75634. * Populates the passed VRFrameData with the information required to render
  75635. * the current frame.
  75636. * @param frameData Define the data structure to populate
  75637. * @returns true if ok otherwise false
  75638. */
  75639. getFrameData(frameData: VRFrameData): boolean;
  75640. /**
  75641. * Get the layers currently being presented.
  75642. * @returns the list of VR layers
  75643. */
  75644. getLayers(): VRLayer[];
  75645. /**
  75646. * Return a VRPose containing the future predicted pose of the VRDisplay
  75647. * when the current frame will be presented. The value returned will not
  75648. * change until JavaScript has returned control to the browser.
  75649. *
  75650. * The VRPose will contain the position, orientation, velocity,
  75651. * and acceleration of each of these properties.
  75652. * @returns the pose object
  75653. */
  75654. getPose(): VRPose;
  75655. /**
  75656. * Return the current instantaneous pose of the VRDisplay, with no
  75657. * prediction applied.
  75658. * @returns the current instantaneous pose
  75659. */
  75660. getImmediatePose(): VRPose;
  75661. /**
  75662. * The callback passed to `requestAnimationFrame` will be called
  75663. * any time a new frame should be rendered. When the VRDisplay is
  75664. * presenting the callback will be called at the native refresh
  75665. * rate of the HMD. When not presenting this function acts
  75666. * identically to how window.requestAnimationFrame acts. Content should
  75667. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75668. * asynchronously from other displays and at differing refresh rates.
  75669. * @param callback Define the eaction to run next frame
  75670. * @returns the request handle it
  75671. */
  75672. requestAnimationFrame(callback: FrameRequestCallback): number;
  75673. /**
  75674. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75675. * Repeat calls while already presenting will update the VRLayers being displayed.
  75676. * @param layers Define the list of layer to present
  75677. * @returns a promise to know when the request has been fulfilled
  75678. */
  75679. requestPresent(layers: VRLayer[]): Promise<void>;
  75680. /**
  75681. * Reset the pose for this display, treating its current position and
  75682. * orientation as the "origin/zero" values. VRPose.position,
  75683. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75684. * updated when calling resetPose(). This should be called in only
  75685. * sitting-space experiences.
  75686. */
  75687. resetPose(): void;
  75688. /**
  75689. * The VRLayer provided to the VRDisplay will be captured and presented
  75690. * in the HMD. Calling this function has the same effect on the source
  75691. * canvas as any other operation that uses its source image, and canvases
  75692. * created without preserveDrawingBuffer set to true will be cleared.
  75693. * @param pose Define the pose to submit
  75694. */
  75695. submitFrame(pose?: VRPose): void;
  75696. }
  75697. declare var VRDisplay: {
  75698. prototype: VRDisplay;
  75699. new(): VRDisplay;
  75700. };
  75701. interface VRLayer {
  75702. leftBounds?: number[] | Float32Array | null;
  75703. rightBounds?: number[] | Float32Array | null;
  75704. source?: HTMLCanvasElement | null;
  75705. }
  75706. interface VRDisplayCapabilities {
  75707. readonly canPresent: boolean;
  75708. readonly hasExternalDisplay: boolean;
  75709. readonly hasOrientation: boolean;
  75710. readonly hasPosition: boolean;
  75711. readonly maxLayers: number;
  75712. }
  75713. interface VREyeParameters {
  75714. /** @deprecated */
  75715. readonly fieldOfView: VRFieldOfView;
  75716. readonly offset: Float32Array;
  75717. readonly renderHeight: number;
  75718. readonly renderWidth: number;
  75719. }
  75720. interface VRFieldOfView {
  75721. readonly downDegrees: number;
  75722. readonly leftDegrees: number;
  75723. readonly rightDegrees: number;
  75724. readonly upDegrees: number;
  75725. }
  75726. interface VRFrameData {
  75727. readonly leftProjectionMatrix: Float32Array;
  75728. readonly leftViewMatrix: Float32Array;
  75729. readonly pose: VRPose;
  75730. readonly rightProjectionMatrix: Float32Array;
  75731. readonly rightViewMatrix: Float32Array;
  75732. readonly timestamp: number;
  75733. }
  75734. interface VRPose {
  75735. readonly angularAcceleration: Float32Array | null;
  75736. readonly angularVelocity: Float32Array | null;
  75737. readonly linearAcceleration: Float32Array | null;
  75738. readonly linearVelocity: Float32Array | null;
  75739. readonly orientation: Float32Array | null;
  75740. readonly position: Float32Array | null;
  75741. readonly timestamp: number;
  75742. }
  75743. interface VRStageParameters {
  75744. sittingToStandingTransform?: Float32Array;
  75745. sizeX?: number;
  75746. sizeY?: number;
  75747. }
  75748. interface Navigator {
  75749. getVRDisplays(): Promise<VRDisplay[]>;
  75750. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75751. }
  75752. interface Window {
  75753. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75754. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75755. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75756. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75757. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75758. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75759. }
  75760. interface Gamepad {
  75761. readonly displayId: number;
  75762. }
  75763. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  75764. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  75765. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  75766. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  75767. type XRHandedness = "none" | "left" | "right";
  75768. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  75769. type XREye = "none" | "left" | "right";
  75770. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  75771. interface XRSpace extends EventTarget {}
  75772. interface XRRenderState {
  75773. depthNear?: number;
  75774. depthFar?: number;
  75775. inlineVerticalFieldOfView?: number;
  75776. baseLayer?: XRWebGLLayer;
  75777. }
  75778. interface XRInputSource {
  75779. handedness: XRHandedness;
  75780. targetRayMode: XRTargetRayMode;
  75781. targetRaySpace: XRSpace;
  75782. gripSpace: XRSpace | undefined;
  75783. gamepad: Gamepad | undefined;
  75784. profiles: Array<string>;
  75785. hand: XRHand | undefined;
  75786. }
  75787. interface XRSessionInit {
  75788. optionalFeatures?: string[];
  75789. requiredFeatures?: string[];
  75790. }
  75791. interface XRSession {
  75792. addEventListener: Function;
  75793. removeEventListener: Function;
  75794. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  75795. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  75796. requestAnimationFrame: Function;
  75797. end(): Promise<void>;
  75798. renderState: XRRenderState;
  75799. inputSources: Array<XRInputSource>;
  75800. // hit test
  75801. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  75802. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  75803. // legacy AR hit test
  75804. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75805. // legacy plane detection
  75806. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  75807. }
  75808. interface XRReferenceSpace extends XRSpace {
  75809. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  75810. onreset: any;
  75811. }
  75812. type XRPlaneSet = Set<XRPlane>;
  75813. type XRAnchorSet = Set<XRAnchor>;
  75814. interface XRFrame {
  75815. session: XRSession;
  75816. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  75817. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  75818. // AR
  75819. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  75820. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  75821. // Anchors
  75822. trackedAnchors?: XRAnchorSet;
  75823. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  75824. // Planes
  75825. worldInformation: {
  75826. detectedPlanes?: XRPlaneSet;
  75827. };
  75828. // Hand tracking
  75829. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  75830. }
  75831. interface XRViewerPose extends XRPose {
  75832. views: Array<XRView>;
  75833. }
  75834. interface XRPose {
  75835. transform: XRRigidTransform;
  75836. emulatedPosition: boolean;
  75837. }
  75838. interface XRWebGLLayerOptions {
  75839. antialias?: boolean;
  75840. depth?: boolean;
  75841. stencil?: boolean;
  75842. alpha?: boolean;
  75843. multiview?: boolean;
  75844. framebufferScaleFactor?: number;
  75845. }
  75846. declare var XRWebGLLayer: {
  75847. prototype: XRWebGLLayer;
  75848. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  75849. };
  75850. interface XRWebGLLayer {
  75851. framebuffer: WebGLFramebuffer;
  75852. framebufferWidth: number;
  75853. framebufferHeight: number;
  75854. getViewport: Function;
  75855. }
  75856. declare class XRRigidTransform {
  75857. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75858. position: DOMPointReadOnly;
  75859. orientation: DOMPointReadOnly;
  75860. matrix: Float32Array;
  75861. inverse: XRRigidTransform;
  75862. }
  75863. interface XRView {
  75864. eye: XREye;
  75865. projectionMatrix: Float32Array;
  75866. transform: XRRigidTransform;
  75867. }
  75868. interface XRInputSourceChangeEvent {
  75869. session: XRSession;
  75870. removed: Array<XRInputSource>;
  75871. added: Array<XRInputSource>;
  75872. }
  75873. interface XRInputSourceEvent extends Event {
  75874. readonly frame: XRFrame;
  75875. readonly inputSource: XRInputSource;
  75876. }
  75877. // Experimental(er) features
  75878. declare class XRRay {
  75879. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  75880. origin: DOMPointReadOnly;
  75881. direction: DOMPointReadOnly;
  75882. matrix: Float32Array;
  75883. }
  75884. declare enum XRHitTestTrackableType {
  75885. "point",
  75886. "plane",
  75887. "mesh",
  75888. }
  75889. interface XRHitResult {
  75890. hitMatrix: Float32Array;
  75891. }
  75892. interface XRTransientInputHitTestResult {
  75893. readonly inputSource: XRInputSource;
  75894. readonly results: Array<XRHitTestResult>;
  75895. }
  75896. interface XRHitTestResult {
  75897. getPose(baseSpace: XRSpace): XRPose | undefined;
  75898. // When anchor system is enabled
  75899. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  75900. }
  75901. interface XRHitTestSource {
  75902. cancel(): void;
  75903. }
  75904. interface XRTransientInputHitTestSource {
  75905. cancel(): void;
  75906. }
  75907. interface XRHitTestOptionsInit {
  75908. space: XRSpace;
  75909. entityTypes?: Array<XRHitTestTrackableType>;
  75910. offsetRay?: XRRay;
  75911. }
  75912. interface XRTransientInputHitTestOptionsInit {
  75913. profile: string;
  75914. entityTypes?: Array<XRHitTestTrackableType>;
  75915. offsetRay?: XRRay;
  75916. }
  75917. interface XRAnchor {
  75918. anchorSpace: XRSpace;
  75919. delete(): void;
  75920. }
  75921. interface XRPlane {
  75922. orientation: "Horizontal" | "Vertical";
  75923. planeSpace: XRSpace;
  75924. polygon: Array<DOMPointReadOnly>;
  75925. lastChangedTime: number;
  75926. }
  75927. interface XRJointSpace extends XRSpace {}
  75928. interface XRJointPose extends XRPose {
  75929. radius: number | undefined;
  75930. }
  75931. declare class XRHand extends Array<XRJointSpace> {
  75932. readonly length: number;
  75933. static readonly WRIST = 0;
  75934. static readonly THUMB_METACARPAL = 1;
  75935. static readonly THUMB_PHALANX_PROXIMAL = 2;
  75936. static readonly THUMB_PHALANX_DISTAL = 3;
  75937. static readonly THUMB_PHALANX_TIP = 4;
  75938. static readonly INDEX_METACARPAL = 5;
  75939. static readonly INDEX_PHALANX_PROXIMAL = 6;
  75940. static readonly INDEX_PHALANX_INTERMEDIATE = 7;
  75941. static readonly INDEX_PHALANX_DISTAL = 8;
  75942. static readonly INDEX_PHALANX_TIP = 9;
  75943. static readonly MIDDLE_METACARPAL = 10;
  75944. static readonly MIDDLE_PHALANX_PROXIMAL = 11;
  75945. static readonly MIDDLE_PHALANX_INTERMEDIATE = 12;
  75946. static readonly MIDDLE_PHALANX_DISTAL = 13;
  75947. static readonly MIDDLE_PHALANX_TIP = 14;
  75948. static readonly RING_METACARPAL = 15;
  75949. static readonly RING_PHALANX_PROXIMAL = 16;
  75950. static readonly RING_PHALANX_INTERMEDIATE = 17;
  75951. static readonly RING_PHALANX_DISTAL = 18;
  75952. static readonly RING_PHALANX_TIP = 19;
  75953. static readonly LITTLE_METACARPAL = 20;
  75954. static readonly LITTLE_PHALANX_PROXIMAL = 21;
  75955. static readonly LITTLE_PHALANX_INTERMEDIATE = 22;
  75956. static readonly LITTLE_PHALANX_DISTAL = 23;
  75957. static readonly LITTLE_PHALANX_TIP = 24;
  75958. }
  75959. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  75960. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  75961. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  75962. interface XRSession {
  75963. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  75964. }
  75965. interface XRFrame {
  75966. featurePointCloud? : Array<number>;
  75967. }
  75968. /**
  75969. * @ignore
  75970. */
  75971. declare module BABYLON.GLTF2.Exporter {
  75972. }
  75973. /**
  75974. * @ignore
  75975. */
  75976. declare module BABYLON.GLTF1 {
  75977. }
  75978. declare module BABYLON.GUI {
  75979. /**
  75980. * Class used to specific a value and its associated unit
  75981. */
  75982. export class ValueAndUnit {
  75983. /** defines the unit to store */
  75984. unit: number;
  75985. /** defines a boolean indicating if the value can be negative */
  75986. negativeValueAllowed: boolean;
  75987. private _value;
  75988. private _originalUnit;
  75989. /**
  75990. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  75991. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75992. */
  75993. ignoreAdaptiveScaling: boolean;
  75994. /**
  75995. * Creates a new ValueAndUnit
  75996. * @param value defines the value to store
  75997. * @param unit defines the unit to store
  75998. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  75999. */
  76000. constructor(value: number,
  76001. /** defines the unit to store */
  76002. unit?: number,
  76003. /** defines a boolean indicating if the value can be negative */
  76004. negativeValueAllowed?: boolean);
  76005. /** Gets a boolean indicating if the value is a percentage */
  76006. get isPercentage(): boolean;
  76007. /** Gets a boolean indicating if the value is store as pixel */
  76008. get isPixel(): boolean;
  76009. /** Gets direct internal value */
  76010. get internalValue(): number;
  76011. /**
  76012. * Gets value as pixel
  76013. * @param host defines the root host
  76014. * @param refValue defines the reference value for percentages
  76015. * @returns the value as pixel
  76016. */
  76017. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76018. /**
  76019. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76020. * @param value defines the value to store
  76021. * @param unit defines the unit to store
  76022. * @returns the current ValueAndUnit
  76023. */
  76024. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76025. /**
  76026. * Gets the value accordingly to its unit
  76027. * @param host defines the root host
  76028. * @returns the value
  76029. */
  76030. getValue(host: AdvancedDynamicTexture): number;
  76031. /**
  76032. * Gets a string representation of the value
  76033. * @param host defines the root host
  76034. * @param decimals defines an optional number of decimals to display
  76035. * @returns a string
  76036. */
  76037. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76038. /**
  76039. * Store a value parsed from a string
  76040. * @param source defines the source string
  76041. * @returns true if the value was successfully parsed
  76042. */
  76043. fromString(source: string | number): boolean;
  76044. private static _Regex;
  76045. private static _UNITMODE_PERCENTAGE;
  76046. private static _UNITMODE_PIXEL;
  76047. /** UNITMODE_PERCENTAGE */
  76048. static get UNITMODE_PERCENTAGE(): number;
  76049. /** UNITMODE_PIXEL */
  76050. static get UNITMODE_PIXEL(): number;
  76051. }
  76052. }
  76053. declare module BABYLON.GUI {
  76054. /**
  76055. * Define a style used by control to automatically setup properties based on a template.
  76056. * Only support font related properties so far
  76057. */
  76058. export class Style implements BABYLON.IDisposable {
  76059. private _fontFamily;
  76060. private _fontStyle;
  76061. private _fontWeight;
  76062. /** @hidden */
  76063. _host: AdvancedDynamicTexture;
  76064. /** @hidden */
  76065. _fontSize: ValueAndUnit;
  76066. /**
  76067. * BABYLON.Observable raised when the style values are changed
  76068. */
  76069. onChangedObservable: BABYLON.Observable<Style>;
  76070. /**
  76071. * Creates a new style object
  76072. * @param host defines the AdvancedDynamicTexture which hosts this style
  76073. */
  76074. constructor(host: AdvancedDynamicTexture);
  76075. /**
  76076. * Gets or sets the font size
  76077. */
  76078. get fontSize(): string | number;
  76079. set fontSize(value: string | number);
  76080. /**
  76081. * Gets or sets the font family
  76082. */
  76083. get fontFamily(): string;
  76084. set fontFamily(value: string);
  76085. /**
  76086. * Gets or sets the font style
  76087. */
  76088. get fontStyle(): string;
  76089. set fontStyle(value: string);
  76090. /** Gets or sets font weight */
  76091. get fontWeight(): string;
  76092. set fontWeight(value: string);
  76093. /** Dispose all associated resources */
  76094. dispose(): void;
  76095. }
  76096. }
  76097. declare module BABYLON.GUI {
  76098. /**
  76099. * Class used to transport BABYLON.Vector2 information for pointer events
  76100. */
  76101. export class Vector2WithInfo extends BABYLON.Vector2 {
  76102. /** defines the current mouse button index */
  76103. buttonIndex: number;
  76104. /**
  76105. * Creates a new Vector2WithInfo
  76106. * @param source defines the vector2 data to transport
  76107. * @param buttonIndex defines the current mouse button index
  76108. */
  76109. constructor(source: BABYLON.Vector2,
  76110. /** defines the current mouse button index */
  76111. buttonIndex?: number);
  76112. }
  76113. /** Class used to provide 2D matrix features */
  76114. export class Matrix2D {
  76115. /** Gets the internal array of 6 floats used to store matrix data */
  76116. m: Float32Array;
  76117. /**
  76118. * Creates a new matrix
  76119. * @param m00 defines value for (0, 0)
  76120. * @param m01 defines value for (0, 1)
  76121. * @param m10 defines value for (1, 0)
  76122. * @param m11 defines value for (1, 1)
  76123. * @param m20 defines value for (2, 0)
  76124. * @param m21 defines value for (2, 1)
  76125. */
  76126. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76127. /**
  76128. * Fills the matrix from direct values
  76129. * @param m00 defines value for (0, 0)
  76130. * @param m01 defines value for (0, 1)
  76131. * @param m10 defines value for (1, 0)
  76132. * @param m11 defines value for (1, 1)
  76133. * @param m20 defines value for (2, 0)
  76134. * @param m21 defines value for (2, 1)
  76135. * @returns the current modified matrix
  76136. */
  76137. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76138. /**
  76139. * Gets matrix determinant
  76140. * @returns the determinant
  76141. */
  76142. determinant(): number;
  76143. /**
  76144. * Inverses the matrix and stores it in a target matrix
  76145. * @param result defines the target matrix
  76146. * @returns the current matrix
  76147. */
  76148. invertToRef(result: Matrix2D): Matrix2D;
  76149. /**
  76150. * Multiplies the current matrix with another one
  76151. * @param other defines the second operand
  76152. * @param result defines the target matrix
  76153. * @returns the current matrix
  76154. */
  76155. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76156. /**
  76157. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76158. * @param x defines the x coordinate to transform
  76159. * @param y defines the x coordinate to transform
  76160. * @param result defines the target vector2
  76161. * @returns the current matrix
  76162. */
  76163. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76164. /**
  76165. * Creates an identity matrix
  76166. * @returns a new matrix
  76167. */
  76168. static Identity(): Matrix2D;
  76169. /**
  76170. * Creates a translation matrix and stores it in a target matrix
  76171. * @param x defines the x coordinate of the translation
  76172. * @param y defines the y coordinate of the translation
  76173. * @param result defines the target matrix
  76174. */
  76175. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76176. /**
  76177. * Creates a scaling matrix and stores it in a target matrix
  76178. * @param x defines the x coordinate of the scaling
  76179. * @param y defines the y coordinate of the scaling
  76180. * @param result defines the target matrix
  76181. */
  76182. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76183. /**
  76184. * Creates a rotation matrix and stores it in a target matrix
  76185. * @param angle defines the rotation angle
  76186. * @param result defines the target matrix
  76187. */
  76188. static RotationToRef(angle: number, result: Matrix2D): void;
  76189. private static _TempPreTranslationMatrix;
  76190. private static _TempPostTranslationMatrix;
  76191. private static _TempRotationMatrix;
  76192. private static _TempScalingMatrix;
  76193. private static _TempCompose0;
  76194. private static _TempCompose1;
  76195. private static _TempCompose2;
  76196. /**
  76197. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  76198. * @param tx defines the x coordinate of the translation
  76199. * @param ty defines the y coordinate of the translation
  76200. * @param angle defines the rotation angle
  76201. * @param scaleX defines the x coordinate of the scaling
  76202. * @param scaleY defines the y coordinate of the scaling
  76203. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  76204. * @param result defines the target matrix
  76205. */
  76206. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  76207. }
  76208. }
  76209. declare module BABYLON.GUI {
  76210. /**
  76211. * Class used to store 2D control sizes
  76212. */
  76213. export class Measure {
  76214. /** defines left coordinate */
  76215. left: number;
  76216. /** defines top coordinate */
  76217. top: number;
  76218. /** defines width dimension */
  76219. width: number;
  76220. /** defines height dimension */
  76221. height: number;
  76222. /**
  76223. * Creates a new measure
  76224. * @param left defines left coordinate
  76225. * @param top defines top coordinate
  76226. * @param width defines width dimension
  76227. * @param height defines height dimension
  76228. */
  76229. constructor(
  76230. /** defines left coordinate */
  76231. left: number,
  76232. /** defines top coordinate */
  76233. top: number,
  76234. /** defines width dimension */
  76235. width: number,
  76236. /** defines height dimension */
  76237. height: number);
  76238. /**
  76239. * Copy from another measure
  76240. * @param other defines the other measure to copy from
  76241. */
  76242. copyFrom(other: Measure): void;
  76243. /**
  76244. * Copy from a group of 4 floats
  76245. * @param left defines left coordinate
  76246. * @param top defines top coordinate
  76247. * @param width defines width dimension
  76248. * @param height defines height dimension
  76249. */
  76250. copyFromFloats(left: number, top: number, width: number, height: number): void;
  76251. /**
  76252. * Computes the axis aligned bounding box measure for two given measures
  76253. * @param a Input measure
  76254. * @param b Input measure
  76255. * @param result the resulting bounding measure
  76256. */
  76257. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  76258. /**
  76259. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76260. * @param transform the matrix to transform the measure before computing the AABB
  76261. * @param addX number to add to left
  76262. * @param addY number to add to top
  76263. * @param addWidth number to add to width
  76264. * @param addHeight number to add to height
  76265. * @param result the resulting AABB
  76266. */
  76267. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  76268. /**
  76269. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76270. * @param transform the matrix to transform the measure before computing the AABB
  76271. * @param result the resulting AABB
  76272. */
  76273. transformToRef(transform: Matrix2D, result: Measure): void;
  76274. /**
  76275. * Check equality between this measure and another one
  76276. * @param other defines the other measures
  76277. * @returns true if both measures are equals
  76278. */
  76279. isEqualsTo(other: Measure): boolean;
  76280. /**
  76281. * Creates an empty measure
  76282. * @returns a new measure
  76283. */
  76284. static Empty(): Measure;
  76285. }
  76286. }
  76287. declare module BABYLON.GUI {
  76288. /**
  76289. * Interface used to define a control that can receive focus
  76290. */
  76291. export interface IFocusableControl {
  76292. /**
  76293. * Function called when the control receives the focus
  76294. */
  76295. onFocus(): void;
  76296. /**
  76297. * Function called when the control loses the focus
  76298. */
  76299. onBlur(): void;
  76300. /**
  76301. * Function called to let the control handle keyboard events
  76302. * @param evt defines the current keyboard event
  76303. */
  76304. processKeyboard(evt: KeyboardEvent): void;
  76305. /**
  76306. * Function called to get the list of controls that should not steal the focus from this control
  76307. * @returns an array of controls
  76308. */
  76309. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76310. }
  76311. /**
  76312. * Class used to create texture to support 2D GUI elements
  76313. * @see https://doc.babylonjs.com/how_to/gui
  76314. */
  76315. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  76316. private _isDirty;
  76317. private _renderObserver;
  76318. private _resizeObserver;
  76319. private _preKeyboardObserver;
  76320. private _pointerMoveObserver;
  76321. private _pointerObserver;
  76322. private _canvasPointerOutObserver;
  76323. private _canvasBlurObserver;
  76324. private _background;
  76325. /** @hidden */
  76326. _rootContainer: Container;
  76327. /** @hidden */
  76328. _lastPickedControl: Control;
  76329. /** @hidden */
  76330. _lastControlOver: {
  76331. [pointerId: number]: Control;
  76332. };
  76333. /** @hidden */
  76334. _lastControlDown: {
  76335. [pointerId: number]: Control;
  76336. };
  76337. /** @hidden */
  76338. _capturingControl: {
  76339. [pointerId: number]: Control;
  76340. };
  76341. /** @hidden */
  76342. _shouldBlockPointer: boolean;
  76343. /** @hidden */
  76344. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  76345. /** @hidden */
  76346. _linkedControls: Control[];
  76347. private _isFullscreen;
  76348. private _fullscreenViewport;
  76349. private _idealWidth;
  76350. private _idealHeight;
  76351. private _useSmallestIdeal;
  76352. private _renderAtIdealSize;
  76353. private _focusedControl;
  76354. private _blockNextFocusCheck;
  76355. private _renderScale;
  76356. private _rootElement;
  76357. private _cursorChanged;
  76358. private _defaultMousePointerId;
  76359. /** @hidden */
  76360. _numLayoutCalls: number;
  76361. /** Gets the number of layout calls made the last time the ADT has been rendered */
  76362. get numLayoutCalls(): number;
  76363. /** @hidden */
  76364. _numRenderCalls: number;
  76365. /** Gets the number of render calls made the last time the ADT has been rendered */
  76366. get numRenderCalls(): number;
  76367. /**
  76368. * Define type to string to ensure compatibility across browsers
  76369. * Safari doesn't support DataTransfer constructor
  76370. */
  76371. private _clipboardData;
  76372. /**
  76373. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  76374. */
  76375. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  76376. /**
  76377. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  76378. */
  76379. onControlPickedObservable: BABYLON.Observable<Control>;
  76380. /**
  76381. * BABYLON.Observable event triggered before layout is evaluated
  76382. */
  76383. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76384. /**
  76385. * BABYLON.Observable event triggered after the layout was evaluated
  76386. */
  76387. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76388. /**
  76389. * BABYLON.Observable event triggered before the texture is rendered
  76390. */
  76391. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76392. /**
  76393. * BABYLON.Observable event triggered after the texture was rendered
  76394. */
  76395. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76396. /**
  76397. * Gets or sets a boolean defining if alpha is stored as premultiplied
  76398. */
  76399. premulAlpha: boolean;
  76400. /**
  76401. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  76402. * Useful when you want more antialiasing
  76403. */
  76404. get renderScale(): number;
  76405. set renderScale(value: number);
  76406. /** Gets or sets the background color */
  76407. get background(): string;
  76408. set background(value: string);
  76409. /**
  76410. * Gets or sets the ideal width used to design controls.
  76411. * The GUI will then rescale everything accordingly
  76412. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76413. */
  76414. get idealWidth(): number;
  76415. set idealWidth(value: number);
  76416. /**
  76417. * Gets or sets the ideal height used to design controls.
  76418. * The GUI will then rescale everything accordingly
  76419. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76420. */
  76421. get idealHeight(): number;
  76422. set idealHeight(value: number);
  76423. /**
  76424. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  76425. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76426. */
  76427. get useSmallestIdeal(): boolean;
  76428. set useSmallestIdeal(value: boolean);
  76429. /**
  76430. * Gets or sets a boolean indicating if adaptive scaling must be used
  76431. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76432. */
  76433. get renderAtIdealSize(): boolean;
  76434. set renderAtIdealSize(value: boolean);
  76435. /**
  76436. * Gets the ratio used when in "ideal mode"
  76437. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76438. * */
  76439. get idealRatio(): number;
  76440. /**
  76441. * Gets the underlying layer used to render the texture when in fullscreen mode
  76442. */
  76443. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  76444. /**
  76445. * Gets the root container control
  76446. */
  76447. get rootContainer(): Container;
  76448. /**
  76449. * Returns an array containing the root container.
  76450. * This is mostly used to let the Inspector introspects the ADT
  76451. * @returns an array containing the rootContainer
  76452. */
  76453. getChildren(): Array<Container>;
  76454. /**
  76455. * Will return all controls that are inside this texture
  76456. * @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
  76457. * @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
  76458. * @return all child controls
  76459. */
  76460. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76461. /**
  76462. * Gets or sets the current focused control
  76463. */
  76464. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  76465. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  76466. /**
  76467. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  76468. */
  76469. get isForeground(): boolean;
  76470. set isForeground(value: boolean);
  76471. /**
  76472. * Gets or set information about clipboardData
  76473. */
  76474. get clipboardData(): string;
  76475. set clipboardData(value: string);
  76476. /**
  76477. * Creates a new AdvancedDynamicTexture
  76478. * @param name defines the name of the texture
  76479. * @param width defines the width of the texture
  76480. * @param height defines the height of the texture
  76481. * @param scene defines the hosting scene
  76482. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  76483. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76484. */
  76485. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  76486. /**
  76487. * Get the current class name of the texture useful for serialization or dynamic coding.
  76488. * @returns "AdvancedDynamicTexture"
  76489. */
  76490. getClassName(): string;
  76491. /**
  76492. * Function used to execute a function on all controls
  76493. * @param func defines the function to execute
  76494. * @param container defines the container where controls belong. If null the root container will be used
  76495. */
  76496. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  76497. private _useInvalidateRectOptimization;
  76498. /**
  76499. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  76500. */
  76501. get useInvalidateRectOptimization(): boolean;
  76502. set useInvalidateRectOptimization(value: boolean);
  76503. private _invalidatedRectangle;
  76504. /**
  76505. * Invalidates a rectangle area on the gui texture
  76506. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  76507. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  76508. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  76509. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  76510. */
  76511. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  76512. /**
  76513. * Marks the texture as dirty forcing a complete update
  76514. */
  76515. markAsDirty(): void;
  76516. /**
  76517. * Helper function used to create a new style
  76518. * @returns a new style
  76519. * @see https://doc.babylonjs.com/how_to/gui#styles
  76520. */
  76521. createStyle(): Style;
  76522. /**
  76523. * Adds a new control to the root container
  76524. * @param control defines the control to add
  76525. * @returns the current texture
  76526. */
  76527. addControl(control: Control): AdvancedDynamicTexture;
  76528. /**
  76529. * Removes a control from the root container
  76530. * @param control defines the control to remove
  76531. * @returns the current texture
  76532. */
  76533. removeControl(control: Control): AdvancedDynamicTexture;
  76534. /**
  76535. * Release all resources
  76536. */
  76537. dispose(): void;
  76538. private _onResize;
  76539. /** @hidden */
  76540. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  76541. /**
  76542. * Get screen coordinates for a vector3
  76543. * @param position defines the position to project
  76544. * @param worldMatrix defines the world matrix to use
  76545. * @returns the projected position
  76546. */
  76547. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  76548. private _checkUpdate;
  76549. private _clearMeasure;
  76550. private _render;
  76551. /** @hidden */
  76552. _changeCursor(cursor: string): void;
  76553. /** @hidden */
  76554. _registerLastControlDown(control: Control, pointerId: number): void;
  76555. private _doPicking;
  76556. /** @hidden */
  76557. _cleanControlAfterRemovalFromList(list: {
  76558. [pointerId: number]: Control;
  76559. }, control: Control): void;
  76560. /** @hidden */
  76561. _cleanControlAfterRemoval(control: Control): void;
  76562. /** Attach to all scene events required to support pointer events */
  76563. attach(): void;
  76564. /** @hidden */
  76565. private onClipboardCopy;
  76566. /** @hidden */
  76567. private onClipboardCut;
  76568. /** @hidden */
  76569. private onClipboardPaste;
  76570. /**
  76571. * Register the clipboard Events onto the canvas
  76572. */
  76573. registerClipboardEvents(): void;
  76574. /**
  76575. * Unregister the clipboard Events from the canvas
  76576. */
  76577. unRegisterClipboardEvents(): void;
  76578. /**
  76579. * Connect the texture to a hosting mesh to enable interactions
  76580. * @param mesh defines the mesh to attach to
  76581. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  76582. */
  76583. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  76584. /**
  76585. * Move the focus to a specific control
  76586. * @param control defines the control which will receive the focus
  76587. */
  76588. moveFocusToControl(control: IFocusableControl): void;
  76589. private _manageFocus;
  76590. private _attachToOnPointerOut;
  76591. private _attachToOnBlur;
  76592. /**
  76593. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  76594. * @param mesh defines the mesh which will receive the texture
  76595. * @param width defines the texture width (1024 by default)
  76596. * @param height defines the texture height (1024 by default)
  76597. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  76598. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  76599. * @returns a new AdvancedDynamicTexture
  76600. */
  76601. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  76602. /**
  76603. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  76604. * In this mode the texture will rely on a layer for its rendering.
  76605. * This allows it to be treated like any other layer.
  76606. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  76607. * LayerMask is set through advancedTexture.layer.layerMask
  76608. * @param name defines name for the texture
  76609. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  76610. * @param scene defines the hsoting scene
  76611. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  76612. * @returns a new AdvancedDynamicTexture
  76613. */
  76614. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  76615. }
  76616. }
  76617. declare module BABYLON.GUI {
  76618. /**
  76619. * Root class used for all 2D controls
  76620. * @see https://doc.babylonjs.com/how_to/gui#controls
  76621. */
  76622. export class Control {
  76623. /** defines the name of the control */
  76624. name?: string | undefined;
  76625. /**
  76626. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  76627. */
  76628. static AllowAlphaInheritance: boolean;
  76629. private _alpha;
  76630. private _alphaSet;
  76631. private _zIndex;
  76632. /** @hidden */
  76633. _host: AdvancedDynamicTexture;
  76634. /** Gets or sets the control parent */
  76635. parent: BABYLON.Nullable<Container>;
  76636. /** @hidden */
  76637. _currentMeasure: Measure;
  76638. private _fontFamily;
  76639. private _fontStyle;
  76640. private _fontWeight;
  76641. private _fontSize;
  76642. private _font;
  76643. /** @hidden */
  76644. _width: ValueAndUnit;
  76645. /** @hidden */
  76646. _height: ValueAndUnit;
  76647. /** @hidden */
  76648. protected _fontOffset: {
  76649. ascent: number;
  76650. height: number;
  76651. descent: number;
  76652. };
  76653. private _color;
  76654. private _style;
  76655. private _styleObserver;
  76656. /** @hidden */
  76657. protected _horizontalAlignment: number;
  76658. /** @hidden */
  76659. protected _verticalAlignment: number;
  76660. /** @hidden */
  76661. protected _isDirty: boolean;
  76662. /** @hidden */
  76663. protected _wasDirty: boolean;
  76664. /** @hidden */
  76665. _tempParentMeasure: Measure;
  76666. /** @hidden */
  76667. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  76668. /** @hidden */
  76669. protected _cachedParentMeasure: Measure;
  76670. private _paddingLeft;
  76671. private _paddingRight;
  76672. private _paddingTop;
  76673. private _paddingBottom;
  76674. /** @hidden */
  76675. _left: ValueAndUnit;
  76676. /** @hidden */
  76677. _top: ValueAndUnit;
  76678. private _scaleX;
  76679. private _scaleY;
  76680. private _rotation;
  76681. private _transformCenterX;
  76682. private _transformCenterY;
  76683. /** @hidden */
  76684. _transformMatrix: Matrix2D;
  76685. /** @hidden */
  76686. protected _invertTransformMatrix: Matrix2D;
  76687. /** @hidden */
  76688. protected _transformedPosition: BABYLON.Vector2;
  76689. private _isMatrixDirty;
  76690. private _cachedOffsetX;
  76691. private _cachedOffsetY;
  76692. private _isVisible;
  76693. private _isHighlighted;
  76694. /** @hidden */
  76695. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  76696. private _fontSet;
  76697. private _dummyVector2;
  76698. private _downCount;
  76699. private _enterCount;
  76700. private _doNotRender;
  76701. private _downPointerIds;
  76702. protected _isEnabled: boolean;
  76703. protected _disabledColor: string;
  76704. protected _disabledColorItem: string;
  76705. /** @hidden */
  76706. protected _rebuildLayout: boolean;
  76707. /** @hidden */
  76708. _customData: any;
  76709. /** @hidden */
  76710. _isClipped: boolean;
  76711. /** @hidden */
  76712. _automaticSize: boolean;
  76713. /** @hidden */
  76714. _tag: any;
  76715. /**
  76716. * 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
  76717. */
  76718. uniqueId: number;
  76719. /**
  76720. * Gets or sets an object used to store user defined information for the node
  76721. */
  76722. metadata: any;
  76723. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  76724. isHitTestVisible: boolean;
  76725. /** Gets or sets a boolean indicating if the control can block pointer events */
  76726. isPointerBlocker: boolean;
  76727. /** Gets or sets a boolean indicating if the control can be focusable */
  76728. isFocusInvisible: boolean;
  76729. /**
  76730. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  76731. * 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
  76732. */
  76733. clipChildren: boolean;
  76734. /**
  76735. * Gets or sets a boolean indicating that control content must be clipped
  76736. * 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
  76737. */
  76738. clipContent: boolean;
  76739. /**
  76740. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  76741. */
  76742. useBitmapCache: boolean;
  76743. private _cacheData;
  76744. private _shadowOffsetX;
  76745. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  76746. get shadowOffsetX(): number;
  76747. set shadowOffsetX(value: number);
  76748. private _shadowOffsetY;
  76749. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  76750. get shadowOffsetY(): number;
  76751. set shadowOffsetY(value: number);
  76752. private _shadowBlur;
  76753. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  76754. get shadowBlur(): number;
  76755. set shadowBlur(value: number);
  76756. private _shadowColor;
  76757. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  76758. get shadowColor(): string;
  76759. set shadowColor(value: string);
  76760. /** Gets or sets the cursor to use when the control is hovered */
  76761. hoverCursor: string;
  76762. /** @hidden */
  76763. protected _linkOffsetX: ValueAndUnit;
  76764. /** @hidden */
  76765. protected _linkOffsetY: ValueAndUnit;
  76766. /** Gets the control type name */
  76767. get typeName(): string;
  76768. /**
  76769. * Get the current class name of the control.
  76770. * @returns current class name
  76771. */
  76772. getClassName(): string;
  76773. /**
  76774. * An event triggered when pointer wheel is scrolled
  76775. */
  76776. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  76777. /**
  76778. * An event triggered when the pointer move over the control.
  76779. */
  76780. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  76781. /**
  76782. * An event triggered when the pointer move out of the control.
  76783. */
  76784. onPointerOutObservable: BABYLON.Observable<Control>;
  76785. /**
  76786. * An event triggered when the pointer taps the control
  76787. */
  76788. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  76789. /**
  76790. * An event triggered when pointer up
  76791. */
  76792. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  76793. /**
  76794. * An event triggered when a control is clicked on
  76795. */
  76796. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  76797. /**
  76798. * An event triggered when pointer enters the control
  76799. */
  76800. onPointerEnterObservable: BABYLON.Observable<Control>;
  76801. /**
  76802. * An event triggered when the control is marked as dirty
  76803. */
  76804. onDirtyObservable: BABYLON.Observable<Control>;
  76805. /**
  76806. * An event triggered before drawing the control
  76807. */
  76808. onBeforeDrawObservable: BABYLON.Observable<Control>;
  76809. /**
  76810. * An event triggered after the control was drawn
  76811. */
  76812. onAfterDrawObservable: BABYLON.Observable<Control>;
  76813. /**
  76814. * An event triggered when the control has been disposed
  76815. */
  76816. onDisposeObservable: BABYLON.Observable<Control>;
  76817. /**
  76818. * Get the hosting AdvancedDynamicTexture
  76819. */
  76820. get host(): AdvancedDynamicTexture;
  76821. /** Gets or set information about font offsets (used to render and align text) */
  76822. get fontOffset(): {
  76823. ascent: number;
  76824. height: number;
  76825. descent: number;
  76826. };
  76827. set fontOffset(offset: {
  76828. ascent: number;
  76829. height: number;
  76830. descent: number;
  76831. });
  76832. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  76833. get alpha(): number;
  76834. set alpha(value: number);
  76835. /**
  76836. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  76837. */
  76838. get isHighlighted(): boolean;
  76839. set isHighlighted(value: boolean);
  76840. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  76841. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76842. */
  76843. get scaleX(): number;
  76844. set scaleX(value: number);
  76845. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  76846. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76847. */
  76848. get scaleY(): number;
  76849. set scaleY(value: number);
  76850. /** Gets or sets the rotation angle (0 by default)
  76851. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76852. */
  76853. get rotation(): number;
  76854. set rotation(value: number);
  76855. /** Gets or sets the transformation center on Y axis (0 by default)
  76856. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76857. */
  76858. get transformCenterY(): number;
  76859. set transformCenterY(value: number);
  76860. /** Gets or sets the transformation center on X axis (0 by default)
  76861. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76862. */
  76863. get transformCenterX(): number;
  76864. set transformCenterX(value: number);
  76865. /**
  76866. * Gets or sets the horizontal alignment
  76867. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76868. */
  76869. get horizontalAlignment(): number;
  76870. set horizontalAlignment(value: number);
  76871. /**
  76872. * Gets or sets the vertical alignment
  76873. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76874. */
  76875. get verticalAlignment(): number;
  76876. set verticalAlignment(value: number);
  76877. /**
  76878. * Gets or sets a fixed ratio for this control.
  76879. * When different from 0, the ratio is used to compute the "second" dimension.
  76880. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  76881. * second dimension is computed as first dimension * fixedRatio
  76882. */
  76883. fixedRatio: number;
  76884. private _fixedRatioMasterIsWidth;
  76885. /**
  76886. * Gets or sets control width
  76887. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76888. */
  76889. get width(): string | number;
  76890. set width(value: string | number);
  76891. /**
  76892. * Gets or sets the control width in pixel
  76893. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76894. */
  76895. get widthInPixels(): number;
  76896. set widthInPixels(value: number);
  76897. /**
  76898. * Gets or sets control height
  76899. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76900. */
  76901. get height(): string | number;
  76902. set height(value: string | number);
  76903. /**
  76904. * Gets or sets control height in pixel
  76905. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76906. */
  76907. get heightInPixels(): number;
  76908. set heightInPixels(value: number);
  76909. /** Gets or set font family */
  76910. get fontFamily(): string;
  76911. set fontFamily(value: string);
  76912. /** Gets or sets font style */
  76913. get fontStyle(): string;
  76914. set fontStyle(value: string);
  76915. /** Gets or sets font weight */
  76916. get fontWeight(): string;
  76917. set fontWeight(value: string);
  76918. /**
  76919. * Gets or sets style
  76920. * @see https://doc.babylonjs.com/how_to/gui#styles
  76921. */
  76922. get style(): BABYLON.Nullable<Style>;
  76923. set style(value: BABYLON.Nullable<Style>);
  76924. /** @hidden */
  76925. get _isFontSizeInPercentage(): boolean;
  76926. /** Gets or sets font size in pixels */
  76927. get fontSizeInPixels(): number;
  76928. set fontSizeInPixels(value: number);
  76929. /** Gets or sets font size */
  76930. get fontSize(): string | number;
  76931. set fontSize(value: string | number);
  76932. /** Gets or sets foreground color */
  76933. get color(): string;
  76934. set color(value: string);
  76935. /** Gets or sets z index which is used to reorder controls on the z axis */
  76936. get zIndex(): number;
  76937. set zIndex(value: number);
  76938. /** Gets or sets a boolean indicating if the control can be rendered */
  76939. get notRenderable(): boolean;
  76940. set notRenderable(value: boolean);
  76941. /** Gets or sets a boolean indicating if the control is visible */
  76942. get isVisible(): boolean;
  76943. set isVisible(value: boolean);
  76944. /** Gets a boolean indicating that the control needs to update its rendering */
  76945. get isDirty(): boolean;
  76946. /**
  76947. * Gets the current linked mesh (or null if none)
  76948. */
  76949. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76950. /**
  76951. * Gets or sets a value indicating the padding to use on the left of the control
  76952. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76953. */
  76954. get paddingLeft(): string | number;
  76955. set paddingLeft(value: string | number);
  76956. /**
  76957. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  76958. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76959. */
  76960. get paddingLeftInPixels(): number;
  76961. set paddingLeftInPixels(value: number);
  76962. /**
  76963. * Gets or sets a value indicating the padding to use on the right of the control
  76964. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76965. */
  76966. get paddingRight(): string | number;
  76967. set paddingRight(value: string | number);
  76968. /**
  76969. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  76970. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76971. */
  76972. get paddingRightInPixels(): number;
  76973. set paddingRightInPixels(value: number);
  76974. /**
  76975. * Gets or sets a value indicating the padding to use on the top of the control
  76976. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76977. */
  76978. get paddingTop(): string | number;
  76979. set paddingTop(value: string | number);
  76980. /**
  76981. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  76982. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76983. */
  76984. get paddingTopInPixels(): number;
  76985. set paddingTopInPixels(value: number);
  76986. /**
  76987. * Gets or sets a value indicating the padding to use on the bottom of the control
  76988. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76989. */
  76990. get paddingBottom(): string | number;
  76991. set paddingBottom(value: string | number);
  76992. /**
  76993. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  76994. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76995. */
  76996. get paddingBottomInPixels(): number;
  76997. set paddingBottomInPixels(value: number);
  76998. /**
  76999. * Gets or sets a value indicating the left coordinate of the control
  77000. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77001. */
  77002. get left(): string | number;
  77003. set left(value: string | number);
  77004. /**
  77005. * Gets or sets a value indicating the left coordinate in pixels of the control
  77006. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77007. */
  77008. get leftInPixels(): number;
  77009. set leftInPixels(value: number);
  77010. /**
  77011. * Gets or sets a value indicating the top coordinate of the control
  77012. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77013. */
  77014. get top(): string | number;
  77015. set top(value: string | number);
  77016. /**
  77017. * Gets or sets a value indicating the top coordinate in pixels of the control
  77018. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77019. */
  77020. get topInPixels(): number;
  77021. set topInPixels(value: number);
  77022. /**
  77023. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77024. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77025. */
  77026. get linkOffsetX(): string | number;
  77027. set linkOffsetX(value: string | number);
  77028. /**
  77029. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77030. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77031. */
  77032. get linkOffsetXInPixels(): number;
  77033. set linkOffsetXInPixels(value: number);
  77034. /**
  77035. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77036. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77037. */
  77038. get linkOffsetY(): string | number;
  77039. set linkOffsetY(value: string | number);
  77040. /**
  77041. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77042. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77043. */
  77044. get linkOffsetYInPixels(): number;
  77045. set linkOffsetYInPixels(value: number);
  77046. /** Gets the center coordinate on X axis */
  77047. get centerX(): number;
  77048. /** Gets the center coordinate on Y axis */
  77049. get centerY(): number;
  77050. /** Gets or sets if control is Enabled*/
  77051. get isEnabled(): boolean;
  77052. set isEnabled(value: boolean);
  77053. /** Gets or sets background color of control if it's disabled*/
  77054. get disabledColor(): string;
  77055. set disabledColor(value: string);
  77056. /** Gets or sets front color of control if it's disabled*/
  77057. get disabledColorItem(): string;
  77058. set disabledColorItem(value: string);
  77059. /**
  77060. * Creates a new control
  77061. * @param name defines the name of the control
  77062. */
  77063. constructor(
  77064. /** defines the name of the control */
  77065. name?: string | undefined);
  77066. /** @hidden */
  77067. protected _getTypeName(): string;
  77068. /**
  77069. * Gets the first ascendant in the hierarchy of the given type
  77070. * @param className defines the required type
  77071. * @returns the ascendant or null if not found
  77072. */
  77073. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77074. /** @hidden */
  77075. _resetFontCache(): void;
  77076. /**
  77077. * Determines if a container is an ascendant of the current control
  77078. * @param container defines the container to look for
  77079. * @returns true if the container is one of the ascendant of the control
  77080. */
  77081. isAscendant(container: Control): boolean;
  77082. /**
  77083. * Gets coordinates in local control space
  77084. * @param globalCoordinates defines the coordinates to transform
  77085. * @returns the new coordinates in local space
  77086. */
  77087. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77088. /**
  77089. * Gets coordinates in local control space
  77090. * @param globalCoordinates defines the coordinates to transform
  77091. * @param result defines the target vector2 where to store the result
  77092. * @returns the current control
  77093. */
  77094. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77095. /**
  77096. * Gets coordinates in parent local control space
  77097. * @param globalCoordinates defines the coordinates to transform
  77098. * @returns the new coordinates in parent local space
  77099. */
  77100. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77101. /**
  77102. * Move the current control to a vector3 position projected onto the screen.
  77103. * @param position defines the target position
  77104. * @param scene defines the hosting scene
  77105. */
  77106. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77107. /**
  77108. * Will store all controls that have this control as ascendant in a given array
  77109. * @param results defines the array where to store the descendants
  77110. * @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
  77111. * @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
  77112. */
  77113. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77114. /**
  77115. * Will return all controls that have this control as ascendant
  77116. * @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
  77117. * @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
  77118. * @return all child controls
  77119. */
  77120. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77121. /**
  77122. * Link current control with a target mesh
  77123. * @param mesh defines the mesh to link with
  77124. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77125. */
  77126. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77127. /** @hidden */
  77128. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77129. /** @hidden */
  77130. _offsetLeft(offset: number): void;
  77131. /** @hidden */
  77132. _offsetTop(offset: number): void;
  77133. /** @hidden */
  77134. _markMatrixAsDirty(): void;
  77135. /** @hidden */
  77136. _flagDescendantsAsMatrixDirty(): void;
  77137. /** @hidden */
  77138. _intersectsRect(rect: Measure): boolean;
  77139. /** @hidden */
  77140. protected invalidateRect(): void;
  77141. /** @hidden */
  77142. _markAsDirty(force?: boolean): void;
  77143. /** @hidden */
  77144. _markAllAsDirty(): void;
  77145. /** @hidden */
  77146. _link(host: AdvancedDynamicTexture): void;
  77147. /** @hidden */
  77148. protected _transform(context?: CanvasRenderingContext2D): void;
  77149. /** @hidden */
  77150. _renderHighlight(context: CanvasRenderingContext2D): void;
  77151. /** @hidden */
  77152. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77153. /** @hidden */
  77154. protected _applyStates(context: CanvasRenderingContext2D): void;
  77155. /** @hidden */
  77156. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77157. /** @hidden */
  77158. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77159. protected _evaluateClippingState(parentMeasure: Measure): void;
  77160. /** @hidden */
  77161. _measure(): void;
  77162. /** @hidden */
  77163. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77164. /** @hidden */
  77165. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77166. /** @hidden */
  77167. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77168. /** @hidden */
  77169. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77170. private static _ClipMeasure;
  77171. private _tmpMeasureA;
  77172. private _clip;
  77173. /** @hidden */
  77174. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77175. /** @hidden */
  77176. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77177. /**
  77178. * Tests if a given coordinates belong to the current control
  77179. * @param x defines x coordinate to test
  77180. * @param y defines y coordinate to test
  77181. * @returns true if the coordinates are inside the control
  77182. */
  77183. contains(x: number, y: number): boolean;
  77184. /** @hidden */
  77185. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77186. /** @hidden */
  77187. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77188. /** @hidden */
  77189. _onPointerEnter(target: Control): boolean;
  77190. /** @hidden */
  77191. _onPointerOut(target: Control, force?: boolean): void;
  77192. /** @hidden */
  77193. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77194. /** @hidden */
  77195. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77196. /** @hidden */
  77197. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77198. /** @hidden */
  77199. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  77200. /** @hidden */
  77201. _onCanvasBlur(): void;
  77202. /** @hidden */
  77203. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77204. private _prepareFont;
  77205. /** Releases associated resources */
  77206. dispose(): void;
  77207. private static _HORIZONTAL_ALIGNMENT_LEFT;
  77208. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  77209. private static _HORIZONTAL_ALIGNMENT_CENTER;
  77210. private static _VERTICAL_ALIGNMENT_TOP;
  77211. private static _VERTICAL_ALIGNMENT_BOTTOM;
  77212. private static _VERTICAL_ALIGNMENT_CENTER;
  77213. /** HORIZONTAL_ALIGNMENT_LEFT */
  77214. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  77215. /** HORIZONTAL_ALIGNMENT_RIGHT */
  77216. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  77217. /** HORIZONTAL_ALIGNMENT_CENTER */
  77218. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  77219. /** VERTICAL_ALIGNMENT_TOP */
  77220. static get VERTICAL_ALIGNMENT_TOP(): number;
  77221. /** VERTICAL_ALIGNMENT_BOTTOM */
  77222. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  77223. /** VERTICAL_ALIGNMENT_CENTER */
  77224. static get VERTICAL_ALIGNMENT_CENTER(): number;
  77225. private static _FontHeightSizes;
  77226. /** @hidden */
  77227. static _GetFontOffset(font: string): {
  77228. ascent: number;
  77229. height: number;
  77230. descent: number;
  77231. };
  77232. /**
  77233. * Creates a stack panel that can be used to render headers
  77234. * @param control defines the control to associate with the header
  77235. * @param text defines the text of the header
  77236. * @param size defines the size of the header
  77237. * @param options defines options used to configure the header
  77238. * @returns a new StackPanel
  77239. * @ignore
  77240. * @hidden
  77241. */
  77242. static AddHeader: (control: Control, text: string, size: string | number, options: {
  77243. isHorizontal: boolean;
  77244. controlFirst: boolean;
  77245. }) => any;
  77246. /** @hidden */
  77247. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  77248. }
  77249. }
  77250. declare module BABYLON.GUI {
  77251. /**
  77252. * Root class for 2D containers
  77253. * @see https://doc.babylonjs.com/how_to/gui#containers
  77254. */
  77255. export class Container extends Control {
  77256. name?: string | undefined;
  77257. /** @hidden */
  77258. _children: Control[];
  77259. /** @hidden */
  77260. protected _measureForChildren: Measure;
  77261. /** @hidden */
  77262. protected _background: string;
  77263. /** @hidden */
  77264. protected _adaptWidthToChildren: boolean;
  77265. /** @hidden */
  77266. protected _adaptHeightToChildren: boolean;
  77267. /**
  77268. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  77269. */
  77270. logLayoutCycleErrors: boolean;
  77271. /**
  77272. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  77273. */
  77274. maxLayoutCycle: number;
  77275. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  77276. get adaptHeightToChildren(): boolean;
  77277. set adaptHeightToChildren(value: boolean);
  77278. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  77279. get adaptWidthToChildren(): boolean;
  77280. set adaptWidthToChildren(value: boolean);
  77281. /** Gets or sets background color */
  77282. get background(): string;
  77283. set background(value: string);
  77284. /** Gets the list of children */
  77285. get children(): Control[];
  77286. /**
  77287. * Creates a new Container
  77288. * @param name defines the name of the container
  77289. */
  77290. constructor(name?: string | undefined);
  77291. protected _getTypeName(): string;
  77292. _flagDescendantsAsMatrixDirty(): void;
  77293. /**
  77294. * Gets a child using its name
  77295. * @param name defines the child name to look for
  77296. * @returns the child control if found
  77297. */
  77298. getChildByName(name: string): BABYLON.Nullable<Control>;
  77299. /**
  77300. * Gets a child using its type and its name
  77301. * @param name defines the child name to look for
  77302. * @param type defines the child type to look for
  77303. * @returns the child control if found
  77304. */
  77305. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  77306. /**
  77307. * Search for a specific control in children
  77308. * @param control defines the control to look for
  77309. * @returns true if the control is in child list
  77310. */
  77311. containsControl(control: Control): boolean;
  77312. /**
  77313. * Adds a new control to the current container
  77314. * @param control defines the control to add
  77315. * @returns the current container
  77316. */
  77317. addControl(control: BABYLON.Nullable<Control>): Container;
  77318. /**
  77319. * Removes all controls from the current container
  77320. * @returns the current container
  77321. */
  77322. clearControls(): Container;
  77323. /**
  77324. * Removes a control from the current container
  77325. * @param control defines the control to remove
  77326. * @returns the current container
  77327. */
  77328. removeControl(control: Control): Container;
  77329. /** @hidden */
  77330. _reOrderControl(control: Control): void;
  77331. /** @hidden */
  77332. _offsetLeft(offset: number): void;
  77333. /** @hidden */
  77334. _offsetTop(offset: number): void;
  77335. /** @hidden */
  77336. _markAllAsDirty(): void;
  77337. /** @hidden */
  77338. protected _localDraw(context: CanvasRenderingContext2D): void;
  77339. /** @hidden */
  77340. _link(host: AdvancedDynamicTexture): void;
  77341. /** @hidden */
  77342. protected _beforeLayout(): void;
  77343. /** @hidden */
  77344. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77345. /** @hidden */
  77346. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77347. protected _postMeasure(): void;
  77348. /** @hidden */
  77349. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77350. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77351. /** @hidden */
  77352. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77353. /** @hidden */
  77354. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77355. /** Releases associated resources */
  77356. dispose(): void;
  77357. }
  77358. }
  77359. declare module BABYLON.GUI {
  77360. /** Class used to create rectangle container */
  77361. export class Rectangle extends Container {
  77362. name?: string | undefined;
  77363. private _thickness;
  77364. private _cornerRadius;
  77365. /** Gets or sets border thickness */
  77366. get thickness(): number;
  77367. set thickness(value: number);
  77368. /** Gets or sets the corner radius angle */
  77369. get cornerRadius(): number;
  77370. set cornerRadius(value: number);
  77371. /**
  77372. * Creates a new Rectangle
  77373. * @param name defines the control name
  77374. */
  77375. constructor(name?: string | undefined);
  77376. protected _getTypeName(): string;
  77377. protected _localDraw(context: CanvasRenderingContext2D): void;
  77378. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77379. private _drawRoundedRect;
  77380. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77381. }
  77382. }
  77383. declare module BABYLON.GUI {
  77384. /**
  77385. * Enum that determines the text-wrapping mode to use.
  77386. */
  77387. export enum TextWrapping {
  77388. /**
  77389. * Clip the text when it's larger than Control.width; this is the default mode.
  77390. */
  77391. Clip = 0,
  77392. /**
  77393. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  77394. */
  77395. WordWrap = 1,
  77396. /**
  77397. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  77398. */
  77399. Ellipsis = 2
  77400. }
  77401. /**
  77402. * Class used to create text block control
  77403. */
  77404. export class TextBlock extends Control {
  77405. /**
  77406. * Defines the name of the control
  77407. */
  77408. name?: string | undefined;
  77409. private _text;
  77410. private _textWrapping;
  77411. private _textHorizontalAlignment;
  77412. private _textVerticalAlignment;
  77413. private _lines;
  77414. private _resizeToFit;
  77415. private _lineSpacing;
  77416. private _outlineWidth;
  77417. private _outlineColor;
  77418. /**
  77419. * An event triggered after the text is changed
  77420. */
  77421. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  77422. /**
  77423. * An event triggered after the text was broken up into lines
  77424. */
  77425. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  77426. /**
  77427. * Function used to split a string into words. By default, a string is split at each space character found
  77428. */
  77429. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  77430. /**
  77431. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  77432. */
  77433. get lines(): any[];
  77434. /**
  77435. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77436. */
  77437. get resizeToFit(): boolean;
  77438. /**
  77439. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77440. */
  77441. set resizeToFit(value: boolean);
  77442. /**
  77443. * Gets or sets a boolean indicating if text must be wrapped
  77444. */
  77445. get textWrapping(): TextWrapping | boolean;
  77446. /**
  77447. * Gets or sets a boolean indicating if text must be wrapped
  77448. */
  77449. set textWrapping(value: TextWrapping | boolean);
  77450. /**
  77451. * Gets or sets text to display
  77452. */
  77453. get text(): string;
  77454. /**
  77455. * Gets or sets text to display
  77456. */
  77457. set text(value: string);
  77458. /**
  77459. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77460. */
  77461. get textHorizontalAlignment(): number;
  77462. /**
  77463. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77464. */
  77465. set textHorizontalAlignment(value: number);
  77466. /**
  77467. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77468. */
  77469. get textVerticalAlignment(): number;
  77470. /**
  77471. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77472. */
  77473. set textVerticalAlignment(value: number);
  77474. /**
  77475. * Gets or sets line spacing value
  77476. */
  77477. set lineSpacing(value: string | number);
  77478. /**
  77479. * Gets or sets line spacing value
  77480. */
  77481. get lineSpacing(): string | number;
  77482. /**
  77483. * Gets or sets outlineWidth of the text to display
  77484. */
  77485. get outlineWidth(): number;
  77486. /**
  77487. * Gets or sets outlineWidth of the text to display
  77488. */
  77489. set outlineWidth(value: number);
  77490. /**
  77491. * Gets or sets outlineColor of the text to display
  77492. */
  77493. get outlineColor(): string;
  77494. /**
  77495. * Gets or sets outlineColor of the text to display
  77496. */
  77497. set outlineColor(value: string);
  77498. /**
  77499. * Creates a new TextBlock object
  77500. * @param name defines the name of the control
  77501. * @param text defines the text to display (emptry string by default)
  77502. */
  77503. constructor(
  77504. /**
  77505. * Defines the name of the control
  77506. */
  77507. name?: string | undefined, text?: string);
  77508. protected _getTypeName(): string;
  77509. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77510. private _drawText;
  77511. /** @hidden */
  77512. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77513. protected _applyStates(context: CanvasRenderingContext2D): void;
  77514. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  77515. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  77516. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  77517. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  77518. protected _renderLines(context: CanvasRenderingContext2D): void;
  77519. /**
  77520. * Given a width constraint applied on the text block, find the expected height
  77521. * @returns expected height
  77522. */
  77523. computeExpectedHeight(): number;
  77524. dispose(): void;
  77525. }
  77526. }
  77527. declare module BABYLON.GUI {
  77528. /**
  77529. * Class used to create 2D images
  77530. */
  77531. export class Image extends Control {
  77532. name?: string | undefined;
  77533. private _workingCanvas;
  77534. private _domImage;
  77535. private _imageWidth;
  77536. private _imageHeight;
  77537. private _loaded;
  77538. private _stretch;
  77539. private _source;
  77540. private _autoScale;
  77541. private _sourceLeft;
  77542. private _sourceTop;
  77543. private _sourceWidth;
  77544. private _sourceHeight;
  77545. private _svgAttributesComputationCompleted;
  77546. private _isSVG;
  77547. private _cellWidth;
  77548. private _cellHeight;
  77549. private _cellId;
  77550. private _populateNinePatchSlicesFromImage;
  77551. private _sliceLeft;
  77552. private _sliceRight;
  77553. private _sliceTop;
  77554. private _sliceBottom;
  77555. private _detectPointerOnOpaqueOnly;
  77556. private _imageDataCache;
  77557. /**
  77558. * BABYLON.Observable notified when the content is loaded
  77559. */
  77560. onImageLoadedObservable: BABYLON.Observable<Image>;
  77561. /**
  77562. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  77563. */
  77564. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  77565. /**
  77566. * Gets a boolean indicating that the content is loaded
  77567. */
  77568. get isLoaded(): boolean;
  77569. /**
  77570. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  77571. */
  77572. get populateNinePatchSlicesFromImage(): boolean;
  77573. set populateNinePatchSlicesFromImage(value: boolean);
  77574. /**
  77575. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  77576. * Beware using this as this will comsume more memory as the image has to be stored twice
  77577. */
  77578. get detectPointerOnOpaqueOnly(): boolean;
  77579. set detectPointerOnOpaqueOnly(value: boolean);
  77580. /**
  77581. * Gets or sets the left value for slicing (9-patch)
  77582. */
  77583. get sliceLeft(): number;
  77584. set sliceLeft(value: number);
  77585. /**
  77586. * Gets or sets the right value for slicing (9-patch)
  77587. */
  77588. get sliceRight(): number;
  77589. set sliceRight(value: number);
  77590. /**
  77591. * Gets or sets the top value for slicing (9-patch)
  77592. */
  77593. get sliceTop(): number;
  77594. set sliceTop(value: number);
  77595. /**
  77596. * Gets or sets the bottom value for slicing (9-patch)
  77597. */
  77598. get sliceBottom(): number;
  77599. set sliceBottom(value: number);
  77600. /**
  77601. * Gets or sets the left coordinate in the source image
  77602. */
  77603. get sourceLeft(): number;
  77604. set sourceLeft(value: number);
  77605. /**
  77606. * Gets or sets the top coordinate in the source image
  77607. */
  77608. get sourceTop(): number;
  77609. set sourceTop(value: number);
  77610. /**
  77611. * Gets or sets the width to capture in the source image
  77612. */
  77613. get sourceWidth(): number;
  77614. set sourceWidth(value: number);
  77615. /**
  77616. * Gets or sets the height to capture in the source image
  77617. */
  77618. get sourceHeight(): number;
  77619. set sourceHeight(value: number);
  77620. /** Indicates if the format of the image is SVG */
  77621. get isSVG(): boolean;
  77622. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  77623. get svgAttributesComputationCompleted(): boolean;
  77624. /**
  77625. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  77626. * @see https://doc.babylonjs.com/how_to/gui#image
  77627. */
  77628. get autoScale(): boolean;
  77629. set autoScale(value: boolean);
  77630. /** Gets or sets the streching mode used by the image */
  77631. get stretch(): number;
  77632. set stretch(value: number);
  77633. /** @hidden */
  77634. _rotate90(n: number, preserveProperties?: boolean): Image;
  77635. private _handleRotationForSVGImage;
  77636. private _rotate90SourceProperties;
  77637. /**
  77638. * Gets or sets the internal DOM image used to render the control
  77639. */
  77640. set domImage(value: HTMLImageElement);
  77641. get domImage(): HTMLImageElement;
  77642. private _onImageLoaded;
  77643. private _extractNinePatchSliceDataFromImage;
  77644. /**
  77645. * Gets or sets image source url
  77646. */
  77647. set source(value: BABYLON.Nullable<string>);
  77648. /**
  77649. * Checks for svg document with icon id present
  77650. */
  77651. private _svgCheck;
  77652. /**
  77653. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  77654. * given external svg file and icon id
  77655. */
  77656. private _getSVGAttribs;
  77657. /**
  77658. * Gets or sets the cell width to use when animation sheet is enabled
  77659. * @see https://doc.babylonjs.com/how_to/gui#image
  77660. */
  77661. get cellWidth(): number;
  77662. set cellWidth(value: number);
  77663. /**
  77664. * Gets or sets the cell height to use when animation sheet is enabled
  77665. * @see https://doc.babylonjs.com/how_to/gui#image
  77666. */
  77667. get cellHeight(): number;
  77668. set cellHeight(value: number);
  77669. /**
  77670. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  77671. * @see https://doc.babylonjs.com/how_to/gui#image
  77672. */
  77673. get cellId(): number;
  77674. set cellId(value: number);
  77675. /**
  77676. * Creates a new Image
  77677. * @param name defines the control name
  77678. * @param url defines the image url
  77679. */
  77680. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  77681. /**
  77682. * Tests if a given coordinates belong to the current control
  77683. * @param x defines x coordinate to test
  77684. * @param y defines y coordinate to test
  77685. * @returns true if the coordinates are inside the control
  77686. */
  77687. contains(x: number, y: number): boolean;
  77688. protected _getTypeName(): string;
  77689. /** Force the control to synchronize with its content */
  77690. synchronizeSizeWithContent(): void;
  77691. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77692. private _prepareWorkingCanvasForOpaqueDetection;
  77693. private _drawImage;
  77694. _draw(context: CanvasRenderingContext2D): void;
  77695. private _renderCornerPatch;
  77696. private _renderNinePatch;
  77697. dispose(): void;
  77698. /** STRETCH_NONE */
  77699. static readonly STRETCH_NONE: number;
  77700. /** STRETCH_FILL */
  77701. static readonly STRETCH_FILL: number;
  77702. /** STRETCH_UNIFORM */
  77703. static readonly STRETCH_UNIFORM: number;
  77704. /** STRETCH_EXTEND */
  77705. static readonly STRETCH_EXTEND: number;
  77706. /** NINE_PATCH */
  77707. static readonly STRETCH_NINE_PATCH: number;
  77708. }
  77709. }
  77710. declare module BABYLON.GUI {
  77711. /**
  77712. * Class used to create 2D buttons
  77713. */
  77714. export class Button extends Rectangle {
  77715. name?: string | undefined;
  77716. /**
  77717. * Function called to generate a pointer enter animation
  77718. */
  77719. pointerEnterAnimation: () => void;
  77720. /**
  77721. * Function called to generate a pointer out animation
  77722. */
  77723. pointerOutAnimation: () => void;
  77724. /**
  77725. * Function called to generate a pointer down animation
  77726. */
  77727. pointerDownAnimation: () => void;
  77728. /**
  77729. * Function called to generate a pointer up animation
  77730. */
  77731. pointerUpAnimation: () => void;
  77732. /**
  77733. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  77734. */
  77735. delegatePickingToChildren: boolean;
  77736. private _image;
  77737. /**
  77738. * Returns the image part of the button (if any)
  77739. */
  77740. get image(): BABYLON.Nullable<Image>;
  77741. private _textBlock;
  77742. /**
  77743. * Returns the image part of the button (if any)
  77744. */
  77745. get textBlock(): BABYLON.Nullable<TextBlock>;
  77746. /**
  77747. * Creates a new Button
  77748. * @param name defines the name of the button
  77749. */
  77750. constructor(name?: string | undefined);
  77751. protected _getTypeName(): string;
  77752. /** @hidden */
  77753. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77754. /** @hidden */
  77755. _onPointerEnter(target: Control): boolean;
  77756. /** @hidden */
  77757. _onPointerOut(target: Control, force?: boolean): void;
  77758. /** @hidden */
  77759. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77760. /** @hidden */
  77761. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77762. /**
  77763. * Creates a new button made with an image and a text
  77764. * @param name defines the name of the button
  77765. * @param text defines the text of the button
  77766. * @param imageUrl defines the url of the image
  77767. * @returns a new Button
  77768. */
  77769. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  77770. /**
  77771. * Creates a new button made with an image
  77772. * @param name defines the name of the button
  77773. * @param imageUrl defines the url of the image
  77774. * @returns a new Button
  77775. */
  77776. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  77777. /**
  77778. * Creates a new button made with a text
  77779. * @param name defines the name of the button
  77780. * @param text defines the text of the button
  77781. * @returns a new Button
  77782. */
  77783. static CreateSimpleButton(name: string, text: string): Button;
  77784. /**
  77785. * Creates a new button made with an image and a centered text
  77786. * @param name defines the name of the button
  77787. * @param text defines the text of the button
  77788. * @param imageUrl defines the url of the image
  77789. * @returns a new Button
  77790. */
  77791. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  77792. }
  77793. }
  77794. declare module BABYLON.GUI {
  77795. /**
  77796. * Class used to create a 2D stack panel container
  77797. */
  77798. export class StackPanel extends Container {
  77799. name?: string | undefined;
  77800. private _isVertical;
  77801. private _manualWidth;
  77802. private _manualHeight;
  77803. private _doNotTrackManualChanges;
  77804. /**
  77805. * Gets or sets a boolean indicating that layou warnings should be ignored
  77806. */
  77807. ignoreLayoutWarnings: boolean;
  77808. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  77809. get isVertical(): boolean;
  77810. set isVertical(value: boolean);
  77811. /**
  77812. * Gets or sets panel width.
  77813. * This value should not be set when in horizontal mode as it will be computed automatically
  77814. */
  77815. set width(value: string | number);
  77816. get width(): string | number;
  77817. /**
  77818. * Gets or sets panel height.
  77819. * This value should not be set when in vertical mode as it will be computed automatically
  77820. */
  77821. set height(value: string | number);
  77822. get height(): string | number;
  77823. /**
  77824. * Creates a new StackPanel
  77825. * @param name defines control name
  77826. */
  77827. constructor(name?: string | undefined);
  77828. protected _getTypeName(): string;
  77829. /** @hidden */
  77830. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77831. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77832. protected _postMeasure(): void;
  77833. }
  77834. }
  77835. declare module BABYLON.GUI {
  77836. /**
  77837. * Class used to represent a 2D checkbox
  77838. */
  77839. export class Checkbox extends Control {
  77840. name?: string | undefined;
  77841. private _isChecked;
  77842. private _background;
  77843. private _checkSizeRatio;
  77844. private _thickness;
  77845. /** Gets or sets border thickness */
  77846. get thickness(): number;
  77847. set thickness(value: number);
  77848. /**
  77849. * BABYLON.Observable raised when isChecked property changes
  77850. */
  77851. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77852. /** Gets or sets a value indicating the ratio between overall size and check size */
  77853. get checkSizeRatio(): number;
  77854. set checkSizeRatio(value: number);
  77855. /** Gets or sets background color */
  77856. get background(): string;
  77857. set background(value: string);
  77858. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77859. get isChecked(): boolean;
  77860. set isChecked(value: boolean);
  77861. /**
  77862. * Creates a new CheckBox
  77863. * @param name defines the control name
  77864. */
  77865. constructor(name?: string | undefined);
  77866. protected _getTypeName(): string;
  77867. /** @hidden */
  77868. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77869. /** @hidden */
  77870. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77871. /**
  77872. * Utility function to easily create a checkbox with a header
  77873. * @param title defines the label to use for the header
  77874. * @param onValueChanged defines the callback to call when value changes
  77875. * @returns a StackPanel containing the checkbox and a textBlock
  77876. */
  77877. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  77878. }
  77879. }
  77880. declare module BABYLON.GUI {
  77881. /**
  77882. * Class used to store key control properties
  77883. */
  77884. export class KeyPropertySet {
  77885. /** Width */
  77886. width?: string;
  77887. /** Height */
  77888. height?: string;
  77889. /** Left padding */
  77890. paddingLeft?: string;
  77891. /** Right padding */
  77892. paddingRight?: string;
  77893. /** Top padding */
  77894. paddingTop?: string;
  77895. /** Bottom padding */
  77896. paddingBottom?: string;
  77897. /** Foreground color */
  77898. color?: string;
  77899. /** Background color */
  77900. background?: string;
  77901. }
  77902. /**
  77903. * Class used to create virtual keyboard
  77904. */
  77905. export class VirtualKeyboard extends StackPanel {
  77906. /** BABYLON.Observable raised when a key is pressed */
  77907. onKeyPressObservable: BABYLON.Observable<string>;
  77908. /** Gets or sets default key button width */
  77909. defaultButtonWidth: string;
  77910. /** Gets or sets default key button height */
  77911. defaultButtonHeight: string;
  77912. /** Gets or sets default key button left padding */
  77913. defaultButtonPaddingLeft: string;
  77914. /** Gets or sets default key button right padding */
  77915. defaultButtonPaddingRight: string;
  77916. /** Gets or sets default key button top padding */
  77917. defaultButtonPaddingTop: string;
  77918. /** Gets or sets default key button bottom padding */
  77919. defaultButtonPaddingBottom: string;
  77920. /** Gets or sets default key button foreground color */
  77921. defaultButtonColor: string;
  77922. /** Gets or sets default key button background color */
  77923. defaultButtonBackground: string;
  77924. /** Gets or sets shift button foreground color */
  77925. shiftButtonColor: string;
  77926. /** Gets or sets shift button thickness*/
  77927. selectedShiftThickness: number;
  77928. /** Gets shift key state */
  77929. shiftState: number;
  77930. protected _getTypeName(): string;
  77931. private _createKey;
  77932. /**
  77933. * Adds a new row of keys
  77934. * @param keys defines the list of keys to add
  77935. * @param propertySets defines the associated property sets
  77936. */
  77937. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  77938. /**
  77939. * Set the shift key to a specific state
  77940. * @param shiftState defines the new shift state
  77941. */
  77942. applyShiftState(shiftState: number): void;
  77943. private _currentlyConnectedInputText;
  77944. private _connectedInputTexts;
  77945. private _onKeyPressObserver;
  77946. /** Gets the input text control currently attached to the keyboard */
  77947. get connectedInputText(): BABYLON.Nullable<InputText>;
  77948. /**
  77949. * Connects the keyboard with an input text control
  77950. *
  77951. * @param input defines the target control
  77952. */
  77953. connect(input: InputText): void;
  77954. /**
  77955. * Disconnects the keyboard from connected InputText controls
  77956. *
  77957. * @param input optionally defines a target control, otherwise all are disconnected
  77958. */
  77959. disconnect(input?: InputText): void;
  77960. private _removeConnectedInputObservables;
  77961. /**
  77962. * Release all resources
  77963. */
  77964. dispose(): void;
  77965. /**
  77966. * Creates a new keyboard using a default layout
  77967. *
  77968. * @param name defines control name
  77969. * @returns a new VirtualKeyboard
  77970. */
  77971. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  77972. }
  77973. }
  77974. declare module BABYLON.GUI {
  77975. /**
  77976. * Class used to create input text control
  77977. */
  77978. export class InputText extends Control implements IFocusableControl {
  77979. name?: string | undefined;
  77980. private _text;
  77981. private _placeholderText;
  77982. private _background;
  77983. private _focusedBackground;
  77984. private _focusedColor;
  77985. private _placeholderColor;
  77986. private _thickness;
  77987. private _margin;
  77988. private _autoStretchWidth;
  77989. private _maxWidth;
  77990. private _isFocused;
  77991. private _blinkTimeout;
  77992. private _blinkIsEven;
  77993. private _cursorOffset;
  77994. private _scrollLeft;
  77995. private _textWidth;
  77996. private _clickedCoordinate;
  77997. private _deadKey;
  77998. private _addKey;
  77999. private _currentKey;
  78000. private _isTextHighlightOn;
  78001. private _textHighlightColor;
  78002. private _highligherOpacity;
  78003. private _highlightedText;
  78004. private _startHighlightIndex;
  78005. private _endHighlightIndex;
  78006. private _cursorIndex;
  78007. private _onFocusSelectAll;
  78008. private _isPointerDown;
  78009. private _onClipboardObserver;
  78010. private _onPointerDblTapObserver;
  78011. /** @hidden */
  78012. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78013. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78014. promptMessage: string;
  78015. /** Force disable prompt on mobile device */
  78016. disableMobilePrompt: boolean;
  78017. /** BABYLON.Observable raised when the text changes */
  78018. onTextChangedObservable: BABYLON.Observable<InputText>;
  78019. /** BABYLON.Observable raised just before an entered character is to be added */
  78020. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78021. /** BABYLON.Observable raised when the control gets the focus */
  78022. onFocusObservable: BABYLON.Observable<InputText>;
  78023. /** BABYLON.Observable raised when the control loses the focus */
  78024. onBlurObservable: BABYLON.Observable<InputText>;
  78025. /**Observable raised when the text is highlighted */
  78026. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78027. /**Observable raised when copy event is triggered */
  78028. onTextCopyObservable: BABYLON.Observable<InputText>;
  78029. /** BABYLON.Observable raised when cut event is triggered */
  78030. onTextCutObservable: BABYLON.Observable<InputText>;
  78031. /** BABYLON.Observable raised when paste event is triggered */
  78032. onTextPasteObservable: BABYLON.Observable<InputText>;
  78033. /** BABYLON.Observable raised when a key event was processed */
  78034. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78035. /** Gets or sets the maximum width allowed by the control */
  78036. get maxWidth(): string | number;
  78037. /** Gets the maximum width allowed by the control in pixels */
  78038. get maxWidthInPixels(): number;
  78039. set maxWidth(value: string | number);
  78040. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78041. get highligherOpacity(): number;
  78042. set highligherOpacity(value: number);
  78043. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78044. get onFocusSelectAll(): boolean;
  78045. set onFocusSelectAll(value: boolean);
  78046. /** Gets or sets the text hightlight color */
  78047. get textHighlightColor(): string;
  78048. set textHighlightColor(value: string);
  78049. /** Gets or sets control margin */
  78050. get margin(): string;
  78051. /** Gets control margin in pixels */
  78052. get marginInPixels(): number;
  78053. set margin(value: string);
  78054. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78055. get autoStretchWidth(): boolean;
  78056. set autoStretchWidth(value: boolean);
  78057. /** Gets or sets border thickness */
  78058. get thickness(): number;
  78059. set thickness(value: number);
  78060. /** Gets or sets the background color when focused */
  78061. get focusedBackground(): string;
  78062. set focusedBackground(value: string);
  78063. /** Gets or sets the background color when focused */
  78064. get focusedColor(): string;
  78065. set focusedColor(value: string);
  78066. /** Gets or sets the background color */
  78067. get background(): string;
  78068. set background(value: string);
  78069. /** Gets or sets the placeholder color */
  78070. get placeholderColor(): string;
  78071. set placeholderColor(value: string);
  78072. /** Gets or sets the text displayed when the control is empty */
  78073. get placeholderText(): string;
  78074. set placeholderText(value: string);
  78075. /** Gets or sets the dead key flag */
  78076. get deadKey(): boolean;
  78077. set deadKey(flag: boolean);
  78078. /** Gets or sets the highlight text */
  78079. get highlightedText(): string;
  78080. set highlightedText(text: string);
  78081. /** Gets or sets if the current key should be added */
  78082. get addKey(): boolean;
  78083. set addKey(flag: boolean);
  78084. /** Gets or sets the value of the current key being entered */
  78085. get currentKey(): string;
  78086. set currentKey(key: string);
  78087. /** Gets or sets the text displayed in the control */
  78088. get text(): string;
  78089. set text(value: string);
  78090. /** Gets or sets control width */
  78091. get width(): string | number;
  78092. set width(value: string | number);
  78093. /**
  78094. * Creates a new InputText
  78095. * @param name defines the control name
  78096. * @param text defines the text of the control
  78097. */
  78098. constructor(name?: string | undefined, text?: string);
  78099. /** @hidden */
  78100. onBlur(): void;
  78101. /** @hidden */
  78102. onFocus(): void;
  78103. protected _getTypeName(): string;
  78104. /**
  78105. * Function called to get the list of controls that should not steal the focus from this control
  78106. * @returns an array of controls
  78107. */
  78108. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78109. /** @hidden */
  78110. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78111. /** @hidden */
  78112. private _updateValueFromCursorIndex;
  78113. /** @hidden */
  78114. private _processDblClick;
  78115. /** @hidden */
  78116. private _selectAllText;
  78117. /**
  78118. * Handles the keyboard event
  78119. * @param evt Defines the KeyboardEvent
  78120. */
  78121. processKeyboard(evt: KeyboardEvent): void;
  78122. /** @hidden */
  78123. private _onCopyText;
  78124. /** @hidden */
  78125. private _onCutText;
  78126. /** @hidden */
  78127. private _onPasteText;
  78128. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78129. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78130. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78131. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78132. protected _beforeRenderText(text: string): string;
  78133. dispose(): void;
  78134. }
  78135. }
  78136. declare module BABYLON.GUI {
  78137. /**
  78138. * Class used to create a 2D grid container
  78139. */
  78140. export class Grid extends Container {
  78141. name?: string | undefined;
  78142. private _rowDefinitions;
  78143. private _columnDefinitions;
  78144. private _cells;
  78145. private _childControls;
  78146. /**
  78147. * Gets the number of columns
  78148. */
  78149. get columnCount(): number;
  78150. /**
  78151. * Gets the number of rows
  78152. */
  78153. get rowCount(): number;
  78154. /** Gets the list of children */
  78155. get children(): Control[];
  78156. /** Gets the list of cells (e.g. the containers) */
  78157. get cells(): {
  78158. [key: string]: Container;
  78159. };
  78160. /**
  78161. * Gets the definition of a specific row
  78162. * @param index defines the index of the row
  78163. * @returns the row definition
  78164. */
  78165. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78166. /**
  78167. * Gets the definition of a specific column
  78168. * @param index defines the index of the column
  78169. * @returns the column definition
  78170. */
  78171. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78172. /**
  78173. * Adds a new row to the grid
  78174. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78175. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  78176. * @returns the current grid
  78177. */
  78178. addRowDefinition(height: number, isPixel?: boolean): Grid;
  78179. /**
  78180. * Adds a new column to the grid
  78181. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78182. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78183. * @returns the current grid
  78184. */
  78185. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  78186. /**
  78187. * Update a row definition
  78188. * @param index defines the index of the row to update
  78189. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78190. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  78191. * @returns the current grid
  78192. */
  78193. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  78194. /**
  78195. * Update a column definition
  78196. * @param index defines the index of the column to update
  78197. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78198. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78199. * @returns the current grid
  78200. */
  78201. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  78202. /**
  78203. * Gets the list of children stored in a specific cell
  78204. * @param row defines the row to check
  78205. * @param column defines the column to check
  78206. * @returns the list of controls
  78207. */
  78208. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  78209. /**
  78210. * Gets a string representing the child cell info (row x column)
  78211. * @param child defines the control to get info from
  78212. * @returns a string containing the child cell info (row x column)
  78213. */
  78214. getChildCellInfo(child: Control): string;
  78215. private _removeCell;
  78216. private _offsetCell;
  78217. /**
  78218. * Remove a column definition at specified index
  78219. * @param index defines the index of the column to remove
  78220. * @returns the current grid
  78221. */
  78222. removeColumnDefinition(index: number): Grid;
  78223. /**
  78224. * Remove a row definition at specified index
  78225. * @param index defines the index of the row to remove
  78226. * @returns the current grid
  78227. */
  78228. removeRowDefinition(index: number): Grid;
  78229. /**
  78230. * Adds a new control to the current grid
  78231. * @param control defines the control to add
  78232. * @param row defines the row where to add the control (0 by default)
  78233. * @param column defines the column where to add the control (0 by default)
  78234. * @returns the current grid
  78235. */
  78236. addControl(control: Control, row?: number, column?: number): Grid;
  78237. /**
  78238. * Removes a control from the current container
  78239. * @param control defines the control to remove
  78240. * @returns the current container
  78241. */
  78242. removeControl(control: Control): Container;
  78243. /**
  78244. * Creates a new Grid
  78245. * @param name defines control name
  78246. */
  78247. constructor(name?: string | undefined);
  78248. protected _getTypeName(): string;
  78249. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  78250. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78251. _flagDescendantsAsMatrixDirty(): void;
  78252. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78253. /** Releases associated resources */
  78254. dispose(): void;
  78255. }
  78256. }
  78257. declare module BABYLON.GUI {
  78258. /** Class used to create color pickers */
  78259. export class ColorPicker extends Control {
  78260. name?: string | undefined;
  78261. private static _Epsilon;
  78262. private _colorWheelCanvas;
  78263. private _value;
  78264. private _tmpColor;
  78265. private _pointerStartedOnSquare;
  78266. private _pointerStartedOnWheel;
  78267. private _squareLeft;
  78268. private _squareTop;
  78269. private _squareSize;
  78270. private _h;
  78271. private _s;
  78272. private _v;
  78273. private _lastPointerDownID;
  78274. /**
  78275. * BABYLON.Observable raised when the value changes
  78276. */
  78277. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  78278. /** Gets or sets the color of the color picker */
  78279. get value(): BABYLON.Color3;
  78280. set value(value: BABYLON.Color3);
  78281. /**
  78282. * Gets or sets control width
  78283. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78284. */
  78285. get width(): string | number;
  78286. set width(value: string | number);
  78287. /**
  78288. * Gets or sets control height
  78289. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78290. */
  78291. get height(): string | number;
  78292. /** Gets or sets control height */
  78293. set height(value: string | number);
  78294. /** Gets or sets control size */
  78295. get size(): string | number;
  78296. set size(value: string | number);
  78297. /**
  78298. * Creates a new ColorPicker
  78299. * @param name defines the control name
  78300. */
  78301. constructor(name?: string | undefined);
  78302. protected _getTypeName(): string;
  78303. /** @hidden */
  78304. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78305. private _updateSquareProps;
  78306. private _drawGradientSquare;
  78307. private _drawCircle;
  78308. private _createColorWheelCanvas;
  78309. /** @hidden */
  78310. _draw(context: CanvasRenderingContext2D): void;
  78311. private _pointerIsDown;
  78312. private _updateValueFromPointer;
  78313. private _isPointOnSquare;
  78314. private _isPointOnWheel;
  78315. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78316. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78317. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78318. _onCanvasBlur(): void;
  78319. /**
  78320. * This function expands the color picker by creating a color picker dialog with manual
  78321. * color value input and the ability to save colors into an array to be used later in
  78322. * subsequent launches of the dialogue.
  78323. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  78324. * @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.
  78325. * @returns picked color as a hex string and the saved colors array as hex strings.
  78326. */
  78327. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  78328. pickerWidth?: string;
  78329. pickerHeight?: string;
  78330. headerHeight?: string;
  78331. lastColor?: string;
  78332. swatchLimit?: number;
  78333. numSwatchesPerLine?: number;
  78334. savedColors?: Array<string>;
  78335. }): Promise<{
  78336. savedColors?: string[];
  78337. pickedColor: string;
  78338. }>;
  78339. }
  78340. }
  78341. declare module BABYLON.GUI {
  78342. /** Class used to create 2D ellipse containers */
  78343. export class Ellipse extends Container {
  78344. name?: string | undefined;
  78345. private _thickness;
  78346. /** Gets or sets border thickness */
  78347. get thickness(): number;
  78348. set thickness(value: number);
  78349. /**
  78350. * Creates a new Ellipse
  78351. * @param name defines the control name
  78352. */
  78353. constructor(name?: string | undefined);
  78354. protected _getTypeName(): string;
  78355. protected _localDraw(context: CanvasRenderingContext2D): void;
  78356. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78357. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78358. }
  78359. }
  78360. declare module BABYLON.GUI {
  78361. /**
  78362. * Class used to create a password control
  78363. */
  78364. export class InputPassword extends InputText {
  78365. protected _beforeRenderText(text: string): string;
  78366. }
  78367. }
  78368. declare module BABYLON.GUI {
  78369. /** Class used to render 2D lines */
  78370. export class Line extends Control {
  78371. name?: string | undefined;
  78372. private _lineWidth;
  78373. private _x1;
  78374. private _y1;
  78375. private _x2;
  78376. private _y2;
  78377. private _dash;
  78378. private _connectedControl;
  78379. private _connectedControlDirtyObserver;
  78380. /** Gets or sets the dash pattern */
  78381. get dash(): Array<number>;
  78382. set dash(value: Array<number>);
  78383. /** Gets or sets the control connected with the line end */
  78384. get connectedControl(): Control;
  78385. set connectedControl(value: Control);
  78386. /** Gets or sets start coordinates on X axis */
  78387. get x1(): string | number;
  78388. set x1(value: string | number);
  78389. /** Gets or sets start coordinates on Y axis */
  78390. get y1(): string | number;
  78391. set y1(value: string | number);
  78392. /** Gets or sets end coordinates on X axis */
  78393. get x2(): string | number;
  78394. set x2(value: string | number);
  78395. /** Gets or sets end coordinates on Y axis */
  78396. get y2(): string | number;
  78397. set y2(value: string | number);
  78398. /** Gets or sets line width */
  78399. get lineWidth(): number;
  78400. set lineWidth(value: number);
  78401. /** Gets or sets horizontal alignment */
  78402. set horizontalAlignment(value: number);
  78403. /** Gets or sets vertical alignment */
  78404. set verticalAlignment(value: number);
  78405. private get _effectiveX2();
  78406. private get _effectiveY2();
  78407. /**
  78408. * Creates a new Line
  78409. * @param name defines the control name
  78410. */
  78411. constructor(name?: string | undefined);
  78412. protected _getTypeName(): string;
  78413. _draw(context: CanvasRenderingContext2D): void;
  78414. _measure(): void;
  78415. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78416. /**
  78417. * Move one end of the line given 3D cartesian coordinates.
  78418. * @param position Targeted world position
  78419. * @param scene BABYLON.Scene
  78420. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78421. */
  78422. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  78423. /**
  78424. * Move one end of the line to a position in screen absolute space.
  78425. * @param projectedPosition Position in screen absolute space (X, Y)
  78426. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78427. */
  78428. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  78429. }
  78430. }
  78431. declare module BABYLON.GUI {
  78432. /**
  78433. * Class used to store a point for a MultiLine object.
  78434. * The point can be pure 2D coordinates, a mesh or a control
  78435. */
  78436. export class MultiLinePoint {
  78437. private _multiLine;
  78438. private _x;
  78439. private _y;
  78440. private _control;
  78441. private _mesh;
  78442. private _controlObserver;
  78443. private _meshObserver;
  78444. /** @hidden */
  78445. _point: BABYLON.Vector2;
  78446. /**
  78447. * Creates a new MultiLinePoint
  78448. * @param multiLine defines the source MultiLine object
  78449. */
  78450. constructor(multiLine: MultiLine);
  78451. /** Gets or sets x coordinate */
  78452. get x(): string | number;
  78453. set x(value: string | number);
  78454. /** Gets or sets y coordinate */
  78455. get y(): string | number;
  78456. set y(value: string | number);
  78457. /** Gets or sets the control associated with this point */
  78458. get control(): BABYLON.Nullable<Control>;
  78459. set control(value: BABYLON.Nullable<Control>);
  78460. /** Gets or sets the mesh associated with this point */
  78461. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78462. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  78463. /** Resets links */
  78464. resetLinks(): void;
  78465. /**
  78466. * Gets a translation vector
  78467. * @returns the translation vector
  78468. */
  78469. translate(): BABYLON.Vector2;
  78470. private _translatePoint;
  78471. /** Release associated resources */
  78472. dispose(): void;
  78473. }
  78474. }
  78475. declare module BABYLON.GUI {
  78476. /**
  78477. * Class used to create multi line control
  78478. */
  78479. export class MultiLine extends Control {
  78480. name?: string | undefined;
  78481. private _lineWidth;
  78482. private _dash;
  78483. private _points;
  78484. private _minX;
  78485. private _minY;
  78486. private _maxX;
  78487. private _maxY;
  78488. /**
  78489. * Creates a new MultiLine
  78490. * @param name defines the control name
  78491. */
  78492. constructor(name?: string | undefined);
  78493. /** Gets or sets dash pattern */
  78494. get dash(): Array<number>;
  78495. set dash(value: Array<number>);
  78496. /**
  78497. * Gets point stored at specified index
  78498. * @param index defines the index to look for
  78499. * @returns the requested point if found
  78500. */
  78501. getAt(index: number): MultiLinePoint;
  78502. /** Function called when a point is updated */
  78503. onPointUpdate: () => void;
  78504. /**
  78505. * Adds new points to the point collection
  78506. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  78507. * @returns the list of created MultiLinePoint
  78508. */
  78509. add(...items: (AbstractMesh | Control | {
  78510. x: string | number;
  78511. y: string | number;
  78512. })[]): MultiLinePoint[];
  78513. /**
  78514. * Adds a new point to the point collection
  78515. * @param item defines the item (mesh, control or 2d coordiantes) to add
  78516. * @returns the created MultiLinePoint
  78517. */
  78518. push(item?: (AbstractMesh | Control | {
  78519. x: string | number;
  78520. y: string | number;
  78521. })): MultiLinePoint;
  78522. /**
  78523. * Remove a specific value or point from the active point collection
  78524. * @param value defines the value or point to remove
  78525. */
  78526. remove(value: number | MultiLinePoint): void;
  78527. /**
  78528. * Resets this object to initial state (no point)
  78529. */
  78530. reset(): void;
  78531. /**
  78532. * Resets all links
  78533. */
  78534. resetLinks(): void;
  78535. /** Gets or sets line width */
  78536. get lineWidth(): number;
  78537. set lineWidth(value: number);
  78538. set horizontalAlignment(value: number);
  78539. set verticalAlignment(value: number);
  78540. protected _getTypeName(): string;
  78541. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78542. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78543. _measure(): void;
  78544. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78545. dispose(): void;
  78546. }
  78547. }
  78548. declare module BABYLON.GUI {
  78549. /**
  78550. * Class used to create radio button controls
  78551. */
  78552. export class RadioButton extends Control {
  78553. name?: string | undefined;
  78554. private _isChecked;
  78555. private _background;
  78556. private _checkSizeRatio;
  78557. private _thickness;
  78558. /** Gets or sets border thickness */
  78559. get thickness(): number;
  78560. set thickness(value: number);
  78561. /** Gets or sets group name */
  78562. group: string;
  78563. /** BABYLON.Observable raised when isChecked is changed */
  78564. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78565. /** Gets or sets a value indicating the ratio between overall size and check size */
  78566. get checkSizeRatio(): number;
  78567. set checkSizeRatio(value: number);
  78568. /** Gets or sets background color */
  78569. get background(): string;
  78570. set background(value: string);
  78571. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78572. get isChecked(): boolean;
  78573. set isChecked(value: boolean);
  78574. /**
  78575. * Creates a new RadioButton
  78576. * @param name defines the control name
  78577. */
  78578. constructor(name?: string | undefined);
  78579. protected _getTypeName(): string;
  78580. _draw(context: CanvasRenderingContext2D): void;
  78581. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78582. /**
  78583. * Utility function to easily create a radio button with a header
  78584. * @param title defines the label to use for the header
  78585. * @param group defines the group to use for the radio button
  78586. * @param isChecked defines the initial state of the radio button
  78587. * @param onValueChanged defines the callback to call when value changes
  78588. * @returns a StackPanel containing the radio button and a textBlock
  78589. */
  78590. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  78591. }
  78592. }
  78593. declare module BABYLON.GUI {
  78594. /**
  78595. * Class used to create slider controls
  78596. */
  78597. export class BaseSlider extends Control {
  78598. name?: string | undefined;
  78599. protected _thumbWidth: ValueAndUnit;
  78600. private _minimum;
  78601. private _maximum;
  78602. private _value;
  78603. private _isVertical;
  78604. protected _barOffset: ValueAndUnit;
  78605. private _isThumbClamped;
  78606. protected _displayThumb: boolean;
  78607. private _step;
  78608. private _lastPointerDownID;
  78609. protected _effectiveBarOffset: number;
  78610. protected _renderLeft: number;
  78611. protected _renderTop: number;
  78612. protected _renderWidth: number;
  78613. protected _renderHeight: number;
  78614. protected _backgroundBoxLength: number;
  78615. protected _backgroundBoxThickness: number;
  78616. protected _effectiveThumbThickness: number;
  78617. /** BABYLON.Observable raised when the sldier value changes */
  78618. onValueChangedObservable: BABYLON.Observable<number>;
  78619. /** Gets or sets a boolean indicating if the thumb must be rendered */
  78620. get displayThumb(): boolean;
  78621. set displayThumb(value: boolean);
  78622. /** Gets or sets a step to apply to values (0 by default) */
  78623. get step(): number;
  78624. set step(value: number);
  78625. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  78626. get barOffset(): string | number;
  78627. /** Gets main bar offset in pixels*/
  78628. get barOffsetInPixels(): number;
  78629. set barOffset(value: string | number);
  78630. /** Gets or sets thumb width */
  78631. get thumbWidth(): string | number;
  78632. /** Gets thumb width in pixels */
  78633. get thumbWidthInPixels(): number;
  78634. set thumbWidth(value: string | number);
  78635. /** Gets or sets minimum value */
  78636. get minimum(): number;
  78637. set minimum(value: number);
  78638. /** Gets or sets maximum value */
  78639. get maximum(): number;
  78640. set maximum(value: number);
  78641. /** Gets or sets current value */
  78642. get value(): number;
  78643. set value(value: number);
  78644. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  78645. get isVertical(): boolean;
  78646. set isVertical(value: boolean);
  78647. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  78648. get isThumbClamped(): boolean;
  78649. set isThumbClamped(value: boolean);
  78650. /**
  78651. * Creates a new BaseSlider
  78652. * @param name defines the control name
  78653. */
  78654. constructor(name?: string | undefined);
  78655. protected _getTypeName(): string;
  78656. protected _getThumbPosition(): number;
  78657. protected _getThumbThickness(type: string): number;
  78658. protected _prepareRenderingData(type: string): void;
  78659. private _pointerIsDown;
  78660. /** @hidden */
  78661. protected _updateValueFromPointer(x: number, y: number): void;
  78662. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78663. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78664. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78665. _onCanvasBlur(): void;
  78666. }
  78667. }
  78668. declare module BABYLON.GUI {
  78669. /**
  78670. * Class used to create slider controls
  78671. */
  78672. export class Slider extends BaseSlider {
  78673. name?: string | undefined;
  78674. private _background;
  78675. private _borderColor;
  78676. private _isThumbCircle;
  78677. protected _displayValueBar: boolean;
  78678. /** Gets or sets a boolean indicating if the value bar must be rendered */
  78679. get displayValueBar(): boolean;
  78680. set displayValueBar(value: boolean);
  78681. /** Gets or sets border color */
  78682. get borderColor(): string;
  78683. set borderColor(value: string);
  78684. /** Gets or sets background color */
  78685. get background(): string;
  78686. set background(value: string);
  78687. /** Gets or sets a boolean indicating if the thumb should be round or square */
  78688. get isThumbCircle(): boolean;
  78689. set isThumbCircle(value: boolean);
  78690. /**
  78691. * Creates a new Slider
  78692. * @param name defines the control name
  78693. */
  78694. constructor(name?: string | undefined);
  78695. protected _getTypeName(): string;
  78696. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78697. }
  78698. }
  78699. declare module BABYLON.GUI {
  78700. /** Class used to create a RadioGroup
  78701. * which contains groups of radio buttons
  78702. */
  78703. export class SelectorGroup {
  78704. /** name of SelectorGroup */
  78705. name: string;
  78706. private _groupPanel;
  78707. private _selectors;
  78708. private _groupHeader;
  78709. /**
  78710. * Creates a new SelectorGroup
  78711. * @param name of group, used as a group heading
  78712. */
  78713. constructor(
  78714. /** name of SelectorGroup */
  78715. name: string);
  78716. /** Gets the groupPanel of the SelectorGroup */
  78717. get groupPanel(): StackPanel;
  78718. /** Gets the selectors array */
  78719. get selectors(): StackPanel[];
  78720. /** Gets and sets the group header */
  78721. get header(): string;
  78722. set header(label: string);
  78723. /** @hidden */
  78724. private _addGroupHeader;
  78725. /** @hidden*/
  78726. _getSelector(selectorNb: number): StackPanel | undefined;
  78727. /** Removes the selector at the given position
  78728. * @param selectorNb the position of the selector within the group
  78729. */
  78730. removeSelector(selectorNb: number): void;
  78731. }
  78732. /** Class used to create a CheckboxGroup
  78733. * which contains groups of checkbox buttons
  78734. */
  78735. export class CheckboxGroup extends SelectorGroup {
  78736. /** Adds a checkbox as a control
  78737. * @param text is the label for the selector
  78738. * @param func is the function called when the Selector is checked
  78739. * @param checked is true when Selector is checked
  78740. */
  78741. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  78742. /** @hidden */
  78743. _setSelectorLabel(selectorNb: number, label: string): void;
  78744. /** @hidden */
  78745. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78746. /** @hidden */
  78747. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78748. /** @hidden */
  78749. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78750. }
  78751. /** Class used to create a RadioGroup
  78752. * which contains groups of radio buttons
  78753. */
  78754. export class RadioGroup extends SelectorGroup {
  78755. private _selectNb;
  78756. /** Adds a radio button as a control
  78757. * @param label is the label for the selector
  78758. * @param func is the function called when the Selector is checked
  78759. * @param checked is true when Selector is checked
  78760. */
  78761. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  78762. /** @hidden */
  78763. _setSelectorLabel(selectorNb: number, label: string): void;
  78764. /** @hidden */
  78765. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78766. /** @hidden */
  78767. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78768. /** @hidden */
  78769. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78770. }
  78771. /** Class used to create a SliderGroup
  78772. * which contains groups of slider buttons
  78773. */
  78774. export class SliderGroup extends SelectorGroup {
  78775. /**
  78776. * Adds a slider to the SelectorGroup
  78777. * @param label is the label for the SliderBar
  78778. * @param func is the function called when the Slider moves
  78779. * @param unit is a string describing the units used, eg degrees or metres
  78780. * @param min is the minimum value for the Slider
  78781. * @param max is the maximum value for the Slider
  78782. * @param value is the start value for the Slider between min and max
  78783. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  78784. */
  78785. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  78786. /** @hidden */
  78787. _setSelectorLabel(selectorNb: number, label: string): void;
  78788. /** @hidden */
  78789. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78790. /** @hidden */
  78791. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78792. /** @hidden */
  78793. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78794. }
  78795. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  78796. * @see https://doc.babylonjs.com/how_to/selector
  78797. */
  78798. export class SelectionPanel extends Rectangle {
  78799. /** name of SelectionPanel */
  78800. name: string;
  78801. /** an array of SelectionGroups */
  78802. groups: SelectorGroup[];
  78803. private _panel;
  78804. private _buttonColor;
  78805. private _buttonBackground;
  78806. private _headerColor;
  78807. private _barColor;
  78808. private _barHeight;
  78809. private _spacerHeight;
  78810. private _labelColor;
  78811. private _groups;
  78812. private _bars;
  78813. /**
  78814. * Creates a new SelectionPanel
  78815. * @param name of SelectionPanel
  78816. * @param groups is an array of SelectionGroups
  78817. */
  78818. constructor(
  78819. /** name of SelectionPanel */
  78820. name: string,
  78821. /** an array of SelectionGroups */
  78822. groups?: SelectorGroup[]);
  78823. protected _getTypeName(): string;
  78824. /** Gets or sets the headerColor */
  78825. get headerColor(): string;
  78826. set headerColor(color: string);
  78827. private _setHeaderColor;
  78828. /** Gets or sets the button color */
  78829. get buttonColor(): string;
  78830. set buttonColor(color: string);
  78831. private _setbuttonColor;
  78832. /** Gets or sets the label color */
  78833. get labelColor(): string;
  78834. set labelColor(color: string);
  78835. private _setLabelColor;
  78836. /** Gets or sets the button background */
  78837. get buttonBackground(): string;
  78838. set buttonBackground(color: string);
  78839. private _setButtonBackground;
  78840. /** Gets or sets the color of separator bar */
  78841. get barColor(): string;
  78842. set barColor(color: string);
  78843. private _setBarColor;
  78844. /** Gets or sets the height of separator bar */
  78845. get barHeight(): string;
  78846. set barHeight(value: string);
  78847. private _setBarHeight;
  78848. /** Gets or sets the height of spacers*/
  78849. get spacerHeight(): string;
  78850. set spacerHeight(value: string);
  78851. private _setSpacerHeight;
  78852. /** Adds a bar between groups */
  78853. private _addSpacer;
  78854. /** Add a group to the selection panel
  78855. * @param group is the selector group to add
  78856. */
  78857. addGroup(group: SelectorGroup): void;
  78858. /** Remove the group from the given position
  78859. * @param groupNb is the position of the group in the list
  78860. */
  78861. removeGroup(groupNb: number): void;
  78862. /** Change a group header label
  78863. * @param label is the new group header label
  78864. * @param groupNb is the number of the group to relabel
  78865. * */
  78866. setHeaderName(label: string, groupNb: number): void;
  78867. /** Change selector label to the one given
  78868. * @param label is the new selector label
  78869. * @param groupNb is the number of the groupcontaining the selector
  78870. * @param selectorNb is the number of the selector within a group to relabel
  78871. * */
  78872. relabel(label: string, groupNb: number, selectorNb: number): void;
  78873. /** For a given group position remove the selector at the given position
  78874. * @param groupNb is the number of the group to remove the selector from
  78875. * @param selectorNb is the number of the selector within the group
  78876. */
  78877. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  78878. /** For a given group position of correct type add a checkbox button
  78879. * @param groupNb is the number of the group to remove the selector from
  78880. * @param label is the label for the selector
  78881. * @param func is the function called when the Selector is checked
  78882. * @param checked is true when Selector is checked
  78883. */
  78884. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78885. /** For a given group position of correct type add a radio button
  78886. * @param groupNb is the number of the group to remove the selector from
  78887. * @param label is the label for the selector
  78888. * @param func is the function called when the Selector is checked
  78889. * @param checked is true when Selector is checked
  78890. */
  78891. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78892. /**
  78893. * For a given slider group add a slider
  78894. * @param groupNb is the number of the group to add the slider to
  78895. * @param label is the label for the Slider
  78896. * @param func is the function called when the Slider moves
  78897. * @param unit is a string describing the units used, eg degrees or metres
  78898. * @param min is the minimum value for the Slider
  78899. * @param max is the maximum value for the Slider
  78900. * @param value is the start value for the Slider between min and max
  78901. * @param onVal is the function used to format the value displayed, eg radians to degrees
  78902. */
  78903. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  78904. }
  78905. }
  78906. declare module BABYLON.GUI {
  78907. /**
  78908. * Class used to hold a the container for ScrollViewer
  78909. * @hidden
  78910. */
  78911. export class _ScrollViewerWindow extends Container {
  78912. parentClientWidth: number;
  78913. parentClientHeight: number;
  78914. private _freezeControls;
  78915. private _parentMeasure;
  78916. private _oldLeft;
  78917. private _oldTop;
  78918. get freezeControls(): boolean;
  78919. set freezeControls(value: boolean);
  78920. private _bucketWidth;
  78921. private _bucketHeight;
  78922. private _buckets;
  78923. private _bucketLen;
  78924. get bucketWidth(): number;
  78925. get bucketHeight(): number;
  78926. setBucketSizes(width: number, height: number): void;
  78927. private _useBuckets;
  78928. private _makeBuckets;
  78929. private _dispatchInBuckets;
  78930. private _updateMeasures;
  78931. private _updateChildrenMeasures;
  78932. private _restoreMeasures;
  78933. /**
  78934. * Creates a new ScrollViewerWindow
  78935. * @param name of ScrollViewerWindow
  78936. */
  78937. constructor(name?: string);
  78938. protected _getTypeName(): string;
  78939. /** @hidden */
  78940. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78941. /** @hidden */
  78942. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78943. private _scrollChildren;
  78944. private _scrollChildrenWithBuckets;
  78945. /** @hidden */
  78946. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78947. protected _postMeasure(): void;
  78948. }
  78949. }
  78950. declare module BABYLON.GUI {
  78951. /**
  78952. * Class used to create slider controls
  78953. */
  78954. export class ScrollBar extends BaseSlider {
  78955. name?: string | undefined;
  78956. private _background;
  78957. private _borderColor;
  78958. private _tempMeasure;
  78959. /** Gets or sets border color */
  78960. get borderColor(): string;
  78961. set borderColor(value: string);
  78962. /** Gets or sets background color */
  78963. get background(): string;
  78964. set background(value: string);
  78965. /**
  78966. * Creates a new Slider
  78967. * @param name defines the control name
  78968. */
  78969. constructor(name?: string | undefined);
  78970. protected _getTypeName(): string;
  78971. protected _getThumbThickness(): number;
  78972. _draw(context: CanvasRenderingContext2D): void;
  78973. private _first;
  78974. private _originX;
  78975. private _originY;
  78976. /** @hidden */
  78977. protected _updateValueFromPointer(x: number, y: number): void;
  78978. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78979. }
  78980. }
  78981. declare module BABYLON.GUI {
  78982. /**
  78983. * Class used to create slider controls
  78984. */
  78985. export class ImageScrollBar extends BaseSlider {
  78986. name?: string | undefined;
  78987. private _backgroundBaseImage;
  78988. private _backgroundImage;
  78989. private _thumbImage;
  78990. private _thumbBaseImage;
  78991. private _thumbLength;
  78992. private _thumbHeight;
  78993. private _barImageHeight;
  78994. private _tempMeasure;
  78995. /** Number of 90° rotation to apply on the images when in vertical mode */
  78996. num90RotationInVerticalMode: number;
  78997. /**
  78998. * Gets or sets the image used to render the background for horizontal bar
  78999. */
  79000. get backgroundImage(): Image;
  79001. set backgroundImage(value: Image);
  79002. /**
  79003. * Gets or sets the image used to render the thumb
  79004. */
  79005. get thumbImage(): Image;
  79006. set thumbImage(value: Image);
  79007. /**
  79008. * Gets or sets the length of the thumb
  79009. */
  79010. get thumbLength(): number;
  79011. set thumbLength(value: number);
  79012. /**
  79013. * Gets or sets the height of the thumb
  79014. */
  79015. get thumbHeight(): number;
  79016. set thumbHeight(value: number);
  79017. /**
  79018. * Gets or sets the height of the bar image
  79019. */
  79020. get barImageHeight(): number;
  79021. set barImageHeight(value: number);
  79022. /**
  79023. * Creates a new ImageScrollBar
  79024. * @param name defines the control name
  79025. */
  79026. constructor(name?: string | undefined);
  79027. protected _getTypeName(): string;
  79028. protected _getThumbThickness(): number;
  79029. _draw(context: CanvasRenderingContext2D): void;
  79030. private _first;
  79031. private _originX;
  79032. private _originY;
  79033. /** @hidden */
  79034. protected _updateValueFromPointer(x: number, y: number): void;
  79035. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79036. }
  79037. }
  79038. declare module BABYLON.GUI {
  79039. /**
  79040. * Class used to hold a viewer window and sliders in a grid
  79041. */
  79042. export class ScrollViewer extends Rectangle {
  79043. private _grid;
  79044. private _horizontalBarSpace;
  79045. private _verticalBarSpace;
  79046. private _dragSpace;
  79047. private _horizontalBar;
  79048. private _verticalBar;
  79049. private _barColor;
  79050. private _barBackground;
  79051. private _barImage;
  79052. private _horizontalBarImage;
  79053. private _verticalBarImage;
  79054. private _barBackgroundImage;
  79055. private _horizontalBarBackgroundImage;
  79056. private _verticalBarBackgroundImage;
  79057. private _barSize;
  79058. private _window;
  79059. private _pointerIsOver;
  79060. private _wheelPrecision;
  79061. private _onWheelObserver;
  79062. private _clientWidth;
  79063. private _clientHeight;
  79064. private _useImageBar;
  79065. private _thumbLength;
  79066. private _thumbHeight;
  79067. private _barImageHeight;
  79068. private _horizontalBarImageHeight;
  79069. private _verticalBarImageHeight;
  79070. private _oldWindowContentsWidth;
  79071. private _oldWindowContentsHeight;
  79072. /**
  79073. * Gets the horizontal scrollbar
  79074. */
  79075. get horizontalBar(): ScrollBar | ImageScrollBar;
  79076. /**
  79077. * Gets the vertical scrollbar
  79078. */
  79079. get verticalBar(): ScrollBar | ImageScrollBar;
  79080. /**
  79081. * Adds a new control to the current container
  79082. * @param control defines the control to add
  79083. * @returns the current container
  79084. */
  79085. addControl(control: BABYLON.Nullable<Control>): Container;
  79086. /**
  79087. * Removes a control from the current container
  79088. * @param control defines the control to remove
  79089. * @returns the current container
  79090. */
  79091. removeControl(control: Control): Container;
  79092. /** Gets the list of children */
  79093. get children(): Control[];
  79094. _flagDescendantsAsMatrixDirty(): void;
  79095. /**
  79096. * Freezes or unfreezes the controls in the window.
  79097. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79098. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79099. */
  79100. get freezeControls(): boolean;
  79101. set freezeControls(value: boolean);
  79102. /** Gets the bucket width */
  79103. get bucketWidth(): number;
  79104. /** Gets the bucket height */
  79105. get bucketHeight(): number;
  79106. /**
  79107. * Sets the bucket sizes.
  79108. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79109. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79110. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79111. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79112. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79113. * used), that's why it is not enabled by default.
  79114. * @param width width of the bucket
  79115. * @param height height of the bucket
  79116. */
  79117. setBucketSizes(width: number, height: number): void;
  79118. private _forceHorizontalBar;
  79119. private _forceVerticalBar;
  79120. /**
  79121. * Forces the horizontal scroll bar to be displayed
  79122. */
  79123. get forceHorizontalBar(): boolean;
  79124. set forceHorizontalBar(value: boolean);
  79125. /**
  79126. * Forces the vertical scroll bar to be displayed
  79127. */
  79128. get forceVerticalBar(): boolean;
  79129. set forceVerticalBar(value: boolean);
  79130. /**
  79131. * Creates a new ScrollViewer
  79132. * @param name of ScrollViewer
  79133. */
  79134. constructor(name?: string, isImageBased?: boolean);
  79135. /** Reset the scroll viewer window to initial size */
  79136. resetWindow(): void;
  79137. protected _getTypeName(): string;
  79138. private _buildClientSizes;
  79139. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79140. protected _postMeasure(): void;
  79141. /**
  79142. * Gets or sets the mouse wheel precision
  79143. * from 0 to 1 with a default value of 0.05
  79144. * */
  79145. get wheelPrecision(): number;
  79146. set wheelPrecision(value: number);
  79147. /** Gets or sets the scroll bar container background color */
  79148. get scrollBackground(): string;
  79149. set scrollBackground(color: string);
  79150. /** Gets or sets the bar color */
  79151. get barColor(): string;
  79152. set barColor(color: string);
  79153. /** Gets or sets the bar image */
  79154. get thumbImage(): Image;
  79155. set thumbImage(value: Image);
  79156. /** Gets or sets the horizontal bar image */
  79157. get horizontalThumbImage(): Image;
  79158. set horizontalThumbImage(value: Image);
  79159. /** Gets or sets the vertical bar image */
  79160. get verticalThumbImage(): Image;
  79161. set verticalThumbImage(value: Image);
  79162. /** Gets or sets the size of the bar */
  79163. get barSize(): number;
  79164. set barSize(value: number);
  79165. /** Gets or sets the length of the thumb */
  79166. get thumbLength(): number;
  79167. set thumbLength(value: number);
  79168. /** Gets or sets the height of the thumb */
  79169. get thumbHeight(): number;
  79170. set thumbHeight(value: number);
  79171. /** Gets or sets the height of the bar image */
  79172. get barImageHeight(): number;
  79173. set barImageHeight(value: number);
  79174. /** Gets or sets the height of the horizontal bar image */
  79175. get horizontalBarImageHeight(): number;
  79176. set horizontalBarImageHeight(value: number);
  79177. /** Gets or sets the height of the vertical bar image */
  79178. get verticalBarImageHeight(): number;
  79179. set verticalBarImageHeight(value: number);
  79180. /** Gets or sets the bar background */
  79181. get barBackground(): string;
  79182. set barBackground(color: string);
  79183. /** Gets or sets the bar background image */
  79184. get barImage(): Image;
  79185. set barImage(value: Image);
  79186. /** Gets or sets the horizontal bar background image */
  79187. get horizontalBarImage(): Image;
  79188. set horizontalBarImage(value: Image);
  79189. /** Gets or sets the vertical bar background image */
  79190. get verticalBarImage(): Image;
  79191. set verticalBarImage(value: Image);
  79192. private _setWindowPosition;
  79193. /** @hidden */
  79194. private _updateScroller;
  79195. _link(host: AdvancedDynamicTexture): void;
  79196. /** @hidden */
  79197. private _addBar;
  79198. /** @hidden */
  79199. private _attachWheel;
  79200. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79201. /** Releases associated resources */
  79202. dispose(): void;
  79203. }
  79204. }
  79205. declare module BABYLON.GUI {
  79206. /** Class used to render a grid */
  79207. export class DisplayGrid extends Control {
  79208. name?: string | undefined;
  79209. private _cellWidth;
  79210. private _cellHeight;
  79211. private _minorLineTickness;
  79212. private _minorLineColor;
  79213. private _majorLineTickness;
  79214. private _majorLineColor;
  79215. private _majorLineFrequency;
  79216. private _background;
  79217. private _displayMajorLines;
  79218. private _displayMinorLines;
  79219. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  79220. get displayMinorLines(): boolean;
  79221. set displayMinorLines(value: boolean);
  79222. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  79223. get displayMajorLines(): boolean;
  79224. set displayMajorLines(value: boolean);
  79225. /** Gets or sets background color (Black by default) */
  79226. get background(): string;
  79227. set background(value: string);
  79228. /** Gets or sets the width of each cell (20 by default) */
  79229. get cellWidth(): number;
  79230. set cellWidth(value: number);
  79231. /** Gets or sets the height of each cell (20 by default) */
  79232. get cellHeight(): number;
  79233. set cellHeight(value: number);
  79234. /** Gets or sets the tickness of minor lines (1 by default) */
  79235. get minorLineTickness(): number;
  79236. set minorLineTickness(value: number);
  79237. /** Gets or sets the color of minor lines (DarkGray by default) */
  79238. get minorLineColor(): string;
  79239. set minorLineColor(value: string);
  79240. /** Gets or sets the tickness of major lines (2 by default) */
  79241. get majorLineTickness(): number;
  79242. set majorLineTickness(value: number);
  79243. /** Gets or sets the color of major lines (White by default) */
  79244. get majorLineColor(): string;
  79245. set majorLineColor(value: string);
  79246. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  79247. get majorLineFrequency(): number;
  79248. set majorLineFrequency(value: number);
  79249. /**
  79250. * Creates a new GridDisplayRectangle
  79251. * @param name defines the control name
  79252. */
  79253. constructor(name?: string | undefined);
  79254. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79255. protected _getTypeName(): string;
  79256. }
  79257. }
  79258. declare module BABYLON.GUI {
  79259. /**
  79260. * Class used to create slider controls based on images
  79261. */
  79262. export class ImageBasedSlider extends BaseSlider {
  79263. name?: string | undefined;
  79264. private _backgroundImage;
  79265. private _thumbImage;
  79266. private _valueBarImage;
  79267. private _tempMeasure;
  79268. get displayThumb(): boolean;
  79269. set displayThumb(value: boolean);
  79270. /**
  79271. * Gets or sets the image used to render the background
  79272. */
  79273. get backgroundImage(): Image;
  79274. set backgroundImage(value: Image);
  79275. /**
  79276. * Gets or sets the image used to render the value bar
  79277. */
  79278. get valueBarImage(): Image;
  79279. set valueBarImage(value: Image);
  79280. /**
  79281. * Gets or sets the image used to render the thumb
  79282. */
  79283. get thumbImage(): Image;
  79284. set thumbImage(value: Image);
  79285. /**
  79286. * Creates a new ImageBasedSlider
  79287. * @param name defines the control name
  79288. */
  79289. constructor(name?: string | undefined);
  79290. protected _getTypeName(): string;
  79291. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79292. }
  79293. }
  79294. declare module BABYLON.GUI {
  79295. /**
  79296. * Forcing an export so that this code will execute
  79297. * @hidden
  79298. */
  79299. const name = "Statics";
  79300. }
  79301. declare module BABYLON.GUI {
  79302. /**
  79303. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  79304. */
  79305. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  79306. /**
  79307. * Define the instrumented AdvancedDynamicTexture.
  79308. */
  79309. texture: AdvancedDynamicTexture;
  79310. private _captureRenderTime;
  79311. private _renderTime;
  79312. private _captureLayoutTime;
  79313. private _layoutTime;
  79314. private _onBeginRenderObserver;
  79315. private _onEndRenderObserver;
  79316. private _onBeginLayoutObserver;
  79317. private _onEndLayoutObserver;
  79318. /**
  79319. * Gets the perf counter used to capture render time
  79320. */
  79321. get renderTimeCounter(): BABYLON.PerfCounter;
  79322. /**
  79323. * Gets the perf counter used to capture layout time
  79324. */
  79325. get layoutTimeCounter(): BABYLON.PerfCounter;
  79326. /**
  79327. * Enable or disable the render time capture
  79328. */
  79329. get captureRenderTime(): boolean;
  79330. set captureRenderTime(value: boolean);
  79331. /**
  79332. * Enable or disable the layout time capture
  79333. */
  79334. get captureLayoutTime(): boolean;
  79335. set captureLayoutTime(value: boolean);
  79336. /**
  79337. * Instantiates a new advanced dynamic texture instrumentation.
  79338. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  79339. * @param texture Defines the AdvancedDynamicTexture to instrument
  79340. */
  79341. constructor(
  79342. /**
  79343. * Define the instrumented AdvancedDynamicTexture.
  79344. */
  79345. texture: AdvancedDynamicTexture);
  79346. /**
  79347. * Dispose and release associated resources.
  79348. */
  79349. dispose(): void;
  79350. }
  79351. }
  79352. declare module BABYLON.GUI {
  79353. /**
  79354. * Class used to load GUI via XML.
  79355. */
  79356. export class XmlLoader {
  79357. private _nodes;
  79358. private _nodeTypes;
  79359. private _isLoaded;
  79360. private _objectAttributes;
  79361. private _parentClass;
  79362. /**
  79363. * Create a new xml loader
  79364. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  79365. */
  79366. constructor(parentClass?: null);
  79367. private _getChainElement;
  79368. private _getClassAttribute;
  79369. private _createGuiElement;
  79370. private _parseGrid;
  79371. private _parseElement;
  79372. private _prepareSourceElement;
  79373. private _parseElementsFromSource;
  79374. private _parseXml;
  79375. /**
  79376. * Gets if the loading has finished.
  79377. * @returns whether the loading has finished or not
  79378. */
  79379. isLoaded(): boolean;
  79380. /**
  79381. * Gets a loaded node / control by id.
  79382. * @param id the Controls id set in the xml
  79383. * @returns element of type Control
  79384. */
  79385. getNodeById(id: string): any;
  79386. /**
  79387. * Gets all loaded nodes / controls
  79388. * @returns Array of controls
  79389. */
  79390. getNodes(): any;
  79391. /**
  79392. * Initiates the xml layout loading
  79393. * @param xmlFile defines the xml layout to load
  79394. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  79395. * @param callback defines the callback called on layout load.
  79396. */
  79397. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  79398. }
  79399. }
  79400. declare module BABYLON.GUI {
  79401. /**
  79402. * Class used to create containers for controls
  79403. */
  79404. export class Container3D extends Control3D {
  79405. private _blockLayout;
  79406. /**
  79407. * Gets the list of child controls
  79408. */
  79409. protected _children: Control3D[];
  79410. /**
  79411. * Gets the list of child controls
  79412. */
  79413. get children(): Array<Control3D>;
  79414. /**
  79415. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  79416. * This is helpful to optimize layout operation when adding multiple children in a row
  79417. */
  79418. get blockLayout(): boolean;
  79419. set blockLayout(value: boolean);
  79420. /**
  79421. * Creates a new container
  79422. * @param name defines the container name
  79423. */
  79424. constructor(name?: string);
  79425. /**
  79426. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  79427. * @returns the current container
  79428. */
  79429. updateLayout(): Container3D;
  79430. /**
  79431. * Gets a boolean indicating if the given control is in the children of this control
  79432. * @param control defines the control to check
  79433. * @returns true if the control is in the child list
  79434. */
  79435. containsControl(control: Control3D): boolean;
  79436. /**
  79437. * Adds a control to the children of this control
  79438. * @param control defines the control to add
  79439. * @returns the current container
  79440. */
  79441. addControl(control: Control3D): Container3D;
  79442. /**
  79443. * This function will be called everytime a new control is added
  79444. */
  79445. protected _arrangeChildren(): void;
  79446. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79447. /**
  79448. * Removes a control from the children of this control
  79449. * @param control defines the control to remove
  79450. * @returns the current container
  79451. */
  79452. removeControl(control: Control3D): Container3D;
  79453. protected _getTypeName(): string;
  79454. /**
  79455. * Releases all associated resources
  79456. */
  79457. dispose(): void;
  79458. /** Control rotation will remain unchanged */
  79459. static readonly UNSET_ORIENTATION: number;
  79460. /** Control will rotate to make it look at sphere central axis */
  79461. static readonly FACEORIGIN_ORIENTATION: number;
  79462. /** Control will rotate to make it look back at sphere central axis */
  79463. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  79464. /** Control will rotate to look at z axis (0, 0, 1) */
  79465. static readonly FACEFORWARD_ORIENTATION: number;
  79466. /** Control will rotate to look at negative z axis (0, 0, -1) */
  79467. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  79468. }
  79469. }
  79470. declare module BABYLON.GUI {
  79471. /**
  79472. * Class used to manage 3D user interface
  79473. * @see https://doc.babylonjs.com/how_to/gui3d
  79474. */
  79475. export class GUI3DManager implements BABYLON.IDisposable {
  79476. private _scene;
  79477. private _sceneDisposeObserver;
  79478. private _utilityLayer;
  79479. private _rootContainer;
  79480. private _pointerObserver;
  79481. private _pointerOutObserver;
  79482. /** @hidden */
  79483. _lastPickedControl: Control3D;
  79484. /** @hidden */
  79485. _lastControlOver: {
  79486. [pointerId: number]: Control3D;
  79487. };
  79488. /** @hidden */
  79489. _lastControlDown: {
  79490. [pointerId: number]: Control3D;
  79491. };
  79492. /**
  79493. * BABYLON.Observable raised when the point picked by the pointer events changed
  79494. */
  79495. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  79496. /** @hidden */
  79497. _sharedMaterials: {
  79498. [key: string]: BABYLON.Material;
  79499. };
  79500. /** Gets the hosting scene */
  79501. get scene(): BABYLON.Scene;
  79502. /** Gets associated utility layer */
  79503. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  79504. /**
  79505. * Creates a new GUI3DManager
  79506. * @param scene
  79507. */
  79508. constructor(scene?: BABYLON.Scene);
  79509. private _handlePointerOut;
  79510. private _doPicking;
  79511. /**
  79512. * Gets the root container
  79513. */
  79514. get rootContainer(): Container3D;
  79515. /**
  79516. * Gets a boolean indicating if the given control is in the root child list
  79517. * @param control defines the control to check
  79518. * @returns true if the control is in the root child list
  79519. */
  79520. containsControl(control: Control3D): boolean;
  79521. /**
  79522. * Adds a control to the root child list
  79523. * @param control defines the control to add
  79524. * @returns the current manager
  79525. */
  79526. addControl(control: Control3D): GUI3DManager;
  79527. /**
  79528. * Removes a control from the root child list
  79529. * @param control defines the control to remove
  79530. * @returns the current container
  79531. */
  79532. removeControl(control: Control3D): GUI3DManager;
  79533. /**
  79534. * Releases all associated resources
  79535. */
  79536. dispose(): void;
  79537. }
  79538. }
  79539. declare module BABYLON.GUI {
  79540. /**
  79541. * Class used to transport BABYLON.Vector3 information for pointer events
  79542. */
  79543. export class Vector3WithInfo extends BABYLON.Vector3 {
  79544. /** defines the current mouse button index */
  79545. buttonIndex: number;
  79546. /**
  79547. * Creates a new Vector3WithInfo
  79548. * @param source defines the vector3 data to transport
  79549. * @param buttonIndex defines the current mouse button index
  79550. */
  79551. constructor(source: BABYLON.Vector3,
  79552. /** defines the current mouse button index */
  79553. buttonIndex?: number);
  79554. }
  79555. }
  79556. declare module BABYLON.GUI {
  79557. /**
  79558. * Class used as base class for controls
  79559. */
  79560. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  79561. /** Defines the control name */
  79562. name?: string | undefined;
  79563. /** @hidden */
  79564. _host: GUI3DManager;
  79565. private _node;
  79566. private _downCount;
  79567. private _enterCount;
  79568. private _downPointerIds;
  79569. private _isVisible;
  79570. /** Gets or sets the control position in world space */
  79571. get position(): BABYLON.Vector3;
  79572. set position(value: BABYLON.Vector3);
  79573. /** Gets or sets the control scaling in world space */
  79574. get scaling(): BABYLON.Vector3;
  79575. set scaling(value: BABYLON.Vector3);
  79576. /** Callback used to start pointer enter animation */
  79577. pointerEnterAnimation: () => void;
  79578. /** Callback used to start pointer out animation */
  79579. pointerOutAnimation: () => void;
  79580. /** Callback used to start pointer down animation */
  79581. pointerDownAnimation: () => void;
  79582. /** Callback used to start pointer up animation */
  79583. pointerUpAnimation: () => void;
  79584. /**
  79585. * An event triggered when the pointer move over the control
  79586. */
  79587. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  79588. /**
  79589. * An event triggered when the pointer move out of the control
  79590. */
  79591. onPointerOutObservable: BABYLON.Observable<Control3D>;
  79592. /**
  79593. * An event triggered when the pointer taps the control
  79594. */
  79595. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  79596. /**
  79597. * An event triggered when pointer is up
  79598. */
  79599. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  79600. /**
  79601. * An event triggered when a control is clicked on (with a mouse)
  79602. */
  79603. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  79604. /**
  79605. * An event triggered when pointer enters the control
  79606. */
  79607. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  79608. /**
  79609. * Gets or sets the parent container
  79610. */
  79611. parent: BABYLON.Nullable<Container3D>;
  79612. private _behaviors;
  79613. /**
  79614. * Gets the list of attached behaviors
  79615. * @see https://doc.babylonjs.com/features/behaviour
  79616. */
  79617. get behaviors(): BABYLON.Behavior<Control3D>[];
  79618. /**
  79619. * Attach a behavior to the control
  79620. * @see https://doc.babylonjs.com/features/behaviour
  79621. * @param behavior defines the behavior to attach
  79622. * @returns the current control
  79623. */
  79624. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79625. /**
  79626. * Remove an attached behavior
  79627. * @see https://doc.babylonjs.com/features/behaviour
  79628. * @param behavior defines the behavior to attach
  79629. * @returns the current control
  79630. */
  79631. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79632. /**
  79633. * Gets an attached behavior by name
  79634. * @param name defines the name of the behavior to look for
  79635. * @see https://doc.babylonjs.com/features/behaviour
  79636. * @returns null if behavior was not found else the requested behavior
  79637. */
  79638. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  79639. /** Gets or sets a boolean indicating if the control is visible */
  79640. get isVisible(): boolean;
  79641. set isVisible(value: boolean);
  79642. /**
  79643. * Creates a new control
  79644. * @param name defines the control name
  79645. */
  79646. constructor(
  79647. /** Defines the control name */
  79648. name?: string | undefined);
  79649. /**
  79650. * Gets a string representing the class name
  79651. */
  79652. get typeName(): string;
  79653. /**
  79654. * Get the current class name of the control.
  79655. * @returns current class name
  79656. */
  79657. getClassName(): string;
  79658. protected _getTypeName(): string;
  79659. /**
  79660. * Gets the transform node used by this control
  79661. */
  79662. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  79663. /**
  79664. * Gets the mesh used to render this control
  79665. */
  79666. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79667. /**
  79668. * Link the control as child of the given node
  79669. * @param node defines the node to link to. Use null to unlink the control
  79670. * @returns the current control
  79671. */
  79672. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  79673. /** @hidden **/
  79674. _prepareNode(scene: BABYLON.Scene): void;
  79675. /**
  79676. * Node creation.
  79677. * Can be overriden by children
  79678. * @param scene defines the scene where the node must be attached
  79679. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  79680. */
  79681. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79682. /**
  79683. * Affect a material to the given mesh
  79684. * @param mesh defines the mesh which will represent the control
  79685. */
  79686. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79687. /** @hidden */
  79688. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  79689. /** @hidden */
  79690. _onPointerEnter(target: Control3D): boolean;
  79691. /** @hidden */
  79692. _onPointerOut(target: Control3D): void;
  79693. /** @hidden */
  79694. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79695. /** @hidden */
  79696. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79697. /** @hidden */
  79698. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79699. /** @hidden */
  79700. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79701. /** @hidden */
  79702. _disposeNode(): void;
  79703. /**
  79704. * Releases all associated resources
  79705. */
  79706. dispose(): void;
  79707. }
  79708. }
  79709. declare module BABYLON.GUI {
  79710. /**
  79711. * Class used as a root to all buttons
  79712. */
  79713. export class AbstractButton3D extends Control3D {
  79714. /**
  79715. * Creates a new button
  79716. * @param name defines the control name
  79717. */
  79718. constructor(name?: string);
  79719. protected _getTypeName(): string;
  79720. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79721. }
  79722. }
  79723. declare module BABYLON.GUI {
  79724. /**
  79725. * Class used to create a button in 3D
  79726. */
  79727. export class Button3D extends AbstractButton3D {
  79728. /** @hidden */
  79729. protected _currentMaterial: BABYLON.Material;
  79730. private _facadeTexture;
  79731. private _content;
  79732. private _contentResolution;
  79733. private _contentScaleRatio;
  79734. /**
  79735. * Gets or sets the texture resolution used to render content (512 by default)
  79736. */
  79737. get contentResolution(): BABYLON.int;
  79738. set contentResolution(value: BABYLON.int);
  79739. /**
  79740. * Gets or sets the texture scale ratio used to render content (2 by default)
  79741. */
  79742. get contentScaleRatio(): number;
  79743. set contentScaleRatio(value: number);
  79744. protected _disposeFacadeTexture(): void;
  79745. protected _resetContent(): void;
  79746. /**
  79747. * Creates a new button
  79748. * @param name defines the control name
  79749. */
  79750. constructor(name?: string);
  79751. /**
  79752. * Gets or sets the GUI 2D content used to display the button's facade
  79753. */
  79754. get content(): Control;
  79755. set content(value: Control);
  79756. /**
  79757. * Apply the facade texture (created from the content property).
  79758. * This function can be overloaded by child classes
  79759. * @param facadeTexture defines the AdvancedDynamicTexture to use
  79760. */
  79761. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79762. protected _getTypeName(): string;
  79763. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79764. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79765. /**
  79766. * Releases all associated resources
  79767. */
  79768. dispose(): void;
  79769. }
  79770. }
  79771. declare module BABYLON.GUI {
  79772. /**
  79773. * Abstract class used to create a container panel deployed on the surface of a volume
  79774. */
  79775. export abstract class VolumeBasedPanel extends Container3D {
  79776. private _columns;
  79777. private _rows;
  79778. private _rowThenColum;
  79779. private _orientation;
  79780. protected _cellWidth: number;
  79781. protected _cellHeight: number;
  79782. /**
  79783. * Gets or sets the distance between elements
  79784. */
  79785. margin: number;
  79786. /**
  79787. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  79788. * | Value | Type | Description |
  79789. * | ----- | ----------------------------------- | ----------- |
  79790. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  79791. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  79792. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  79793. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  79794. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  79795. */
  79796. get orientation(): number;
  79797. set orientation(value: number);
  79798. /**
  79799. * Gets or sets the number of columns requested (10 by default).
  79800. * The panel will automatically compute the number of rows based on number of child controls.
  79801. */
  79802. get columns(): BABYLON.int;
  79803. set columns(value: BABYLON.int);
  79804. /**
  79805. * Gets or sets a the number of rows requested.
  79806. * The panel will automatically compute the number of columns based on number of child controls.
  79807. */
  79808. get rows(): BABYLON.int;
  79809. set rows(value: BABYLON.int);
  79810. /**
  79811. * Creates new VolumeBasedPanel
  79812. */
  79813. constructor();
  79814. protected _arrangeChildren(): void;
  79815. /** Child classes must implement this function to provide correct control positioning */
  79816. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79817. /** Child classes can implement this function to provide additional processing */
  79818. protected _finalProcessing(): void;
  79819. }
  79820. }
  79821. declare module BABYLON.GUI {
  79822. /**
  79823. * Class used to create a container panel deployed on the surface of a cylinder
  79824. */
  79825. export class CylinderPanel extends VolumeBasedPanel {
  79826. private _radius;
  79827. /**
  79828. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  79829. */
  79830. get radius(): BABYLON.float;
  79831. set radius(value: BABYLON.float);
  79832. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79833. private _cylindricalMapping;
  79834. }
  79835. }
  79836. declare module BABYLON.GUI {
  79837. /** @hidden */
  79838. export var fluentVertexShader: {
  79839. name: string;
  79840. shader: string;
  79841. };
  79842. }
  79843. declare module BABYLON.GUI {
  79844. /** @hidden */
  79845. export var fluentPixelShader: {
  79846. name: string;
  79847. shader: string;
  79848. };
  79849. }
  79850. declare module BABYLON.GUI {
  79851. /** @hidden */
  79852. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  79853. INNERGLOW: boolean;
  79854. BORDER: boolean;
  79855. HOVERLIGHT: boolean;
  79856. TEXTURE: boolean;
  79857. constructor();
  79858. }
  79859. /**
  79860. * Class used to render controls with fluent desgin
  79861. */
  79862. export class FluentMaterial extends BABYLON.PushMaterial {
  79863. /**
  79864. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  79865. */
  79866. innerGlowColorIntensity: number;
  79867. /**
  79868. * Gets or sets the inner glow color (white by default)
  79869. */
  79870. innerGlowColor: BABYLON.Color3;
  79871. /**
  79872. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  79873. */
  79874. albedoColor: BABYLON.Color3;
  79875. /**
  79876. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  79877. */
  79878. renderBorders: boolean;
  79879. /**
  79880. * Gets or sets border width (default is 0.5)
  79881. */
  79882. borderWidth: number;
  79883. /**
  79884. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  79885. */
  79886. edgeSmoothingValue: number;
  79887. /**
  79888. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  79889. */
  79890. borderMinValue: number;
  79891. /**
  79892. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  79893. */
  79894. renderHoverLight: boolean;
  79895. /**
  79896. * Gets or sets the radius used to render the hover light (default is 1.0)
  79897. */
  79898. hoverRadius: number;
  79899. /**
  79900. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  79901. */
  79902. hoverColor: BABYLON.Color4;
  79903. /**
  79904. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  79905. */
  79906. hoverPosition: BABYLON.Vector3;
  79907. private _albedoTexture;
  79908. /** Gets or sets the texture to use for albedo color */
  79909. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79910. /**
  79911. * Creates a new Fluent material
  79912. * @param name defines the name of the material
  79913. * @param scene defines the hosting scene
  79914. */
  79915. constructor(name: string, scene: BABYLON.Scene);
  79916. needAlphaBlending(): boolean;
  79917. needAlphaTesting(): boolean;
  79918. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79919. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79920. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79921. getActiveTextures(): BABYLON.BaseTexture[];
  79922. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79923. dispose(forceDisposeEffect?: boolean): void;
  79924. clone(name: string): FluentMaterial;
  79925. serialize(): any;
  79926. getClassName(): string;
  79927. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  79928. }
  79929. }
  79930. declare module BABYLON.GUI {
  79931. /**
  79932. * Class used to create a holographic button in 3D
  79933. */
  79934. export class HolographicButton extends Button3D {
  79935. private _backPlate;
  79936. private _textPlate;
  79937. private _frontPlate;
  79938. private _text;
  79939. private _imageUrl;
  79940. private _shareMaterials;
  79941. private _frontMaterial;
  79942. private _backMaterial;
  79943. private _plateMaterial;
  79944. private _pickedPointObserver;
  79945. private _tooltipFade;
  79946. private _tooltipTextBlock;
  79947. private _tooltipTexture;
  79948. private _tooltipMesh;
  79949. private _tooltipHoverObserver;
  79950. private _tooltipOutObserver;
  79951. private _disposeTooltip;
  79952. /**
  79953. * Rendering ground id of all the mesh in the button
  79954. */
  79955. set renderingGroupId(id: number);
  79956. get renderingGroupId(): number;
  79957. /**
  79958. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  79959. */
  79960. set tooltipText(text: BABYLON.Nullable<string>);
  79961. get tooltipText(): BABYLON.Nullable<string>;
  79962. /**
  79963. * Gets or sets text for the button
  79964. */
  79965. get text(): string;
  79966. set text(value: string);
  79967. /**
  79968. * Gets or sets the image url for the button
  79969. */
  79970. get imageUrl(): string;
  79971. set imageUrl(value: string);
  79972. /**
  79973. * Gets the back material used by this button
  79974. */
  79975. get backMaterial(): FluentMaterial;
  79976. /**
  79977. * Gets the front material used by this button
  79978. */
  79979. get frontMaterial(): FluentMaterial;
  79980. /**
  79981. * Gets the plate material used by this button
  79982. */
  79983. get plateMaterial(): BABYLON.StandardMaterial;
  79984. /**
  79985. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  79986. */
  79987. get shareMaterials(): boolean;
  79988. /**
  79989. * Creates a new button
  79990. * @param name defines the control name
  79991. */
  79992. constructor(name?: string, shareMaterials?: boolean);
  79993. protected _getTypeName(): string;
  79994. private _rebuildContent;
  79995. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79996. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79997. private _createBackMaterial;
  79998. private _createFrontMaterial;
  79999. private _createPlateMaterial;
  80000. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80001. /**
  80002. * Releases all associated resources
  80003. */
  80004. dispose(): void;
  80005. }
  80006. }
  80007. declare module BABYLON.GUI {
  80008. /**
  80009. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80010. */
  80011. export class MeshButton3D extends Button3D {
  80012. /** @hidden */
  80013. protected _currentMesh: BABYLON.Mesh;
  80014. /**
  80015. * Creates a new 3D button based on a mesh
  80016. * @param mesh mesh to become a 3D button
  80017. * @param name defines the control name
  80018. */
  80019. constructor(mesh: BABYLON.Mesh, name?: string);
  80020. protected _getTypeName(): string;
  80021. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80022. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80023. }
  80024. }
  80025. declare module BABYLON.GUI {
  80026. /**
  80027. * Class used to create a container panel deployed on the surface of a plane
  80028. */
  80029. export class PlanePanel extends VolumeBasedPanel {
  80030. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80031. }
  80032. }
  80033. declare module BABYLON.GUI {
  80034. /**
  80035. * Class used to create a container panel where items get randomized planar mapping
  80036. */
  80037. export class ScatterPanel extends VolumeBasedPanel {
  80038. private _iteration;
  80039. /**
  80040. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80041. */
  80042. get iteration(): BABYLON.float;
  80043. set iteration(value: BABYLON.float);
  80044. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80045. private _scatterMapping;
  80046. protected _finalProcessing(): void;
  80047. }
  80048. }
  80049. declare module BABYLON.GUI {
  80050. /**
  80051. * Class used to create a container panel deployed on the surface of a sphere
  80052. */
  80053. export class SpherePanel extends VolumeBasedPanel {
  80054. private _radius;
  80055. /**
  80056. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80057. */
  80058. get radius(): BABYLON.float;
  80059. set radius(value: BABYLON.float);
  80060. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80061. private _sphericalMapping;
  80062. }
  80063. }
  80064. declare module BABYLON.GUI {
  80065. /**
  80066. * Class used to create a stack panel in 3D on XY plane
  80067. */
  80068. export class StackPanel3D extends Container3D {
  80069. private _isVertical;
  80070. /**
  80071. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80072. */
  80073. get isVertical(): boolean;
  80074. set isVertical(value: boolean);
  80075. /**
  80076. * Gets or sets the distance between elements
  80077. */
  80078. margin: number;
  80079. /**
  80080. * Creates new StackPanel
  80081. * @param isVertical
  80082. */
  80083. constructor(isVertical?: boolean);
  80084. protected _arrangeChildren(): void;
  80085. }
  80086. }
  80087. declare module BABYLON {
  80088. /**
  80089. * Configuration for glTF validation
  80090. */
  80091. export interface IGLTFValidationConfiguration {
  80092. /**
  80093. * The url of the glTF validator.
  80094. */
  80095. url: string;
  80096. }
  80097. /**
  80098. * glTF validation
  80099. */
  80100. export class GLTFValidation {
  80101. /**
  80102. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80103. */
  80104. static Configuration: IGLTFValidationConfiguration;
  80105. private static _LoadScriptPromise;
  80106. /**
  80107. * Validate a glTF asset using the glTF-Validator.
  80108. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80109. * @param rootUrl The root url for the glTF
  80110. * @param fileName The file name for the glTF
  80111. * @param getExternalResource The callback to get external resources for the glTF validator
  80112. * @returns A promise that resolves with the glTF validation results once complete
  80113. */
  80114. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80115. }
  80116. }
  80117. declare module BABYLON {
  80118. /**
  80119. * Mode that determines the coordinate system to use.
  80120. */
  80121. export enum GLTFLoaderCoordinateSystemMode {
  80122. /**
  80123. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80124. */
  80125. AUTO = 0,
  80126. /**
  80127. * Sets the useRightHandedSystem flag on the scene.
  80128. */
  80129. FORCE_RIGHT_HANDED = 1
  80130. }
  80131. /**
  80132. * Mode that determines what animations will start.
  80133. */
  80134. export enum GLTFLoaderAnimationStartMode {
  80135. /**
  80136. * No animation will start.
  80137. */
  80138. NONE = 0,
  80139. /**
  80140. * The first animation will start.
  80141. */
  80142. FIRST = 1,
  80143. /**
  80144. * All animations will start.
  80145. */
  80146. ALL = 2
  80147. }
  80148. /**
  80149. * Interface that contains the data for the glTF asset.
  80150. */
  80151. export interface IGLTFLoaderData {
  80152. /**
  80153. * The object that represents the glTF JSON.
  80154. */
  80155. json: Object;
  80156. /**
  80157. * The BIN chunk of a binary glTF.
  80158. */
  80159. bin: Nullable<IDataBuffer>;
  80160. }
  80161. /**
  80162. * Interface for extending the loader.
  80163. */
  80164. export interface IGLTFLoaderExtension {
  80165. /**
  80166. * The name of this extension.
  80167. */
  80168. readonly name: string;
  80169. /**
  80170. * Defines whether this extension is enabled.
  80171. */
  80172. enabled: boolean;
  80173. /**
  80174. * Defines the order of this extension.
  80175. * The loader sorts the extensions using these values when loading.
  80176. */
  80177. order?: number;
  80178. }
  80179. /**
  80180. * Loader state.
  80181. */
  80182. export enum GLTFLoaderState {
  80183. /**
  80184. * The asset is loading.
  80185. */
  80186. LOADING = 0,
  80187. /**
  80188. * The asset is ready for rendering.
  80189. */
  80190. READY = 1,
  80191. /**
  80192. * The asset is completely loaded.
  80193. */
  80194. COMPLETE = 2
  80195. }
  80196. /** @hidden */
  80197. export interface IImportMeshAsyncOutput {
  80198. meshes: AbstractMesh[];
  80199. particleSystems: IParticleSystem[];
  80200. skeletons: Skeleton[];
  80201. animationGroups: AnimationGroup[];
  80202. lights: Light[];
  80203. transformNodes: TransformNode[];
  80204. }
  80205. /** @hidden */
  80206. export interface IGLTFLoader extends IDisposable {
  80207. readonly state: Nullable<GLTFLoaderState>;
  80208. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  80209. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  80210. }
  80211. /**
  80212. * File loader for loading glTF files into a scene.
  80213. */
  80214. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80215. /** @hidden */
  80216. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80217. /** @hidden */
  80218. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80219. /**
  80220. * Raised when the asset has been parsed
  80221. */
  80222. onParsedObservable: Observable<IGLTFLoaderData>;
  80223. private _onParsedObserver;
  80224. /**
  80225. * Raised when the asset has been parsed
  80226. */
  80227. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  80228. /**
  80229. * 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.
  80230. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  80231. * Defaults to true.
  80232. * @hidden
  80233. */
  80234. static IncrementalLoading: boolean;
  80235. /**
  80236. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  80237. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  80238. * @hidden
  80239. */
  80240. static HomogeneousCoordinates: boolean;
  80241. /**
  80242. * The coordinate system mode. Defaults to AUTO.
  80243. */
  80244. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  80245. /**
  80246. * The animation start mode. Defaults to FIRST.
  80247. */
  80248. animationStartMode: GLTFLoaderAnimationStartMode;
  80249. /**
  80250. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  80251. */
  80252. compileMaterials: boolean;
  80253. /**
  80254. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  80255. */
  80256. useClipPlane: boolean;
  80257. /**
  80258. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  80259. */
  80260. compileShadowGenerators: boolean;
  80261. /**
  80262. * Defines if the Alpha blended materials are only applied as coverage.
  80263. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  80264. * If true, no extra effects are applied to transparent pixels.
  80265. */
  80266. transparencyAsCoverage: boolean;
  80267. /**
  80268. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  80269. * Enabling will disable offline support and glTF validator.
  80270. * Defaults to false.
  80271. */
  80272. useRangeRequests: boolean;
  80273. /**
  80274. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  80275. */
  80276. createInstances: boolean;
  80277. /**
  80278. * 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.
  80279. */
  80280. alwaysComputeBoundingBox: boolean;
  80281. /**
  80282. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  80283. */
  80284. loadAllMaterials: boolean;
  80285. /**
  80286. * Function called before loading a url referenced by the asset.
  80287. */
  80288. preprocessUrlAsync: (url: string) => Promise<string>;
  80289. /**
  80290. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80291. * 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, ...)
  80292. */
  80293. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  80294. private _onMeshLoadedObserver;
  80295. /**
  80296. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80297. * 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, ...)
  80298. */
  80299. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  80300. /**
  80301. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  80302. */
  80303. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  80304. private _onTextureLoadedObserver;
  80305. /**
  80306. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  80307. */
  80308. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  80309. /**
  80310. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  80311. */
  80312. readonly onMaterialLoadedObservable: Observable<Material>;
  80313. private _onMaterialLoadedObserver;
  80314. /**
  80315. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  80316. */
  80317. set onMaterialLoaded(callback: (material: Material) => void);
  80318. /**
  80319. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  80320. */
  80321. readonly onCameraLoadedObservable: Observable<Camera>;
  80322. private _onCameraLoadedObserver;
  80323. /**
  80324. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  80325. */
  80326. set onCameraLoaded(callback: (camera: Camera) => void);
  80327. /**
  80328. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  80329. * For assets with LODs, raised when all of the LODs are complete.
  80330. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80331. */
  80332. readonly onCompleteObservable: Observable<void>;
  80333. private _onCompleteObserver;
  80334. /**
  80335. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  80336. * For assets with LODs, raised when all of the LODs are complete.
  80337. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80338. */
  80339. set onComplete(callback: () => void);
  80340. /**
  80341. * Observable raised when an error occurs.
  80342. */
  80343. readonly onErrorObservable: Observable<any>;
  80344. private _onErrorObserver;
  80345. /**
  80346. * Callback raised when an error occurs.
  80347. */
  80348. set onError(callback: (reason: any) => void);
  80349. /**
  80350. * Observable raised after the loader is disposed.
  80351. */
  80352. readonly onDisposeObservable: Observable<void>;
  80353. private _onDisposeObserver;
  80354. /**
  80355. * Callback raised after the loader is disposed.
  80356. */
  80357. set onDispose(callback: () => void);
  80358. /**
  80359. * Observable raised after a loader extension is created.
  80360. * Set additional options for a loader extension in this event.
  80361. */
  80362. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  80363. private _onExtensionLoadedObserver;
  80364. /**
  80365. * Callback raised after a loader extension is created.
  80366. */
  80367. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  80368. /**
  80369. * Defines if the loader logging is enabled.
  80370. */
  80371. get loggingEnabled(): boolean;
  80372. set loggingEnabled(value: boolean);
  80373. /**
  80374. * Defines if the loader should capture performance counters.
  80375. */
  80376. get capturePerformanceCounters(): boolean;
  80377. set capturePerformanceCounters(value: boolean);
  80378. /**
  80379. * Defines if the loader should validate the asset.
  80380. */
  80381. validate: boolean;
  80382. /**
  80383. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  80384. */
  80385. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  80386. private _onValidatedObserver;
  80387. /**
  80388. * Callback raised after a loader extension is created.
  80389. */
  80390. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  80391. private _loader;
  80392. private _progressCallback?;
  80393. private _requests;
  80394. private static magicBase64Encoded;
  80395. /**
  80396. * Name of the loader ("gltf")
  80397. */
  80398. name: string;
  80399. /** @hidden */
  80400. extensions: ISceneLoaderPluginExtensions;
  80401. /**
  80402. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  80403. */
  80404. dispose(): void;
  80405. /** @hidden */
  80406. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80407. /** @hidden */
  80408. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80409. /** @hidden */
  80410. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80411. meshes: AbstractMesh[];
  80412. particleSystems: IParticleSystem[];
  80413. skeletons: Skeleton[];
  80414. animationGroups: AnimationGroup[];
  80415. }>;
  80416. /** @hidden */
  80417. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80418. /** @hidden */
  80419. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80420. /** @hidden */
  80421. canDirectLoad(data: string): boolean;
  80422. /** @hidden */
  80423. directLoad(scene: Scene, data: string): Promise<any>;
  80424. /**
  80425. * The callback that allows custom handling of the root url based on the response url.
  80426. * @param rootUrl the original root url
  80427. * @param responseURL the response url if available
  80428. * @returns the new root url
  80429. */
  80430. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  80431. /** @hidden */
  80432. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  80433. /**
  80434. * The loader state or null if the loader is not active.
  80435. */
  80436. get loaderState(): Nullable<GLTFLoaderState>;
  80437. /**
  80438. * Returns a promise that resolves when the asset is completely loaded.
  80439. * @returns a promise that resolves when the asset is completely loaded.
  80440. */
  80441. whenCompleteAsync(): Promise<void>;
  80442. /** @hidden */
  80443. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  80444. /** @hidden */
  80445. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  80446. private _onProgress;
  80447. private _validate;
  80448. private _getLoader;
  80449. private _parseJson;
  80450. private _unpackBinaryAsync;
  80451. private _unpackBinaryV1Async;
  80452. private _unpackBinaryV2Async;
  80453. private static _parseVersion;
  80454. private static _compareVersion;
  80455. private static readonly _logSpaces;
  80456. private _logIndentLevel;
  80457. private _loggingEnabled;
  80458. /** @hidden */
  80459. _log: (message: string) => void;
  80460. /** @hidden */
  80461. _logOpen(message: string): void;
  80462. /** @hidden */
  80463. _logClose(): void;
  80464. private _logEnabled;
  80465. private _logDisabled;
  80466. private _capturePerformanceCounters;
  80467. /** @hidden */
  80468. _startPerformanceCounter: (counterName: string) => void;
  80469. /** @hidden */
  80470. _endPerformanceCounter: (counterName: string) => void;
  80471. private _startPerformanceCounterEnabled;
  80472. private _startPerformanceCounterDisabled;
  80473. private _endPerformanceCounterEnabled;
  80474. private _endPerformanceCounterDisabled;
  80475. }
  80476. }
  80477. declare module BABYLON.GLTF1 {
  80478. /**
  80479. * Enums
  80480. * @hidden
  80481. */
  80482. export enum EComponentType {
  80483. BYTE = 5120,
  80484. UNSIGNED_BYTE = 5121,
  80485. SHORT = 5122,
  80486. UNSIGNED_SHORT = 5123,
  80487. FLOAT = 5126
  80488. }
  80489. /** @hidden */
  80490. export enum EShaderType {
  80491. FRAGMENT = 35632,
  80492. VERTEX = 35633
  80493. }
  80494. /** @hidden */
  80495. export enum EParameterType {
  80496. BYTE = 5120,
  80497. UNSIGNED_BYTE = 5121,
  80498. SHORT = 5122,
  80499. UNSIGNED_SHORT = 5123,
  80500. INT = 5124,
  80501. UNSIGNED_INT = 5125,
  80502. FLOAT = 5126,
  80503. FLOAT_VEC2 = 35664,
  80504. FLOAT_VEC3 = 35665,
  80505. FLOAT_VEC4 = 35666,
  80506. INT_VEC2 = 35667,
  80507. INT_VEC3 = 35668,
  80508. INT_VEC4 = 35669,
  80509. BOOL = 35670,
  80510. BOOL_VEC2 = 35671,
  80511. BOOL_VEC3 = 35672,
  80512. BOOL_VEC4 = 35673,
  80513. FLOAT_MAT2 = 35674,
  80514. FLOAT_MAT3 = 35675,
  80515. FLOAT_MAT4 = 35676,
  80516. SAMPLER_2D = 35678
  80517. }
  80518. /** @hidden */
  80519. export enum ETextureWrapMode {
  80520. CLAMP_TO_EDGE = 33071,
  80521. MIRRORED_REPEAT = 33648,
  80522. REPEAT = 10497
  80523. }
  80524. /** @hidden */
  80525. export enum ETextureFilterType {
  80526. NEAREST = 9728,
  80527. LINEAR = 9728,
  80528. NEAREST_MIPMAP_NEAREST = 9984,
  80529. LINEAR_MIPMAP_NEAREST = 9985,
  80530. NEAREST_MIPMAP_LINEAR = 9986,
  80531. LINEAR_MIPMAP_LINEAR = 9987
  80532. }
  80533. /** @hidden */
  80534. export enum ETextureFormat {
  80535. ALPHA = 6406,
  80536. RGB = 6407,
  80537. RGBA = 6408,
  80538. LUMINANCE = 6409,
  80539. LUMINANCE_ALPHA = 6410
  80540. }
  80541. /** @hidden */
  80542. export enum ECullingType {
  80543. FRONT = 1028,
  80544. BACK = 1029,
  80545. FRONT_AND_BACK = 1032
  80546. }
  80547. /** @hidden */
  80548. export enum EBlendingFunction {
  80549. ZERO = 0,
  80550. ONE = 1,
  80551. SRC_COLOR = 768,
  80552. ONE_MINUS_SRC_COLOR = 769,
  80553. DST_COLOR = 774,
  80554. ONE_MINUS_DST_COLOR = 775,
  80555. SRC_ALPHA = 770,
  80556. ONE_MINUS_SRC_ALPHA = 771,
  80557. DST_ALPHA = 772,
  80558. ONE_MINUS_DST_ALPHA = 773,
  80559. CONSTANT_COLOR = 32769,
  80560. ONE_MINUS_CONSTANT_COLOR = 32770,
  80561. CONSTANT_ALPHA = 32771,
  80562. ONE_MINUS_CONSTANT_ALPHA = 32772,
  80563. SRC_ALPHA_SATURATE = 776
  80564. }
  80565. /** @hidden */
  80566. export interface IGLTFProperty {
  80567. extensions?: {
  80568. [key: string]: any;
  80569. };
  80570. extras?: Object;
  80571. }
  80572. /** @hidden */
  80573. export interface IGLTFChildRootProperty extends IGLTFProperty {
  80574. name?: string;
  80575. }
  80576. /** @hidden */
  80577. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  80578. bufferView: string;
  80579. byteOffset: number;
  80580. byteStride: number;
  80581. count: number;
  80582. type: string;
  80583. componentType: EComponentType;
  80584. max?: number[];
  80585. min?: number[];
  80586. name?: string;
  80587. }
  80588. /** @hidden */
  80589. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  80590. buffer: string;
  80591. byteOffset: number;
  80592. byteLength: number;
  80593. byteStride: number;
  80594. target?: number;
  80595. }
  80596. /** @hidden */
  80597. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  80598. uri: string;
  80599. byteLength?: number;
  80600. type?: string;
  80601. }
  80602. /** @hidden */
  80603. export interface IGLTFShader extends IGLTFChildRootProperty {
  80604. uri: string;
  80605. type: EShaderType;
  80606. }
  80607. /** @hidden */
  80608. export interface IGLTFProgram extends IGLTFChildRootProperty {
  80609. attributes: string[];
  80610. fragmentShader: string;
  80611. vertexShader: string;
  80612. }
  80613. /** @hidden */
  80614. export interface IGLTFTechniqueParameter {
  80615. type: number;
  80616. count?: number;
  80617. semantic?: string;
  80618. node?: string;
  80619. value?: number | boolean | string | Array<any>;
  80620. source?: string;
  80621. babylonValue?: any;
  80622. }
  80623. /** @hidden */
  80624. export interface IGLTFTechniqueCommonProfile {
  80625. lightingModel: string;
  80626. texcoordBindings: Object;
  80627. parameters?: Array<any>;
  80628. }
  80629. /** @hidden */
  80630. export interface IGLTFTechniqueStatesFunctions {
  80631. blendColor?: number[];
  80632. blendEquationSeparate?: number[];
  80633. blendFuncSeparate?: number[];
  80634. colorMask: boolean[];
  80635. cullFace: number[];
  80636. }
  80637. /** @hidden */
  80638. export interface IGLTFTechniqueStates {
  80639. enable: number[];
  80640. functions: IGLTFTechniqueStatesFunctions;
  80641. }
  80642. /** @hidden */
  80643. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  80644. parameters: {
  80645. [key: string]: IGLTFTechniqueParameter;
  80646. };
  80647. program: string;
  80648. attributes: {
  80649. [key: string]: string;
  80650. };
  80651. uniforms: {
  80652. [key: string]: string;
  80653. };
  80654. states: IGLTFTechniqueStates;
  80655. }
  80656. /** @hidden */
  80657. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  80658. technique?: string;
  80659. values: string[];
  80660. }
  80661. /** @hidden */
  80662. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  80663. attributes: {
  80664. [key: string]: string;
  80665. };
  80666. indices: string;
  80667. material: string;
  80668. mode?: number;
  80669. }
  80670. /** @hidden */
  80671. export interface IGLTFMesh extends IGLTFChildRootProperty {
  80672. primitives: IGLTFMeshPrimitive[];
  80673. }
  80674. /** @hidden */
  80675. export interface IGLTFImage extends IGLTFChildRootProperty {
  80676. uri: string;
  80677. }
  80678. /** @hidden */
  80679. export interface IGLTFSampler extends IGLTFChildRootProperty {
  80680. magFilter?: number;
  80681. minFilter?: number;
  80682. wrapS?: number;
  80683. wrapT?: number;
  80684. }
  80685. /** @hidden */
  80686. export interface IGLTFTexture extends IGLTFChildRootProperty {
  80687. sampler: string;
  80688. source: string;
  80689. format?: ETextureFormat;
  80690. internalFormat?: ETextureFormat;
  80691. target?: number;
  80692. type?: number;
  80693. babylonTexture?: Texture;
  80694. }
  80695. /** @hidden */
  80696. export interface IGLTFAmbienLight {
  80697. color?: number[];
  80698. }
  80699. /** @hidden */
  80700. export interface IGLTFDirectionalLight {
  80701. color?: number[];
  80702. }
  80703. /** @hidden */
  80704. export interface IGLTFPointLight {
  80705. color?: number[];
  80706. constantAttenuation?: number;
  80707. linearAttenuation?: number;
  80708. quadraticAttenuation?: number;
  80709. }
  80710. /** @hidden */
  80711. export interface IGLTFSpotLight {
  80712. color?: number[];
  80713. constantAttenuation?: number;
  80714. fallOfAngle?: number;
  80715. fallOffExponent?: number;
  80716. linearAttenuation?: number;
  80717. quadraticAttenuation?: number;
  80718. }
  80719. /** @hidden */
  80720. export interface IGLTFLight extends IGLTFChildRootProperty {
  80721. type: string;
  80722. }
  80723. /** @hidden */
  80724. export interface IGLTFCameraOrthographic {
  80725. xmag: number;
  80726. ymag: number;
  80727. zfar: number;
  80728. znear: number;
  80729. }
  80730. /** @hidden */
  80731. export interface IGLTFCameraPerspective {
  80732. aspectRatio: number;
  80733. yfov: number;
  80734. zfar: number;
  80735. znear: number;
  80736. }
  80737. /** @hidden */
  80738. export interface IGLTFCamera extends IGLTFChildRootProperty {
  80739. type: string;
  80740. }
  80741. /** @hidden */
  80742. export interface IGLTFAnimationChannelTarget {
  80743. id: string;
  80744. path: string;
  80745. }
  80746. /** @hidden */
  80747. export interface IGLTFAnimationChannel {
  80748. sampler: string;
  80749. target: IGLTFAnimationChannelTarget;
  80750. }
  80751. /** @hidden */
  80752. export interface IGLTFAnimationSampler {
  80753. input: string;
  80754. output: string;
  80755. interpolation?: string;
  80756. }
  80757. /** @hidden */
  80758. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  80759. channels?: IGLTFAnimationChannel[];
  80760. parameters?: {
  80761. [key: string]: string;
  80762. };
  80763. samplers?: {
  80764. [key: string]: IGLTFAnimationSampler;
  80765. };
  80766. }
  80767. /** @hidden */
  80768. export interface IGLTFNodeInstanceSkin {
  80769. skeletons: string[];
  80770. skin: string;
  80771. meshes: string[];
  80772. }
  80773. /** @hidden */
  80774. export interface IGLTFSkins extends IGLTFChildRootProperty {
  80775. bindShapeMatrix: number[];
  80776. inverseBindMatrices: string;
  80777. jointNames: string[];
  80778. babylonSkeleton?: Skeleton;
  80779. }
  80780. /** @hidden */
  80781. export interface IGLTFNode extends IGLTFChildRootProperty {
  80782. camera?: string;
  80783. children: string[];
  80784. skin?: string;
  80785. jointName?: string;
  80786. light?: string;
  80787. matrix: number[];
  80788. mesh?: string;
  80789. meshes?: string[];
  80790. rotation?: number[];
  80791. scale?: number[];
  80792. translation?: number[];
  80793. babylonNode?: Node;
  80794. }
  80795. /** @hidden */
  80796. export interface IGLTFScene extends IGLTFChildRootProperty {
  80797. nodes: string[];
  80798. }
  80799. /** @hidden */
  80800. export interface IGLTFRuntime {
  80801. extensions: {
  80802. [key: string]: any;
  80803. };
  80804. accessors: {
  80805. [key: string]: IGLTFAccessor;
  80806. };
  80807. buffers: {
  80808. [key: string]: IGLTFBuffer;
  80809. };
  80810. bufferViews: {
  80811. [key: string]: IGLTFBufferView;
  80812. };
  80813. meshes: {
  80814. [key: string]: IGLTFMesh;
  80815. };
  80816. lights: {
  80817. [key: string]: IGLTFLight;
  80818. };
  80819. cameras: {
  80820. [key: string]: IGLTFCamera;
  80821. };
  80822. nodes: {
  80823. [key: string]: IGLTFNode;
  80824. };
  80825. images: {
  80826. [key: string]: IGLTFImage;
  80827. };
  80828. textures: {
  80829. [key: string]: IGLTFTexture;
  80830. };
  80831. shaders: {
  80832. [key: string]: IGLTFShader;
  80833. };
  80834. programs: {
  80835. [key: string]: IGLTFProgram;
  80836. };
  80837. samplers: {
  80838. [key: string]: IGLTFSampler;
  80839. };
  80840. techniques: {
  80841. [key: string]: IGLTFTechnique;
  80842. };
  80843. materials: {
  80844. [key: string]: IGLTFMaterial;
  80845. };
  80846. animations: {
  80847. [key: string]: IGLTFAnimation;
  80848. };
  80849. skins: {
  80850. [key: string]: IGLTFSkins;
  80851. };
  80852. currentScene?: Object;
  80853. scenes: {
  80854. [key: string]: IGLTFScene;
  80855. };
  80856. extensionsUsed: string[];
  80857. extensionsRequired?: string[];
  80858. buffersCount: number;
  80859. shaderscount: number;
  80860. scene: Scene;
  80861. rootUrl: string;
  80862. loadedBufferCount: number;
  80863. loadedBufferViews: {
  80864. [name: string]: ArrayBufferView;
  80865. };
  80866. loadedShaderCount: number;
  80867. importOnlyMeshes: boolean;
  80868. importMeshesNames?: string[];
  80869. dummyNodes: Node[];
  80870. forAssetContainer: boolean;
  80871. }
  80872. /** @hidden */
  80873. export interface INodeToRoot {
  80874. bone: Bone;
  80875. node: IGLTFNode;
  80876. id: string;
  80877. }
  80878. /** @hidden */
  80879. export interface IJointNode {
  80880. node: IGLTFNode;
  80881. id: string;
  80882. }
  80883. }
  80884. declare module BABYLON.GLTF1 {
  80885. /**
  80886. * Utils functions for GLTF
  80887. * @hidden
  80888. */
  80889. export class GLTFUtils {
  80890. /**
  80891. * Sets the given "parameter" matrix
  80892. * @param scene: the Scene object
  80893. * @param source: the source node where to pick the matrix
  80894. * @param parameter: the GLTF technique parameter
  80895. * @param uniformName: the name of the shader's uniform
  80896. * @param shaderMaterial: the shader material
  80897. */
  80898. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  80899. /**
  80900. * Sets the given "parameter" matrix
  80901. * @param shaderMaterial: the shader material
  80902. * @param uniform: the name of the shader's uniform
  80903. * @param value: the value of the uniform
  80904. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  80905. */
  80906. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  80907. /**
  80908. * Returns the wrap mode of the texture
  80909. * @param mode: the mode value
  80910. */
  80911. static GetWrapMode(mode: number): number;
  80912. /**
  80913. * Returns the byte stride giving an accessor
  80914. * @param accessor: the GLTF accessor objet
  80915. */
  80916. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  80917. /**
  80918. * Returns the texture filter mode giving a mode value
  80919. * @param mode: the filter mode value
  80920. */
  80921. static GetTextureFilterMode(mode: number): ETextureFilterType;
  80922. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  80923. /**
  80924. * Returns a buffer from its accessor
  80925. * @param gltfRuntime: the GLTF runtime
  80926. * @param accessor: the GLTF accessor
  80927. */
  80928. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  80929. /**
  80930. * Decodes a buffer view into a string
  80931. * @param view: the buffer view
  80932. */
  80933. static DecodeBufferToText(view: ArrayBufferView): string;
  80934. /**
  80935. * Returns the default material of gltf. Related to
  80936. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  80937. * @param scene: the Babylon.js scene
  80938. */
  80939. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  80940. private static _DefaultMaterial;
  80941. }
  80942. }
  80943. declare module BABYLON.GLTF1 {
  80944. /**
  80945. * Implementation of the base glTF spec
  80946. * @hidden
  80947. */
  80948. export class GLTFLoaderBase {
  80949. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  80950. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80951. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  80952. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80953. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  80954. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80955. }
  80956. /**
  80957. * glTF V1 Loader
  80958. * @hidden
  80959. */
  80960. export class GLTFLoader implements IGLTFLoader {
  80961. static Extensions: {
  80962. [name: string]: GLTFLoaderExtension;
  80963. };
  80964. static RegisterExtension(extension: GLTFLoaderExtension): void;
  80965. state: Nullable<GLTFLoaderState>;
  80966. dispose(): void;
  80967. private _importMeshAsync;
  80968. /**
  80969. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  80970. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80971. * @param scene the scene the meshes should be added to
  80972. * @param forAssetContainer defines if the entities must be stored in the scene
  80973. * @param data gltf data containing information of the meshes in a loaded file
  80974. * @param rootUrl root url to load from
  80975. * @param onProgress event that fires when loading progress has occured
  80976. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80977. */
  80978. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  80979. private _loadAsync;
  80980. /**
  80981. * Imports all objects from a loaded gltf file and adds them to the scene
  80982. * @param scene the scene the objects should be added to
  80983. * @param data gltf data containing information of the meshes in a loaded file
  80984. * @param rootUrl root url to load from
  80985. * @param onProgress event that fires when loading progress has occured
  80986. * @returns a promise which completes when objects have been loaded to the scene
  80987. */
  80988. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  80989. private _loadShadersAsync;
  80990. private _loadBuffersAsync;
  80991. private _createNodes;
  80992. }
  80993. /** @hidden */
  80994. export abstract class GLTFLoaderExtension {
  80995. private _name;
  80996. constructor(name: string);
  80997. get name(): string;
  80998. /**
  80999. * Defines an override for loading the runtime
  81000. * Return true to stop further extensions from loading the runtime
  81001. */
  81002. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81003. /**
  81004. * Defines an onverride for creating gltf runtime
  81005. * Return true to stop further extensions from creating the runtime
  81006. */
  81007. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81008. /**
  81009. * Defines an override for loading buffers
  81010. * Return true to stop further extensions from loading this buffer
  81011. */
  81012. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81013. /**
  81014. * Defines an override for loading texture buffers
  81015. * Return true to stop further extensions from loading this texture data
  81016. */
  81017. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81018. /**
  81019. * Defines an override for creating textures
  81020. * Return true to stop further extensions from loading this texture
  81021. */
  81022. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81023. /**
  81024. * Defines an override for loading shader strings
  81025. * Return true to stop further extensions from loading this shader data
  81026. */
  81027. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81028. /**
  81029. * Defines an override for loading materials
  81030. * Return true to stop further extensions from loading this material
  81031. */
  81032. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81033. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81034. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81035. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81036. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81037. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81038. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81039. private static LoadTextureBufferAsync;
  81040. private static CreateTextureAsync;
  81041. private static ApplyExtensions;
  81042. }
  81043. }
  81044. declare module BABYLON.GLTF1 {
  81045. /** @hidden */
  81046. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81047. private _bin;
  81048. constructor();
  81049. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81050. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81051. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81052. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81053. }
  81054. }
  81055. declare module BABYLON.GLTF1 {
  81056. /** @hidden */
  81057. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81058. constructor();
  81059. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81060. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81061. private _loadTexture;
  81062. }
  81063. }
  81064. declare module BABYLON.GLTF2.Loader {
  81065. /**
  81066. * Loader interface with an index field.
  81067. */
  81068. export interface IArrayItem {
  81069. /**
  81070. * The index of this item in the array.
  81071. */
  81072. index: number;
  81073. }
  81074. /**
  81075. * Loader interface with additional members.
  81076. */
  81077. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81078. /** @hidden */
  81079. _data?: Promise<ArrayBufferView>;
  81080. /** @hidden */
  81081. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81082. }
  81083. /**
  81084. * Loader interface with additional members.
  81085. */
  81086. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81087. }
  81088. /** @hidden */
  81089. export interface _IAnimationSamplerData {
  81090. input: Float32Array;
  81091. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81092. output: Float32Array;
  81093. }
  81094. /**
  81095. * Loader interface with additional members.
  81096. */
  81097. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81098. /** @hidden */
  81099. _data?: Promise<_IAnimationSamplerData>;
  81100. }
  81101. /**
  81102. * Loader interface with additional members.
  81103. */
  81104. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81105. channels: IAnimationChannel[];
  81106. samplers: IAnimationSampler[];
  81107. /** @hidden */
  81108. _babylonAnimationGroup?: AnimationGroup;
  81109. }
  81110. /**
  81111. * Loader interface with additional members.
  81112. */
  81113. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81114. /** @hidden */
  81115. _data?: Promise<ArrayBufferView>;
  81116. }
  81117. /**
  81118. * Loader interface with additional members.
  81119. */
  81120. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81121. /** @hidden */
  81122. _data?: Promise<ArrayBufferView>;
  81123. /** @hidden */
  81124. _babylonBuffer?: Promise<Buffer>;
  81125. }
  81126. /**
  81127. * Loader interface with additional members.
  81128. */
  81129. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81130. }
  81131. /**
  81132. * Loader interface with additional members.
  81133. */
  81134. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81135. /** @hidden */
  81136. _data?: Promise<ArrayBufferView>;
  81137. }
  81138. /**
  81139. * Loader interface with additional members.
  81140. */
  81141. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81142. }
  81143. /**
  81144. * Loader interface with additional members.
  81145. */
  81146. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81147. }
  81148. /**
  81149. * Loader interface with additional members.
  81150. */
  81151. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81152. baseColorTexture?: ITextureInfo;
  81153. metallicRoughnessTexture?: ITextureInfo;
  81154. }
  81155. /**
  81156. * Loader interface with additional members.
  81157. */
  81158. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81159. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81160. normalTexture?: IMaterialNormalTextureInfo;
  81161. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81162. emissiveTexture?: ITextureInfo;
  81163. /** @hidden */
  81164. _data?: {
  81165. [babylonDrawMode: number]: {
  81166. babylonMaterial: Material;
  81167. babylonMeshes: AbstractMesh[];
  81168. promise: Promise<void>;
  81169. };
  81170. };
  81171. }
  81172. /**
  81173. * Loader interface with additional members.
  81174. */
  81175. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  81176. primitives: IMeshPrimitive[];
  81177. }
  81178. /**
  81179. * Loader interface with additional members.
  81180. */
  81181. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  81182. /** @hidden */
  81183. _instanceData?: {
  81184. babylonSourceMesh: Mesh;
  81185. promise: Promise<any>;
  81186. };
  81187. }
  81188. /**
  81189. * Loader interface with additional members.
  81190. */
  81191. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  81192. /**
  81193. * The parent glTF node.
  81194. */
  81195. parent?: INode;
  81196. /** @hidden */
  81197. _babylonTransformNode?: TransformNode;
  81198. /** @hidden */
  81199. _primitiveBabylonMeshes?: AbstractMesh[];
  81200. /** @hidden */
  81201. _babylonBones?: Bone[];
  81202. /** @hidden */
  81203. _numMorphTargets?: number;
  81204. }
  81205. /** @hidden */
  81206. export interface _ISamplerData {
  81207. noMipMaps: boolean;
  81208. samplingMode: number;
  81209. wrapU: number;
  81210. wrapV: number;
  81211. }
  81212. /**
  81213. * Loader interface with additional members.
  81214. */
  81215. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  81216. /** @hidden */
  81217. _data?: _ISamplerData;
  81218. }
  81219. /**
  81220. * Loader interface with additional members.
  81221. */
  81222. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  81223. }
  81224. /**
  81225. * Loader interface with additional members.
  81226. */
  81227. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  81228. /** @hidden */
  81229. _data?: {
  81230. babylonSkeleton: Skeleton;
  81231. promise: Promise<void>;
  81232. };
  81233. }
  81234. /**
  81235. * Loader interface with additional members.
  81236. */
  81237. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  81238. }
  81239. /**
  81240. * Loader interface with additional members.
  81241. */
  81242. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  81243. }
  81244. /**
  81245. * Loader interface with additional members.
  81246. */
  81247. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  81248. accessors?: IAccessor[];
  81249. animations?: IAnimation[];
  81250. buffers?: IBuffer[];
  81251. bufferViews?: IBufferView[];
  81252. cameras?: ICamera[];
  81253. images?: IImage[];
  81254. materials?: IMaterial[];
  81255. meshes?: IMesh[];
  81256. nodes?: INode[];
  81257. samplers?: ISampler[];
  81258. scenes?: IScene[];
  81259. skins?: ISkin[];
  81260. textures?: ITexture[];
  81261. }
  81262. }
  81263. declare module BABYLON.GLTF2 {
  81264. /**
  81265. * Interface for a glTF loader extension.
  81266. */
  81267. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  81268. /**
  81269. * Called after the loader state changes to LOADING.
  81270. */
  81271. onLoading?(): void;
  81272. /**
  81273. * Called after the loader state changes to READY.
  81274. */
  81275. onReady?(): void;
  81276. /**
  81277. * Define this method to modify the default behavior when loading scenes.
  81278. * @param context The context when loading the asset
  81279. * @param scene The glTF scene property
  81280. * @returns A promise that resolves when the load is complete or null if not handled
  81281. */
  81282. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  81283. /**
  81284. * Define this method to modify the default behavior when loading nodes.
  81285. * @param context The context when loading the asset
  81286. * @param node The glTF node property
  81287. * @param assign A function called synchronously after parsing the glTF properties
  81288. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  81289. */
  81290. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81291. /**
  81292. * Define this method to modify the default behavior when loading cameras.
  81293. * @param context The context when loading the asset
  81294. * @param camera The glTF camera property
  81295. * @param assign A function called synchronously after parsing the glTF properties
  81296. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  81297. */
  81298. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81299. /**
  81300. * @hidden
  81301. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  81302. * @param context The context when loading the asset
  81303. * @param primitive The glTF mesh primitive property
  81304. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  81305. */
  81306. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81307. /**
  81308. * @hidden
  81309. * Define this method to modify the default behavior when loading data for mesh primitives.
  81310. * @param context The context when loading the asset
  81311. * @param name The mesh name when loading the asset
  81312. * @param node The glTF node when loading the asset
  81313. * @param mesh The glTF mesh when loading the asset
  81314. * @param primitive The glTF mesh primitive property
  81315. * @param assign A function called synchronously after parsing the glTF properties
  81316. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81317. */
  81318. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81319. /**
  81320. * @hidden
  81321. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  81322. * @param context The context when loading the asset
  81323. * @param material The glTF material property
  81324. * @param assign A function called synchronously after parsing the glTF properties
  81325. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  81326. */
  81327. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81328. /**
  81329. * Define this method to modify the default behavior when creating materials.
  81330. * @param context The context when loading the asset
  81331. * @param material The glTF material property
  81332. * @param babylonDrawMode The draw mode for the Babylon material
  81333. * @returns The Babylon material or null if not handled
  81334. */
  81335. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81336. /**
  81337. * Define this method to modify the default behavior when loading material properties.
  81338. * @param context The context when loading the asset
  81339. * @param material The glTF material property
  81340. * @param babylonMaterial The Babylon material
  81341. * @returns A promise that resolves when the load is complete or null if not handled
  81342. */
  81343. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81344. /**
  81345. * Define this method to modify the default behavior when loading texture infos.
  81346. * @param context The context when loading the asset
  81347. * @param textureInfo The glTF texture info property
  81348. * @param assign A function called synchronously after parsing the glTF properties
  81349. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81350. */
  81351. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81352. /**
  81353. * @hidden
  81354. * Define this method to modify the default behavior when loading textures.
  81355. * @param context The context when loading the asset
  81356. * @param texture The glTF texture property
  81357. * @param assign A function called synchronously after parsing the glTF properties
  81358. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81359. */
  81360. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81361. /**
  81362. * Define this method to modify the default behavior when loading animations.
  81363. * @param context The context when loading the asset
  81364. * @param animation The glTF animation property
  81365. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  81366. */
  81367. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81368. /**
  81369. * @hidden
  81370. * Define this method to modify the default behavior when loading skins.
  81371. * @param context The context when loading the asset
  81372. * @param node The glTF node property
  81373. * @param skin The glTF skin property
  81374. * @returns A promise that resolves when the load is complete or null if not handled
  81375. */
  81376. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  81377. /**
  81378. * @hidden
  81379. * Define this method to modify the default behavior when loading uris.
  81380. * @param context The context when loading the asset
  81381. * @param property The glTF property associated with the uri
  81382. * @param uri The uri to load
  81383. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81384. */
  81385. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81386. /**
  81387. * Define this method to modify the default behavior when loading buffer views.
  81388. * @param context The context when loading the asset
  81389. * @param bufferView The glTF buffer view property
  81390. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81391. */
  81392. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  81393. /**
  81394. * Define this method to modify the default behavior when loading buffers.
  81395. * @param context The context when loading the asset
  81396. * @param buffer The glTF buffer property
  81397. * @param byteOffset The byte offset to load
  81398. * @param byteLength The byte length to load
  81399. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81400. */
  81401. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81402. }
  81403. }
  81404. declare module BABYLON.GLTF2 {
  81405. /**
  81406. * Helper class for working with arrays when loading the glTF asset
  81407. */
  81408. export class ArrayItem {
  81409. /**
  81410. * Gets an item from the given array.
  81411. * @param context The context when loading the asset
  81412. * @param array The array to get the item from
  81413. * @param index The index to the array
  81414. * @returns The array item
  81415. */
  81416. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  81417. /**
  81418. * Assign an `index` field to each item of the given array.
  81419. * @param array The array of items
  81420. */
  81421. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  81422. }
  81423. /**
  81424. * The glTF 2.0 loader
  81425. */
  81426. export class GLTFLoader implements IGLTFLoader {
  81427. /** @hidden */
  81428. _completePromises: Promise<any>[];
  81429. /** @hidden */
  81430. _forAssetContainer: boolean;
  81431. /** Storage */
  81432. _babylonLights: Light[];
  81433. /** @hidden */
  81434. _disableInstancedMesh: number;
  81435. private _disposed;
  81436. private _parent;
  81437. private _state;
  81438. private _extensions;
  81439. private _rootUrl;
  81440. private _fileName;
  81441. private _uniqueRootUrl;
  81442. private _gltf;
  81443. private _bin;
  81444. private _babylonScene;
  81445. private _rootBabylonMesh;
  81446. private _defaultBabylonMaterialData;
  81447. private static _RegisteredExtensions;
  81448. /**
  81449. * The default glTF sampler.
  81450. */
  81451. static readonly DefaultSampler: ISampler;
  81452. /**
  81453. * Registers a loader extension.
  81454. * @param name The name of the loader extension.
  81455. * @param factory The factory function that creates the loader extension.
  81456. */
  81457. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  81458. /**
  81459. * Unregisters a loader extension.
  81460. * @param name The name of the loader extension.
  81461. * @returns A boolean indicating whether the extension has been unregistered
  81462. */
  81463. static UnregisterExtension(name: string): boolean;
  81464. /**
  81465. * The loader state.
  81466. */
  81467. get state(): Nullable<GLTFLoaderState>;
  81468. /**
  81469. * The object that represents the glTF JSON.
  81470. */
  81471. get gltf(): IGLTF;
  81472. /**
  81473. * The BIN chunk of a binary glTF.
  81474. */
  81475. get bin(): Nullable<IDataBuffer>;
  81476. /**
  81477. * The parent file loader.
  81478. */
  81479. get parent(): GLTFFileLoader;
  81480. /**
  81481. * The Babylon scene when loading the asset.
  81482. */
  81483. get babylonScene(): Scene;
  81484. /**
  81485. * The root Babylon mesh when loading the asset.
  81486. */
  81487. get rootBabylonMesh(): Mesh;
  81488. /** @hidden */
  81489. constructor(parent: GLTFFileLoader);
  81490. /** @hidden */
  81491. dispose(): void;
  81492. /** @hidden */
  81493. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  81494. /** @hidden */
  81495. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81496. private _loadAsync;
  81497. private _loadData;
  81498. private _setupData;
  81499. private _loadExtensions;
  81500. private _checkExtensions;
  81501. private _setState;
  81502. private _createRootNode;
  81503. /**
  81504. * Loads a glTF scene.
  81505. * @param context The context when loading the asset
  81506. * @param scene The glTF scene property
  81507. * @returns A promise that resolves when the load is complete
  81508. */
  81509. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  81510. private _forEachPrimitive;
  81511. private _getMeshes;
  81512. private _getTransformNodes;
  81513. private _getSkeletons;
  81514. private _getAnimationGroups;
  81515. private _startAnimations;
  81516. /**
  81517. * Loads a glTF node.
  81518. * @param context The context when loading the asset
  81519. * @param node The glTF node property
  81520. * @param assign A function called synchronously after parsing the glTF properties
  81521. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  81522. */
  81523. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  81524. private _loadMeshAsync;
  81525. /**
  81526. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  81527. * @param context The context when loading the asset
  81528. * @param name The mesh name when loading the asset
  81529. * @param node The glTF node when loading the asset
  81530. * @param mesh The glTF mesh when loading the asset
  81531. * @param primitive The glTF mesh primitive property
  81532. * @param assign A function called synchronously after parsing the glTF properties
  81533. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81534. */
  81535. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  81536. private _loadVertexDataAsync;
  81537. private _createMorphTargets;
  81538. private _loadMorphTargetsAsync;
  81539. private _loadMorphTargetVertexDataAsync;
  81540. private static _LoadTransform;
  81541. private _loadSkinAsync;
  81542. private _loadBones;
  81543. private _loadBone;
  81544. private _loadSkinInverseBindMatricesDataAsync;
  81545. private _updateBoneMatrices;
  81546. private _getNodeMatrix;
  81547. /**
  81548. * Loads a glTF camera.
  81549. * @param context The context when loading the asset
  81550. * @param camera The glTF camera property
  81551. * @param assign A function called synchronously after parsing the glTF properties
  81552. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  81553. */
  81554. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  81555. private _loadAnimationsAsync;
  81556. /**
  81557. * Loads a glTF animation.
  81558. * @param context The context when loading the asset
  81559. * @param animation The glTF animation property
  81560. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  81561. */
  81562. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  81563. /**
  81564. * @hidden Loads a glTF animation channel.
  81565. * @param context The context when loading the asset
  81566. * @param animationContext The context of the animation when loading the asset
  81567. * @param animation The glTF animation property
  81568. * @param channel The glTF animation channel property
  81569. * @param babylonAnimationGroup The babylon animation group property
  81570. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  81571. * @returns A void promise when the channel load is complete
  81572. */
  81573. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  81574. private _loadAnimationSamplerAsync;
  81575. private _loadBufferAsync;
  81576. /**
  81577. * Loads a glTF buffer view.
  81578. * @param context The context when loading the asset
  81579. * @param bufferView The glTF buffer view property
  81580. * @returns A promise that resolves with the loaded data when the load is complete
  81581. */
  81582. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  81583. private _loadAccessorAsync;
  81584. /** @hidden */
  81585. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  81586. private _loadIndicesAccessorAsync;
  81587. private _loadVertexBufferViewAsync;
  81588. private _loadVertexAccessorAsync;
  81589. private _loadMaterialMetallicRoughnessPropertiesAsync;
  81590. /** @hidden */
  81591. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  81592. private _createDefaultMaterial;
  81593. /**
  81594. * Creates a Babylon material from a glTF material.
  81595. * @param context The context when loading the asset
  81596. * @param material The glTF material property
  81597. * @param babylonDrawMode The draw mode for the Babylon material
  81598. * @returns The Babylon material
  81599. */
  81600. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  81601. /**
  81602. * Loads properties from a glTF material into a Babylon material.
  81603. * @param context The context when loading the asset
  81604. * @param material The glTF material property
  81605. * @param babylonMaterial The Babylon material
  81606. * @returns A promise that resolves when the load is complete
  81607. */
  81608. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81609. /**
  81610. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  81611. * @param context The context when loading the asset
  81612. * @param material The glTF material property
  81613. * @param babylonMaterial The Babylon material
  81614. * @returns A promise that resolves when the load is complete
  81615. */
  81616. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81617. /**
  81618. * Loads the alpha properties from a glTF material into a Babylon material.
  81619. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  81620. * @param context The context when loading the asset
  81621. * @param material The glTF material property
  81622. * @param babylonMaterial The Babylon material
  81623. */
  81624. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  81625. /**
  81626. * Loads a glTF texture info.
  81627. * @param context The context when loading the asset
  81628. * @param textureInfo The glTF texture info property
  81629. * @param assign A function called synchronously after parsing the glTF properties
  81630. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  81631. */
  81632. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81633. /** @hidden */
  81634. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81635. /** @hidden */
  81636. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81637. private _loadSampler;
  81638. /**
  81639. * Loads a glTF image.
  81640. * @param context The context when loading the asset
  81641. * @param image The glTF image property
  81642. * @returns A promise that resolves with the loaded data when the load is complete
  81643. */
  81644. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  81645. /**
  81646. * Loads a glTF uri.
  81647. * @param context The context when loading the asset
  81648. * @param property The glTF property associated with the uri
  81649. * @param uri The base64 or relative uri
  81650. * @returns A promise that resolves with the loaded data when the load is complete
  81651. */
  81652. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  81653. /**
  81654. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  81655. * @param babylonObject the Babylon object with metadata
  81656. * @param pointer the JSON pointer
  81657. */
  81658. static AddPointerMetadata(babylonObject: {
  81659. metadata: any;
  81660. }, pointer: string): void;
  81661. private static _GetTextureWrapMode;
  81662. private static _GetTextureSamplingMode;
  81663. private static _GetTypedArrayConstructor;
  81664. private static _GetTypedArray;
  81665. private static _GetNumComponents;
  81666. private static _ValidateUri;
  81667. /** @hidden */
  81668. static _GetDrawMode(context: string, mode: number | undefined): number;
  81669. private _compileMaterialsAsync;
  81670. private _compileShadowGeneratorsAsync;
  81671. private _forEachExtensions;
  81672. private _applyExtensions;
  81673. private _extensionsOnLoading;
  81674. private _extensionsOnReady;
  81675. private _extensionsLoadSceneAsync;
  81676. private _extensionsLoadNodeAsync;
  81677. private _extensionsLoadCameraAsync;
  81678. private _extensionsLoadVertexDataAsync;
  81679. private _extensionsLoadMeshPrimitiveAsync;
  81680. private _extensionsLoadMaterialAsync;
  81681. private _extensionsCreateMaterial;
  81682. private _extensionsLoadMaterialPropertiesAsync;
  81683. private _extensionsLoadTextureInfoAsync;
  81684. private _extensionsLoadTextureAsync;
  81685. private _extensionsLoadAnimationAsync;
  81686. private _extensionsLoadSkinAsync;
  81687. private _extensionsLoadUriAsync;
  81688. private _extensionsLoadBufferViewAsync;
  81689. private _extensionsLoadBufferAsync;
  81690. /**
  81691. * Helper method called by a loader extension to load an glTF extension.
  81692. * @param context The context when loading the asset
  81693. * @param property The glTF property to load the extension from
  81694. * @param extensionName The name of the extension to load
  81695. * @param actionAsync The action to run
  81696. * @returns The promise returned by actionAsync or null if the extension does not exist
  81697. */
  81698. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81699. /**
  81700. * Helper method called by a loader extension to load a glTF extra.
  81701. * @param context The context when loading the asset
  81702. * @param property The glTF property to load the extra from
  81703. * @param extensionName The name of the extension to load
  81704. * @param actionAsync The action to run
  81705. * @returns The promise returned by actionAsync or null if the extra does not exist
  81706. */
  81707. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81708. /**
  81709. * Checks for presence of an extension.
  81710. * @param name The name of the extension to check
  81711. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  81712. */
  81713. isExtensionUsed(name: string): boolean;
  81714. /**
  81715. * Increments the indentation level and logs a message.
  81716. * @param message The message to log
  81717. */
  81718. logOpen(message: string): void;
  81719. /**
  81720. * Decrements the indentation level.
  81721. */
  81722. logClose(): void;
  81723. /**
  81724. * Logs a message
  81725. * @param message The message to log
  81726. */
  81727. log(message: string): void;
  81728. /**
  81729. * Starts a performance counter.
  81730. * @param counterName The name of the performance counter
  81731. */
  81732. startPerformanceCounter(counterName: string): void;
  81733. /**
  81734. * Ends a performance counter.
  81735. * @param counterName The name of the performance counter
  81736. */
  81737. endPerformanceCounter(counterName: string): void;
  81738. }
  81739. }
  81740. declare module BABYLON.GLTF2.Loader.Extensions {
  81741. /** @hidden */
  81742. interface IEXTLightsImageBased_LightImageBased {
  81743. _babylonTexture?: BaseTexture;
  81744. _loaded?: Promise<void>;
  81745. }
  81746. /**
  81747. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  81748. */
  81749. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  81750. /**
  81751. * The name of this extension.
  81752. */
  81753. readonly name: string;
  81754. /**
  81755. * Defines whether this extension is enabled.
  81756. */
  81757. enabled: boolean;
  81758. private _loader;
  81759. private _lights?;
  81760. /** @hidden */
  81761. constructor(loader: GLTFLoader);
  81762. /** @hidden */
  81763. dispose(): void;
  81764. /** @hidden */
  81765. onLoading(): void;
  81766. /** @hidden */
  81767. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81768. private _loadLightAsync;
  81769. }
  81770. }
  81771. declare module BABYLON.GLTF2.Loader.Extensions {
  81772. /**
  81773. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  81774. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  81775. * !!! Experimental Extension Subject to Changes !!!
  81776. */
  81777. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  81778. /**
  81779. * The name of this extension.
  81780. */
  81781. readonly name: string;
  81782. /**
  81783. * Defines whether this extension is enabled.
  81784. */
  81785. enabled: boolean;
  81786. private _loader;
  81787. /** @hidden */
  81788. constructor(loader: GLTFLoader);
  81789. /** @hidden */
  81790. dispose(): void;
  81791. /** @hidden */
  81792. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81793. }
  81794. }
  81795. declare module BABYLON.GLTF2.Loader.Extensions {
  81796. /**
  81797. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  81798. */
  81799. export class EXT_texture_webp implements IGLTFLoaderExtension {
  81800. /** The name of this extension. */
  81801. readonly name: string;
  81802. /** Defines whether this extension is enabled. */
  81803. enabled: boolean;
  81804. private _loader;
  81805. /** @hidden */
  81806. constructor(loader: GLTFLoader);
  81807. /** @hidden */
  81808. dispose(): void;
  81809. /** @hidden */
  81810. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81811. }
  81812. }
  81813. declare module BABYLON.GLTF2.Loader.Extensions {
  81814. /**
  81815. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  81816. */
  81817. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  81818. /**
  81819. * The name of this extension.
  81820. */
  81821. readonly name: string;
  81822. /**
  81823. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  81824. */
  81825. dracoCompression?: DracoCompression;
  81826. /**
  81827. * Defines whether this extension is enabled.
  81828. */
  81829. enabled: boolean;
  81830. private _loader;
  81831. /** @hidden */
  81832. constructor(loader: GLTFLoader);
  81833. /** @hidden */
  81834. dispose(): void;
  81835. /** @hidden */
  81836. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81837. }
  81838. }
  81839. declare module BABYLON.GLTF2.Loader.Extensions {
  81840. /**
  81841. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  81842. */
  81843. export class KHR_lights implements IGLTFLoaderExtension {
  81844. /**
  81845. * The name of this extension.
  81846. */
  81847. readonly name: string;
  81848. /**
  81849. * Defines whether this extension is enabled.
  81850. */
  81851. enabled: boolean;
  81852. private _loader;
  81853. private _lights?;
  81854. /** @hidden */
  81855. constructor(loader: GLTFLoader);
  81856. /** @hidden */
  81857. dispose(): void;
  81858. /** @hidden */
  81859. onLoading(): void;
  81860. /** @hidden */
  81861. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81862. }
  81863. }
  81864. declare module BABYLON.GLTF2.Loader.Extensions {
  81865. /**
  81866. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  81867. */
  81868. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  81869. /**
  81870. * The name of this extension.
  81871. */
  81872. readonly name: string;
  81873. /**
  81874. * Defines whether this extension is enabled.
  81875. */
  81876. enabled: boolean;
  81877. /**
  81878. * Defines a number that determines the order the extensions are applied.
  81879. */
  81880. order: number;
  81881. private _loader;
  81882. /** @hidden */
  81883. constructor(loader: GLTFLoader);
  81884. /** @hidden */
  81885. dispose(): void;
  81886. /** @hidden */
  81887. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81888. private _loadSpecularGlossinessPropertiesAsync;
  81889. }
  81890. }
  81891. declare module BABYLON.GLTF2.Loader.Extensions {
  81892. /**
  81893. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  81894. */
  81895. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  81896. /**
  81897. * The name of this extension.
  81898. */
  81899. readonly name: string;
  81900. /**
  81901. * Defines whether this extension is enabled.
  81902. */
  81903. enabled: boolean;
  81904. /**
  81905. * Defines a number that determines the order the extensions are applied.
  81906. */
  81907. order: number;
  81908. private _loader;
  81909. /** @hidden */
  81910. constructor(loader: GLTFLoader);
  81911. /** @hidden */
  81912. dispose(): void;
  81913. /** @hidden */
  81914. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81915. private _loadUnlitPropertiesAsync;
  81916. }
  81917. }
  81918. declare module BABYLON.GLTF2.Loader.Extensions {
  81919. /**
  81920. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  81921. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  81922. * !!! Experimental Extension Subject to Changes !!!
  81923. */
  81924. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  81925. /**
  81926. * The name of this extension.
  81927. */
  81928. readonly name: string;
  81929. /**
  81930. * Defines whether this extension is enabled.
  81931. */
  81932. enabled: boolean;
  81933. /**
  81934. * Defines a number that determines the order the extensions are applied.
  81935. */
  81936. order: number;
  81937. private _loader;
  81938. /** @hidden */
  81939. constructor(loader: GLTFLoader);
  81940. /** @hidden */
  81941. dispose(): void;
  81942. /** @hidden */
  81943. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81944. private _loadClearCoatPropertiesAsync;
  81945. }
  81946. }
  81947. declare module BABYLON.GLTF2.Loader.Extensions {
  81948. /**
  81949. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  81950. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  81951. * !!! Experimental Extension Subject to Changes !!!
  81952. */
  81953. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  81954. /**
  81955. * The name of this extension.
  81956. */
  81957. readonly name: string;
  81958. /**
  81959. * Defines whether this extension is enabled.
  81960. */
  81961. enabled: boolean;
  81962. /**
  81963. * Defines a number that determines the order the extensions are applied.
  81964. */
  81965. order: number;
  81966. private _loader;
  81967. /** @hidden */
  81968. constructor(loader: GLTFLoader);
  81969. /** @hidden */
  81970. dispose(): void;
  81971. /** @hidden */
  81972. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81973. private _loadSheenPropertiesAsync;
  81974. }
  81975. }
  81976. declare module BABYLON.GLTF2.Loader.Extensions {
  81977. /**
  81978. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  81979. * !!! Experimental Extension Subject to Changes !!!
  81980. */
  81981. export class KHR_materials_specular implements IGLTFLoaderExtension {
  81982. /**
  81983. * The name of this extension.
  81984. */
  81985. readonly name: string;
  81986. /**
  81987. * Defines whether this extension is enabled.
  81988. */
  81989. enabled: boolean;
  81990. /**
  81991. * Defines a number that determines the order the extensions are applied.
  81992. */
  81993. order: number;
  81994. private _loader;
  81995. /** @hidden */
  81996. constructor(loader: GLTFLoader);
  81997. /** @hidden */
  81998. dispose(): void;
  81999. /** @hidden */
  82000. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82001. private _loadSpecularPropertiesAsync;
  82002. }
  82003. }
  82004. declare module BABYLON.GLTF2.Loader.Extensions {
  82005. /**
  82006. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82007. * !!! Experimental Extension Subject to Changes !!!
  82008. */
  82009. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82010. /**
  82011. * Default ior Value from the spec.
  82012. */
  82013. private static readonly _DEFAULT_IOR;
  82014. /**
  82015. * The name of this extension.
  82016. */
  82017. readonly name: string;
  82018. /**
  82019. * Defines whether this extension is enabled.
  82020. */
  82021. enabled: boolean;
  82022. /**
  82023. * Defines a number that determines the order the extensions are applied.
  82024. */
  82025. order: number;
  82026. private _loader;
  82027. /** @hidden */
  82028. constructor(loader: GLTFLoader);
  82029. /** @hidden */
  82030. dispose(): void;
  82031. /** @hidden */
  82032. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82033. private _loadIorPropertiesAsync;
  82034. }
  82035. }
  82036. declare module BABYLON.GLTF2.Loader.Extensions {
  82037. /**
  82038. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82039. * !!! Experimental Extension Subject to Changes !!!
  82040. */
  82041. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82042. /**
  82043. * The name of this extension.
  82044. */
  82045. readonly name: string;
  82046. /**
  82047. * Defines whether this extension is enabled.
  82048. */
  82049. enabled: boolean;
  82050. private _loader;
  82051. private _variants?;
  82052. /** @hidden */
  82053. constructor(loader: GLTFLoader);
  82054. /** @hidden */
  82055. dispose(): void;
  82056. /**
  82057. * Gets the list of available variant names for this asset.
  82058. * @param rootMesh The glTF root mesh
  82059. * @returns the list of all the variant names for this model
  82060. */
  82061. static GetAvailableVariants(rootMesh: Mesh): string[];
  82062. /**
  82063. * Gets the list of available variant names for this asset.
  82064. * @param rootMesh The glTF root mesh
  82065. * @returns the list of all the variant names for this model
  82066. */
  82067. getAvailableVariants(rootMesh: Mesh): string[];
  82068. /**
  82069. * Select a variant given a variant name or a list of variant names.
  82070. * @param rootMesh The glTF root mesh
  82071. * @param variantName The variant name(s) to select.
  82072. */
  82073. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82074. /**
  82075. * Select a variant given a variant name or a list of variant names.
  82076. * @param rootMesh The glTF root mesh
  82077. * @param variantName The variant name(s) to select.
  82078. */
  82079. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82080. /**
  82081. * Reset back to the original before selecting a variant.
  82082. * @param rootMesh The glTF root mesh
  82083. */
  82084. static Reset(rootMesh: Mesh): void;
  82085. /**
  82086. * Reset back to the original before selecting a variant.
  82087. * @param rootMesh The glTF root mesh
  82088. */
  82089. reset(rootMesh: Mesh): void;
  82090. /**
  82091. * Gets the last selected variant name(s) or null if original.
  82092. * @param rootMesh The glTF root mesh
  82093. * @returns The selected variant name(s).
  82094. */
  82095. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82096. /**
  82097. * Gets the last selected variant name(s) or null if original.
  82098. * @param rootMesh The glTF root mesh
  82099. * @returns The selected variant name(s).
  82100. */
  82101. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82102. private static _GetExtensionMetadata;
  82103. /** @hidden */
  82104. onLoading(): void;
  82105. /** @hidden */
  82106. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82107. }
  82108. }
  82109. declare module BABYLON.GLTF2.Loader.Extensions {
  82110. /**
  82111. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82112. * !!! Experimental Extension Subject to Changes !!!
  82113. */
  82114. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82115. /**
  82116. * The name of this extension.
  82117. */
  82118. readonly name: string;
  82119. /**
  82120. * Defines whether this extension is enabled.
  82121. */
  82122. enabled: boolean;
  82123. /**
  82124. * Defines a number that determines the order the extensions are applied.
  82125. */
  82126. order: number;
  82127. private _loader;
  82128. /** @hidden */
  82129. constructor(loader: GLTFLoader);
  82130. /** @hidden */
  82131. dispose(): void;
  82132. /** @hidden */
  82133. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82134. private _loadTransparentPropertiesAsync;
  82135. }
  82136. }
  82137. declare module BABYLON.GLTF2.Loader.Extensions {
  82138. /**
  82139. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82140. */
  82141. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82142. /**
  82143. * The name of this extension.
  82144. */
  82145. readonly name: string;
  82146. /**
  82147. * Defines whether this extension is enabled.
  82148. */
  82149. enabled: boolean;
  82150. /** @hidden */
  82151. constructor(loader: GLTFLoader);
  82152. /** @hidden */
  82153. dispose(): void;
  82154. }
  82155. }
  82156. declare module BABYLON.GLTF2.Loader.Extensions {
  82157. /**
  82158. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82159. * !!! Experimental Extension Subject to Changes !!!
  82160. */
  82161. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82162. /** The name of this extension. */
  82163. readonly name: string;
  82164. /** Defines whether this extension is enabled. */
  82165. enabled: boolean;
  82166. private _loader;
  82167. /** @hidden */
  82168. constructor(loader: GLTFLoader);
  82169. /** @hidden */
  82170. dispose(): void;
  82171. /** @hidden */
  82172. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82173. }
  82174. }
  82175. declare module BABYLON.GLTF2.Loader.Extensions {
  82176. /**
  82177. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  82178. */
  82179. export class KHR_texture_transform implements IGLTFLoaderExtension {
  82180. /**
  82181. * The name of this extension.
  82182. */
  82183. readonly name: string;
  82184. /**
  82185. * Defines whether this extension is enabled.
  82186. */
  82187. enabled: boolean;
  82188. private _loader;
  82189. /** @hidden */
  82190. constructor(loader: GLTFLoader);
  82191. /** @hidden */
  82192. dispose(): void;
  82193. /** @hidden */
  82194. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82195. }
  82196. }
  82197. declare module BABYLON.GLTF2.Loader.Extensions {
  82198. /**
  82199. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  82200. * !!! Experimental Extension Subject to Changes !!!
  82201. */
  82202. export class KHR_xmp implements IGLTFLoaderExtension {
  82203. /**
  82204. * The name of this extension.
  82205. */
  82206. readonly name: string;
  82207. /**
  82208. * Defines whether this extension is enabled.
  82209. */
  82210. enabled: boolean;
  82211. /**
  82212. * Defines a number that determines the order the extensions are applied.
  82213. */
  82214. order: number;
  82215. private _loader;
  82216. /** @hidden */
  82217. constructor(loader: GLTFLoader);
  82218. /** @hidden */
  82219. dispose(): void;
  82220. /**
  82221. * Called after the loader state changes to LOADING.
  82222. */
  82223. onLoading(): void;
  82224. }
  82225. }
  82226. declare module BABYLON.GLTF2.Loader.Extensions {
  82227. /**
  82228. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  82229. */
  82230. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  82231. /**
  82232. * The name of this extension.
  82233. */
  82234. readonly name: string;
  82235. /**
  82236. * Defines whether this extension is enabled.
  82237. */
  82238. enabled: boolean;
  82239. private _loader;
  82240. private _clips;
  82241. private _emitters;
  82242. /** @hidden */
  82243. constructor(loader: GLTFLoader);
  82244. /** @hidden */
  82245. dispose(): void;
  82246. /** @hidden */
  82247. onLoading(): void;
  82248. /** @hidden */
  82249. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82250. /** @hidden */
  82251. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82252. /** @hidden */
  82253. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82254. private _loadClipAsync;
  82255. private _loadEmitterAsync;
  82256. private _getEventAction;
  82257. private _loadAnimationEventAsync;
  82258. }
  82259. }
  82260. declare module BABYLON.GLTF2.Loader.Extensions {
  82261. /**
  82262. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  82263. */
  82264. export class MSFT_lod implements IGLTFLoaderExtension {
  82265. /**
  82266. * The name of this extension.
  82267. */
  82268. readonly name: string;
  82269. /**
  82270. * Defines whether this extension is enabled.
  82271. */
  82272. enabled: boolean;
  82273. /**
  82274. * Defines a number that determines the order the extensions are applied.
  82275. */
  82276. order: number;
  82277. /**
  82278. * Maximum number of LODs to load, starting from the lowest LOD.
  82279. */
  82280. maxLODsToLoad: number;
  82281. /**
  82282. * Observable raised when all node LODs of one level are loaded.
  82283. * The event data is the index of the loaded LOD starting from zero.
  82284. * Dispose the loader to cancel the loading of the next level of LODs.
  82285. */
  82286. onNodeLODsLoadedObservable: Observable<number>;
  82287. /**
  82288. * Observable raised when all material LODs of one level are loaded.
  82289. * The event data is the index of the loaded LOD starting from zero.
  82290. * Dispose the loader to cancel the loading of the next level of LODs.
  82291. */
  82292. onMaterialLODsLoadedObservable: Observable<number>;
  82293. private _loader;
  82294. private _bufferLODs;
  82295. private _nodeIndexLOD;
  82296. private _nodeSignalLODs;
  82297. private _nodePromiseLODs;
  82298. private _nodeBufferLODs;
  82299. private _materialIndexLOD;
  82300. private _materialSignalLODs;
  82301. private _materialPromiseLODs;
  82302. private _materialBufferLODs;
  82303. /** @hidden */
  82304. constructor(loader: GLTFLoader);
  82305. /** @hidden */
  82306. dispose(): void;
  82307. /** @hidden */
  82308. onReady(): void;
  82309. /** @hidden */
  82310. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82311. /** @hidden */
  82312. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82313. /** @hidden */
  82314. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82315. /** @hidden */
  82316. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82317. /** @hidden */
  82318. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82319. private _loadBufferLOD;
  82320. /**
  82321. * Gets an array of LOD properties from lowest to highest.
  82322. */
  82323. private _getLODs;
  82324. private _disposeTransformNode;
  82325. private _disposeMaterials;
  82326. }
  82327. }
  82328. declare module BABYLON.GLTF2.Loader.Extensions {
  82329. /** @hidden */
  82330. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  82331. readonly name: string;
  82332. enabled: boolean;
  82333. private _loader;
  82334. constructor(loader: GLTFLoader);
  82335. dispose(): void;
  82336. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82337. }
  82338. }
  82339. declare module BABYLON.GLTF2.Loader.Extensions {
  82340. /** @hidden */
  82341. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  82342. readonly name: string;
  82343. enabled: boolean;
  82344. private _loader;
  82345. constructor(loader: GLTFLoader);
  82346. dispose(): void;
  82347. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82348. }
  82349. }
  82350. declare module BABYLON.GLTF2.Loader.Extensions {
  82351. /**
  82352. * Store glTF extras (if present) in BJS objects' metadata
  82353. */
  82354. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  82355. /**
  82356. * The name of this extension.
  82357. */
  82358. readonly name: string;
  82359. /**
  82360. * Defines whether this extension is enabled.
  82361. */
  82362. enabled: boolean;
  82363. private _loader;
  82364. private _assignExtras;
  82365. /** @hidden */
  82366. constructor(loader: GLTFLoader);
  82367. /** @hidden */
  82368. dispose(): void;
  82369. /** @hidden */
  82370. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82371. /** @hidden */
  82372. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82373. /** @hidden */
  82374. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82375. }
  82376. }
  82377. declare module BABYLON {
  82378. /**
  82379. * Class reading and parsing the MTL file bundled with the obj file.
  82380. */
  82381. export class MTLFileLoader {
  82382. /**
  82383. * Invert Y-Axis of referenced textures on load
  82384. */
  82385. static INVERT_TEXTURE_Y: boolean;
  82386. /**
  82387. * All material loaded from the mtl will be set here
  82388. */
  82389. materials: StandardMaterial[];
  82390. /**
  82391. * This function will read the mtl file and create each material described inside
  82392. * This function could be improve by adding :
  82393. * -some component missing (Ni, Tf...)
  82394. * -including the specific options available
  82395. *
  82396. * @param scene defines the scene the material will be created in
  82397. * @param data defines the mtl data to parse
  82398. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  82399. * @param forAssetContainer defines if the material should be registered in the scene
  82400. */
  82401. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  82402. /**
  82403. * Gets the texture for the material.
  82404. *
  82405. * If the material is imported from input file,
  82406. * We sanitize the url to ensure it takes the textre from aside the material.
  82407. *
  82408. * @param rootUrl The root url to load from
  82409. * @param value The value stored in the mtl
  82410. * @return The Texture
  82411. */
  82412. private static _getTexture;
  82413. }
  82414. }
  82415. declare module BABYLON {
  82416. /**
  82417. * Options for loading OBJ/MTL files
  82418. */
  82419. type MeshLoadOptions = {
  82420. /**
  82421. * Defines if UVs are optimized by default during load.
  82422. */
  82423. OptimizeWithUV: boolean;
  82424. /**
  82425. * Defines custom scaling of UV coordinates of loaded meshes.
  82426. */
  82427. UVScaling: Vector2;
  82428. /**
  82429. * Invert model on y-axis (does a model scaling inversion)
  82430. */
  82431. InvertY: boolean;
  82432. /**
  82433. * Invert Y-Axis of referenced textures on load
  82434. */
  82435. InvertTextureY: boolean;
  82436. /**
  82437. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82438. */
  82439. ImportVertexColors: boolean;
  82440. /**
  82441. * Compute the normals for the model, even if normals are present in the file.
  82442. */
  82443. ComputeNormals: boolean;
  82444. /**
  82445. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82446. */
  82447. SkipMaterials: boolean;
  82448. /**
  82449. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82450. */
  82451. MaterialLoadingFailsSilently: boolean;
  82452. };
  82453. /**
  82454. * OBJ file type loader.
  82455. * This is a babylon scene loader plugin.
  82456. */
  82457. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82458. /**
  82459. * Defines if UVs are optimized by default during load.
  82460. */
  82461. static OPTIMIZE_WITH_UV: boolean;
  82462. /**
  82463. * Invert model on y-axis (does a model scaling inversion)
  82464. */
  82465. static INVERT_Y: boolean;
  82466. /**
  82467. * Invert Y-Axis of referenced textures on load
  82468. */
  82469. static get INVERT_TEXTURE_Y(): boolean;
  82470. static set INVERT_TEXTURE_Y(value: boolean);
  82471. /**
  82472. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82473. */
  82474. static IMPORT_VERTEX_COLORS: boolean;
  82475. /**
  82476. * Compute the normals for the model, even if normals are present in the file.
  82477. */
  82478. static COMPUTE_NORMALS: boolean;
  82479. /**
  82480. * Defines custom scaling of UV coordinates of loaded meshes.
  82481. */
  82482. static UV_SCALING: Vector2;
  82483. /**
  82484. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82485. */
  82486. static SKIP_MATERIALS: boolean;
  82487. /**
  82488. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82489. *
  82490. * Defaults to true for backwards compatibility.
  82491. */
  82492. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  82493. /**
  82494. * Defines the name of the plugin.
  82495. */
  82496. name: string;
  82497. /**
  82498. * Defines the extension the plugin is able to load.
  82499. */
  82500. extensions: string;
  82501. /** @hidden */
  82502. obj: RegExp;
  82503. /** @hidden */
  82504. group: RegExp;
  82505. /** @hidden */
  82506. mtllib: RegExp;
  82507. /** @hidden */
  82508. usemtl: RegExp;
  82509. /** @hidden */
  82510. smooth: RegExp;
  82511. /** @hidden */
  82512. vertexPattern: RegExp;
  82513. /** @hidden */
  82514. normalPattern: RegExp;
  82515. /** @hidden */
  82516. uvPattern: RegExp;
  82517. /** @hidden */
  82518. facePattern1: RegExp;
  82519. /** @hidden */
  82520. facePattern2: RegExp;
  82521. /** @hidden */
  82522. facePattern3: RegExp;
  82523. /** @hidden */
  82524. facePattern4: RegExp;
  82525. /** @hidden */
  82526. facePattern5: RegExp;
  82527. private _forAssetContainer;
  82528. private _meshLoadOptions;
  82529. /**
  82530. * Creates loader for .OBJ files
  82531. *
  82532. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  82533. */
  82534. constructor(meshLoadOptions?: MeshLoadOptions);
  82535. private static get currentMeshLoadOptions();
  82536. /**
  82537. * Calls synchronously the MTL file attached to this obj.
  82538. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  82539. * Without this function materials are not displayed in the first frame (but displayed after).
  82540. * In consequence it is impossible to get material information in your HTML file
  82541. *
  82542. * @param url The URL of the MTL file
  82543. * @param rootUrl
  82544. * @param onSuccess Callback function to be called when the MTL file is loaded
  82545. * @private
  82546. */
  82547. private _loadMTL;
  82548. /**
  82549. * Instantiates a OBJ file loader plugin.
  82550. * @returns the created plugin
  82551. */
  82552. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  82553. /**
  82554. * If the data string can be loaded directly.
  82555. *
  82556. * @param data string containing the file data
  82557. * @returns if the data can be loaded directly
  82558. */
  82559. canDirectLoad(data: string): boolean;
  82560. /**
  82561. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  82562. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82563. * @param scene the scene the meshes should be added to
  82564. * @param data the OBJ data to load
  82565. * @param rootUrl root url to load from
  82566. * @param onProgress event that fires when loading progress has occured
  82567. * @param fileName Defines the name of the file to load
  82568. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82569. */
  82570. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82571. meshes: AbstractMesh[];
  82572. particleSystems: IParticleSystem[];
  82573. skeletons: Skeleton[];
  82574. animationGroups: AnimationGroup[];
  82575. }>;
  82576. /**
  82577. * Imports all objects from the loaded OBJ data and adds them to the scene
  82578. * @param scene the scene the objects should be added to
  82579. * @param data the OBJ data to load
  82580. * @param rootUrl root url to load from
  82581. * @param onProgress event that fires when loading progress has occured
  82582. * @param fileName Defines the name of the file to load
  82583. * @returns a promise which completes when objects have been loaded to the scene
  82584. */
  82585. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82586. /**
  82587. * Load into an asset container.
  82588. * @param scene The scene to load into
  82589. * @param data The data to import
  82590. * @param rootUrl The root url for scene and resources
  82591. * @param onProgress The callback when the load progresses
  82592. * @param fileName Defines the name of the file to load
  82593. * @returns The loaded asset container
  82594. */
  82595. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82596. /**
  82597. * Read the OBJ file and create an Array of meshes.
  82598. * Each mesh contains all information given by the OBJ and the MTL file.
  82599. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  82600. *
  82601. * @param meshesNames
  82602. * @param scene Scene The scene where are displayed the data
  82603. * @param data String The content of the obj file
  82604. * @param rootUrl String The path to the folder
  82605. * @returns Array<AbstractMesh>
  82606. * @private
  82607. */
  82608. private _parseSolid;
  82609. }
  82610. }
  82611. declare module BABYLON {
  82612. /**
  82613. * STL file type loader.
  82614. * This is a babylon scene loader plugin.
  82615. */
  82616. export class STLFileLoader implements ISceneLoaderPlugin {
  82617. /** @hidden */
  82618. solidPattern: RegExp;
  82619. /** @hidden */
  82620. facetsPattern: RegExp;
  82621. /** @hidden */
  82622. normalPattern: RegExp;
  82623. /** @hidden */
  82624. vertexPattern: RegExp;
  82625. /**
  82626. * Defines the name of the plugin.
  82627. */
  82628. name: string;
  82629. /**
  82630. * Defines the extensions the stl loader is able to load.
  82631. * force data to come in as an ArrayBuffer
  82632. * we'll convert to string if it looks like it's an ASCII .stl
  82633. */
  82634. extensions: ISceneLoaderPluginExtensions;
  82635. /**
  82636. * Import meshes into a scene.
  82637. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  82638. * @param scene The scene to import into
  82639. * @param data The data to import
  82640. * @param rootUrl The root url for scene and resources
  82641. * @param meshes The meshes array to import into
  82642. * @param particleSystems The particle systems array to import into
  82643. * @param skeletons The skeletons array to import into
  82644. * @param onError The callback when import fails
  82645. * @returns True if successful or false otherwise
  82646. */
  82647. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  82648. /**
  82649. * Load into a scene.
  82650. * @param scene The scene to load into
  82651. * @param data The data to import
  82652. * @param rootUrl The root url for scene and resources
  82653. * @param onError The callback when import fails
  82654. * @returns true if successful or false otherwise
  82655. */
  82656. load(scene: Scene, data: any, rootUrl: string): boolean;
  82657. /**
  82658. * Load into an asset container.
  82659. * @param scene The scene to load into
  82660. * @param data The data to import
  82661. * @param rootUrl The root url for scene and resources
  82662. * @param onError The callback when import fails
  82663. * @returns The loaded asset container
  82664. */
  82665. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  82666. private _isBinary;
  82667. private _parseBinary;
  82668. private _parseASCII;
  82669. }
  82670. }
  82671. declare module BABYLON {
  82672. /**
  82673. * Class for generating OBJ data from a Babylon scene.
  82674. */
  82675. export class OBJExport {
  82676. /**
  82677. * Exports the geometry of a Mesh array in .OBJ file format (text)
  82678. * @param mesh defines the list of meshes to serialize
  82679. * @param materials defines if materials should be exported
  82680. * @param matlibname defines the name of the associated mtl file
  82681. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  82682. * @returns the OBJ content
  82683. */
  82684. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  82685. /**
  82686. * Exports the material(s) of a mesh in .MTL file format (text)
  82687. * @param mesh defines the mesh to extract the material from
  82688. * @returns the mtl content
  82689. */
  82690. static MTL(mesh: Mesh): string;
  82691. }
  82692. }
  82693. declare module BABYLON {
  82694. /** @hidden */
  82695. export var __IGLTFExporterExtension: number;
  82696. /**
  82697. * Interface for extending the exporter
  82698. * @hidden
  82699. */
  82700. export interface IGLTFExporterExtension {
  82701. /**
  82702. * The name of this extension
  82703. */
  82704. readonly name: string;
  82705. /**
  82706. * Defines whether this extension is enabled
  82707. */
  82708. enabled: boolean;
  82709. /**
  82710. * Defines whether this extension is required
  82711. */
  82712. required: boolean;
  82713. }
  82714. }
  82715. declare module BABYLON.GLTF2.Exporter {
  82716. /** @hidden */
  82717. export var __IGLTFExporterExtensionV2: number;
  82718. /**
  82719. * Interface for a glTF exporter extension
  82720. * @hidden
  82721. */
  82722. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  82723. /**
  82724. * Define this method to modify the default behavior before exporting a texture
  82725. * @param context The context when loading the asset
  82726. * @param babylonTexture The Babylon.js texture
  82727. * @param mimeType The mime-type of the generated image
  82728. * @returns A promise that resolves with the exported texture
  82729. */
  82730. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  82731. /**
  82732. * Define this method to get notified when a texture info is created
  82733. * @param context The context when loading the asset
  82734. * @param textureInfo The glTF texture info
  82735. * @param babylonTexture The Babylon.js texture
  82736. */
  82737. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82738. /**
  82739. * Define this method to modify the default behavior when exporting texture info
  82740. * @param context The context when loading the asset
  82741. * @param meshPrimitive glTF mesh primitive
  82742. * @param babylonSubMesh Babylon submesh
  82743. * @param binaryWriter glTF serializer binary writer instance
  82744. * @returns nullable IMeshPrimitive promise
  82745. */
  82746. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  82747. /**
  82748. * Define this method to modify the default behavior when exporting a node
  82749. * @param context The context when exporting the node
  82750. * @param node glTF node
  82751. * @param babylonNode BabylonJS node
  82752. * @returns nullable INode promise
  82753. */
  82754. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82755. [key: number]: number;
  82756. }): Promise<Nullable<INode>>;
  82757. /**
  82758. * Define this method to modify the default behavior when exporting a material
  82759. * @param material glTF material
  82760. * @param babylonMaterial BabylonJS material
  82761. * @returns nullable IMaterial promise
  82762. */
  82763. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  82764. /**
  82765. * Define this method to return additional textures to export from a material
  82766. * @param material glTF material
  82767. * @param babylonMaterial BabylonJS material
  82768. * @returns List of textures
  82769. */
  82770. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82771. /** Gets a boolean indicating that this extension was used */
  82772. wasUsed: boolean;
  82773. /** Gets a boolean indicating that this extension is required for the file to work */
  82774. required: boolean;
  82775. /**
  82776. * Called after the exporter state changes to EXPORTING
  82777. */
  82778. onExporting?(): void;
  82779. }
  82780. }
  82781. declare module BABYLON.GLTF2.Exporter {
  82782. /**
  82783. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  82784. * @hidden
  82785. */
  82786. export class _GLTFMaterialExporter {
  82787. /**
  82788. * Represents the dielectric specular values for R, G and B
  82789. */
  82790. private static readonly _DielectricSpecular;
  82791. /**
  82792. * Allows the maximum specular power to be defined for material calculations
  82793. */
  82794. private static readonly _MaxSpecularPower;
  82795. /**
  82796. * Mapping to store textures
  82797. */
  82798. private _textureMap;
  82799. /**
  82800. * Numeric tolerance value
  82801. */
  82802. private static readonly _Epsilon;
  82803. /**
  82804. * Reference to the glTF Exporter
  82805. */
  82806. private _exporter;
  82807. constructor(exporter: _Exporter);
  82808. /**
  82809. * Specifies if two colors are approximately equal in value
  82810. * @param color1 first color to compare to
  82811. * @param color2 second color to compare to
  82812. * @param epsilon threshold value
  82813. */
  82814. private static FuzzyEquals;
  82815. /**
  82816. * Gets the materials from a Babylon scene and converts them to glTF materials
  82817. * @param scene babylonjs scene
  82818. * @param mimeType texture mime type
  82819. * @param images array of images
  82820. * @param textures array of textures
  82821. * @param materials array of materials
  82822. * @param imageData mapping of texture names to base64 textures
  82823. * @param hasTextureCoords specifies if texture coordinates are present on the material
  82824. */
  82825. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  82826. /**
  82827. * Makes a copy of the glTF material without the texture parameters
  82828. * @param originalMaterial original glTF material
  82829. * @returns glTF material without texture parameters
  82830. */
  82831. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  82832. /**
  82833. * Specifies if the material has any texture parameters present
  82834. * @param material glTF Material
  82835. * @returns boolean specifying if texture parameters are present
  82836. */
  82837. _hasTexturesPresent(material: IMaterial): boolean;
  82838. /**
  82839. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  82840. * @param babylonStandardMaterial
  82841. * @returns glTF Metallic Roughness Material representation
  82842. */
  82843. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  82844. /**
  82845. * Computes the metallic factor
  82846. * @param diffuse diffused value
  82847. * @param specular specular value
  82848. * @param oneMinusSpecularStrength one minus the specular strength
  82849. * @returns metallic value
  82850. */
  82851. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  82852. /**
  82853. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  82854. * @param glTFMaterial glTF material
  82855. * @param babylonMaterial Babylon material
  82856. */
  82857. private static _SetAlphaMode;
  82858. /**
  82859. * Converts a Babylon Standard Material to a glTF Material
  82860. * @param babylonStandardMaterial BJS Standard Material
  82861. * @param mimeType mime type to use for the textures
  82862. * @param images array of glTF image interfaces
  82863. * @param textures array of glTF texture interfaces
  82864. * @param materials array of glTF material interfaces
  82865. * @param imageData map of image file name to data
  82866. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82867. */
  82868. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82869. private _finishMaterial;
  82870. /**
  82871. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82872. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  82873. * @param mimeType mime type to use for the textures
  82874. * @param images array of glTF image interfaces
  82875. * @param textures array of glTF texture interfaces
  82876. * @param materials array of glTF material interfaces
  82877. * @param imageData map of image file name to data
  82878. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82879. */
  82880. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82881. /**
  82882. * Converts an image typed array buffer to a base64 image
  82883. * @param buffer typed array buffer
  82884. * @param width width of the image
  82885. * @param height height of the image
  82886. * @param mimeType mimetype of the image
  82887. * @returns base64 image string
  82888. */
  82889. private _createBase64FromCanvasAsync;
  82890. /**
  82891. * Generates a white texture based on the specified width and height
  82892. * @param width width of the texture in pixels
  82893. * @param height height of the texture in pixels
  82894. * @param scene babylonjs scene
  82895. * @returns white texture
  82896. */
  82897. private _createWhiteTexture;
  82898. /**
  82899. * 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
  82900. * @param texture1 first texture to resize
  82901. * @param texture2 second texture to resize
  82902. * @param scene babylonjs scene
  82903. * @returns resized textures or null
  82904. */
  82905. private _resizeTexturesToSameDimensions;
  82906. /**
  82907. * Converts an array of pixels to a Float32Array
  82908. * Throws an error if the pixel format is not supported
  82909. * @param pixels - array buffer containing pixel values
  82910. * @returns Float32 of pixels
  82911. */
  82912. private _convertPixelArrayToFloat32;
  82913. /**
  82914. * Convert Specular Glossiness Textures to Metallic Roughness
  82915. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  82916. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  82917. * @param diffuseTexture texture used to store diffuse information
  82918. * @param specularGlossinessTexture texture used to store specular and glossiness information
  82919. * @param factors specular glossiness material factors
  82920. * @param mimeType the mime type to use for the texture
  82921. * @returns pbr metallic roughness interface or null
  82922. */
  82923. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  82924. /**
  82925. * Converts specular glossiness material properties to metallic roughness
  82926. * @param specularGlossiness interface with specular glossiness material properties
  82927. * @returns interface with metallic roughness material properties
  82928. */
  82929. private _convertSpecularGlossinessToMetallicRoughness;
  82930. /**
  82931. * Calculates the surface reflectance, independent of lighting conditions
  82932. * @param color Color source to calculate brightness from
  82933. * @returns number representing the perceived brightness, or zero if color is undefined
  82934. */
  82935. private _getPerceivedBrightness;
  82936. /**
  82937. * Returns the maximum color component value
  82938. * @param color
  82939. * @returns maximum color component value, or zero if color is null or undefined
  82940. */
  82941. private _getMaxComponent;
  82942. /**
  82943. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  82944. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82945. * @param mimeType mime type to use for the textures
  82946. * @param images array of glTF image interfaces
  82947. * @param textures array of glTF texture interfaces
  82948. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82949. * @param imageData map of image file name to data
  82950. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82951. * @returns glTF PBR Metallic Roughness factors
  82952. */
  82953. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  82954. private _getGLTFTextureSampler;
  82955. private _getGLTFTextureWrapMode;
  82956. private _getGLTFTextureWrapModesSampler;
  82957. /**
  82958. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  82959. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82960. * @param mimeType mime type to use for the textures
  82961. * @param images array of glTF image interfaces
  82962. * @param textures array of glTF texture interfaces
  82963. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82964. * @param imageData map of image file name to data
  82965. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82966. * @returns glTF PBR Metallic Roughness factors
  82967. */
  82968. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  82969. /**
  82970. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82971. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82972. * @param mimeType mime type to use for the textures
  82973. * @param images array of glTF image interfaces
  82974. * @param textures array of glTF texture interfaces
  82975. * @param materials array of glTF material interfaces
  82976. * @param imageData map of image file name to data
  82977. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82978. */
  82979. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82980. private setMetallicRoughnessPbrMaterial;
  82981. private getPixelsFromTexture;
  82982. /**
  82983. * Extracts a texture from a Babylon texture into file data and glTF data
  82984. * @param babylonTexture Babylon texture to extract
  82985. * @param mimeType Mime Type of the babylonTexture
  82986. * @return glTF texture info, or null if the texture format is not supported
  82987. */
  82988. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82989. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82990. /**
  82991. * Builds a texture from base64 string
  82992. * @param base64Texture base64 texture string
  82993. * @param baseTextureName Name to use for the texture
  82994. * @param mimeType image mime type for the texture
  82995. * @param images array of images
  82996. * @param textures array of textures
  82997. * @param imageData map of image data
  82998. * @returns glTF texture info, or null if the texture format is not supported
  82999. */
  83000. private _getTextureInfoFromBase64;
  83001. }
  83002. }
  83003. declare module BABYLON {
  83004. /**
  83005. * Class for holding and downloading glTF file data
  83006. */
  83007. export class GLTFData {
  83008. /**
  83009. * Object which contains the file name as the key and its data as the value
  83010. */
  83011. glTFFiles: {
  83012. [fileName: string]: string | Blob;
  83013. };
  83014. /**
  83015. * Initializes the glTF file object
  83016. */
  83017. constructor();
  83018. /**
  83019. * Downloads the glTF data as files based on their names and data
  83020. */
  83021. downloadFiles(): void;
  83022. }
  83023. }
  83024. declare module BABYLON {
  83025. /**
  83026. * Holds a collection of exporter options and parameters
  83027. */
  83028. export interface IExportOptions {
  83029. /**
  83030. * Function which indicates whether a babylon node should be exported or not
  83031. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83032. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83033. */
  83034. shouldExportNode?(node: Node): boolean;
  83035. /**
  83036. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83037. * @param metadata source metadata to read from
  83038. * @returns the data to store to glTF node extras
  83039. */
  83040. metadataSelector?(metadata: any): any;
  83041. /**
  83042. * The sample rate to bake animation curves
  83043. */
  83044. animationSampleRate?: number;
  83045. /**
  83046. * Begin serialization without waiting for the scene to be ready
  83047. */
  83048. exportWithoutWaitingForScene?: boolean;
  83049. /**
  83050. * Indicates if coordinate system swapping root nodes should be included in export
  83051. */
  83052. includeCoordinateSystemConversionNodes?: boolean;
  83053. }
  83054. /**
  83055. * Class for generating glTF data from a Babylon scene.
  83056. */
  83057. export class GLTF2Export {
  83058. /**
  83059. * Exports the geometry of the scene to .gltf file format asynchronously
  83060. * @param scene Babylon scene with scene hierarchy information
  83061. * @param filePrefix File prefix to use when generating the glTF file
  83062. * @param options Exporter options
  83063. * @returns Returns an object with a .gltf file and associates texture names
  83064. * as keys and their data and paths as values
  83065. */
  83066. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83067. private static _PreExportAsync;
  83068. private static _PostExportAsync;
  83069. /**
  83070. * Exports the geometry of the scene to .glb file format asychronously
  83071. * @param scene Babylon scene with scene hierarchy information
  83072. * @param filePrefix File prefix to use when generating glb file
  83073. * @param options Exporter options
  83074. * @returns Returns an object with a .glb filename as key and data as value
  83075. */
  83076. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83077. }
  83078. }
  83079. declare module BABYLON.GLTF2.Exporter {
  83080. /**
  83081. * @hidden
  83082. */
  83083. export class _GLTFUtilities {
  83084. /**
  83085. * Creates a buffer view based on the supplied arguments
  83086. * @param bufferIndex index value of the specified buffer
  83087. * @param byteOffset byte offset value
  83088. * @param byteLength byte length of the bufferView
  83089. * @param byteStride byte distance between conequential elements
  83090. * @param name name of the buffer view
  83091. * @returns bufferView for glTF
  83092. */
  83093. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83094. /**
  83095. * Creates an accessor based on the supplied arguments
  83096. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83097. * @param name The name of the accessor
  83098. * @param type The type of the accessor
  83099. * @param componentType The datatype of components in the attribute
  83100. * @param count The number of attributes referenced by this accessor
  83101. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83102. * @param min Minimum value of each component in this attribute
  83103. * @param max Maximum value of each component in this attribute
  83104. * @returns accessor for glTF
  83105. */
  83106. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83107. /**
  83108. * Calculates the minimum and maximum values of an array of position floats
  83109. * @param positions Positions array of a mesh
  83110. * @param vertexStart Starting vertex offset to calculate min and max values
  83111. * @param vertexCount Number of vertices to check for min and max values
  83112. * @returns min number array and max number array
  83113. */
  83114. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83115. min: number[];
  83116. max: number[];
  83117. };
  83118. /**
  83119. * Converts a new right-handed Vector3
  83120. * @param vector vector3 array
  83121. * @returns right-handed Vector3
  83122. */
  83123. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83124. /**
  83125. * Converts a Vector3 to right-handed
  83126. * @param vector Vector3 to convert to right-handed
  83127. */
  83128. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83129. /**
  83130. * Converts a three element number array to right-handed
  83131. * @param vector number array to convert to right-handed
  83132. */
  83133. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83134. /**
  83135. * Converts a new right-handed Vector3
  83136. * @param vector vector3 array
  83137. * @returns right-handed Vector3
  83138. */
  83139. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83140. /**
  83141. * Converts a Vector3 to right-handed
  83142. * @param vector Vector3 to convert to right-handed
  83143. */
  83144. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83145. /**
  83146. * Converts a three element number array to right-handed
  83147. * @param vector number array to convert to right-handed
  83148. */
  83149. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83150. /**
  83151. * Converts a Vector4 to right-handed
  83152. * @param vector Vector4 to convert to right-handed
  83153. */
  83154. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83155. /**
  83156. * Converts a Vector4 to right-handed
  83157. * @param vector Vector4 to convert to right-handed
  83158. */
  83159. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83160. /**
  83161. * Converts a Quaternion to right-handed
  83162. * @param quaternion Source quaternion to convert to right-handed
  83163. */
  83164. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  83165. /**
  83166. * Converts a Quaternion to right-handed
  83167. * @param quaternion Source quaternion to convert to right-handed
  83168. */
  83169. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  83170. static _NormalizeTangentFromRef(tangent: Vector4): void;
  83171. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  83172. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  83173. }
  83174. }
  83175. declare module BABYLON.GLTF2.Exporter {
  83176. /**
  83177. * Converts Babylon Scene into glTF 2.0.
  83178. * @hidden
  83179. */
  83180. export class _Exporter {
  83181. /**
  83182. * Stores the glTF to export
  83183. */
  83184. _glTF: IGLTF;
  83185. /**
  83186. * Stores all generated buffer views, which represents views into the main glTF buffer data
  83187. */
  83188. _bufferViews: IBufferView[];
  83189. /**
  83190. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  83191. */
  83192. _accessors: IAccessor[];
  83193. /**
  83194. * Stores all the generated nodes, which contains transform and/or mesh information per node
  83195. */
  83196. _nodes: INode[];
  83197. /**
  83198. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  83199. */
  83200. private _scenes;
  83201. /**
  83202. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  83203. */
  83204. private _meshes;
  83205. /**
  83206. * Stores all the generated material information, which represents the appearance of each primitive
  83207. */
  83208. _materials: IMaterial[];
  83209. _materialMap: {
  83210. [materialID: number]: number;
  83211. };
  83212. /**
  83213. * Stores all the generated texture information, which is referenced by glTF materials
  83214. */
  83215. _textures: ITexture[];
  83216. /**
  83217. * Stores all the generated image information, which is referenced by glTF textures
  83218. */
  83219. _images: IImage[];
  83220. /**
  83221. * Stores all the texture samplers
  83222. */
  83223. _samplers: ISampler[];
  83224. /**
  83225. * Stores all the generated glTF skins
  83226. */
  83227. _skins: ISkin[];
  83228. /**
  83229. * Stores all the generated animation samplers, which is referenced by glTF animations
  83230. */
  83231. /**
  83232. * Stores the animations for glTF models
  83233. */
  83234. private _animations;
  83235. /**
  83236. * Stores the total amount of bytes stored in the glTF buffer
  83237. */
  83238. private _totalByteLength;
  83239. /**
  83240. * Stores a reference to the Babylon scene containing the source geometry and material information
  83241. */
  83242. _babylonScene: Scene;
  83243. /**
  83244. * Stores a map of the image data, where the key is the file name and the value
  83245. * is the image data
  83246. */
  83247. _imageData: {
  83248. [fileName: string]: {
  83249. data: Uint8Array;
  83250. mimeType: ImageMimeType;
  83251. };
  83252. };
  83253. /**
  83254. * Stores a map of the unique id of a node to its index in the node array
  83255. */
  83256. _nodeMap: {
  83257. [key: number]: number;
  83258. };
  83259. /**
  83260. * Specifies if the source Babylon scene was left handed, and needed conversion.
  83261. */
  83262. _convertToRightHandedSystem: boolean;
  83263. /**
  83264. * Specifies if a Babylon node should be converted to right-handed on export
  83265. */
  83266. _convertToRightHandedSystemMap: {
  83267. [nodeId: number]: boolean;
  83268. };
  83269. _includeCoordinateSystemConversionNodes: boolean;
  83270. /**
  83271. * Baked animation sample rate
  83272. */
  83273. private _animationSampleRate;
  83274. private _options;
  83275. private _localEngine;
  83276. _glTFMaterialExporter: _GLTFMaterialExporter;
  83277. private _extensions;
  83278. private static _ExtensionNames;
  83279. private static _ExtensionFactories;
  83280. private _applyExtension;
  83281. private _applyExtensions;
  83282. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  83283. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  83284. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83285. [key: number]: number;
  83286. }): Promise<Nullable<INode>>;
  83287. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  83288. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  83289. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83290. private _forEachExtensions;
  83291. private _extensionsOnExporting;
  83292. /**
  83293. * Load glTF serializer extensions
  83294. */
  83295. private _loadExtensions;
  83296. /**
  83297. * Creates a glTF Exporter instance, which can accept optional exporter options
  83298. * @param babylonScene Babylon scene object
  83299. * @param options Options to modify the behavior of the exporter
  83300. */
  83301. constructor(babylonScene: Scene, options?: IExportOptions);
  83302. dispose(): void;
  83303. /**
  83304. * Registers a glTF exporter extension
  83305. * @param name Name of the extension to export
  83306. * @param factory The factory function that creates the exporter extension
  83307. */
  83308. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  83309. /**
  83310. * Un-registers an exporter extension
  83311. * @param name The name fo the exporter extension
  83312. * @returns A boolean indicating whether the extension has been un-registered
  83313. */
  83314. static UnregisterExtension(name: string): boolean;
  83315. /**
  83316. * Lazy load a local engine
  83317. */
  83318. _getLocalEngine(): Engine;
  83319. private reorderIndicesBasedOnPrimitiveMode;
  83320. /**
  83321. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  83322. * clock-wise during export to glTF
  83323. * @param submesh BabylonJS submesh
  83324. * @param primitiveMode Primitive mode of the mesh
  83325. * @param sideOrientation the winding order of the submesh
  83326. * @param vertexBufferKind The type of vertex attribute
  83327. * @param meshAttributeArray The vertex attribute data
  83328. * @param byteOffset The offset to the binary data
  83329. * @param binaryWriter The binary data for the glTF file
  83330. * @param convertToRightHandedSystem Converts the values to right-handed
  83331. */
  83332. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  83333. /**
  83334. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  83335. * clock-wise during export to glTF
  83336. * @param submesh BabylonJS submesh
  83337. * @param primitiveMode Primitive mode of the mesh
  83338. * @param sideOrientation the winding order of the submesh
  83339. * @param vertexBufferKind The type of vertex attribute
  83340. * @param meshAttributeArray The vertex attribute data
  83341. * @param byteOffset The offset to the binary data
  83342. * @param binaryWriter The binary data for the glTF file
  83343. * @param convertToRightHandedSystem Converts the values to right-handed
  83344. */
  83345. private reorderTriangleFillMode;
  83346. /**
  83347. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  83348. * clock-wise during export to glTF
  83349. * @param submesh BabylonJS submesh
  83350. * @param primitiveMode Primitive mode of the mesh
  83351. * @param sideOrientation the winding order of the submesh
  83352. * @param vertexBufferKind The type of vertex attribute
  83353. * @param meshAttributeArray The vertex attribute data
  83354. * @param byteOffset The offset to the binary data
  83355. * @param binaryWriter The binary data for the glTF file
  83356. * @param convertToRightHandedSystem Converts the values to right-handed
  83357. */
  83358. private reorderTriangleStripDrawMode;
  83359. /**
  83360. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  83361. * clock-wise during export to glTF
  83362. * @param submesh BabylonJS submesh
  83363. * @param primitiveMode Primitive mode of the mesh
  83364. * @param sideOrientation the winding order of the submesh
  83365. * @param vertexBufferKind The type of vertex attribute
  83366. * @param meshAttributeArray The vertex attribute data
  83367. * @param byteOffset The offset to the binary data
  83368. * @param binaryWriter The binary data for the glTF file
  83369. * @param convertToRightHandedSystem Converts the values to right-handed
  83370. */
  83371. private reorderTriangleFanMode;
  83372. /**
  83373. * Writes the vertex attribute data to binary
  83374. * @param vertices The vertices to write to the binary writer
  83375. * @param byteOffset The offset into the binary writer to overwrite binary data
  83376. * @param vertexAttributeKind The vertex attribute type
  83377. * @param meshAttributeArray The vertex attribute data
  83378. * @param binaryWriter The writer containing the binary data
  83379. * @param convertToRightHandedSystem Converts the values to right-handed
  83380. */
  83381. private writeVertexAttributeData;
  83382. /**
  83383. * Writes mesh attribute data to a data buffer
  83384. * Returns the bytelength of the data
  83385. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83386. * @param meshAttributeArray Array containing the attribute data
  83387. * @param byteStride Specifies the space between data
  83388. * @param binaryWriter The buffer to write the binary data to
  83389. * @param convertToRightHandedSystem Converts the values to right-handed
  83390. */
  83391. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  83392. /**
  83393. * Writes mesh attribute data to a data buffer
  83394. * Returns the bytelength of the data
  83395. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83396. * @param meshAttributeArray Array containing the attribute data
  83397. * @param byteStride Specifies the space between data
  83398. * @param binaryWriter The buffer to write the binary data to
  83399. * @param convertToRightHandedSystem Converts the values to right-handed
  83400. */
  83401. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  83402. /**
  83403. * Generates glTF json data
  83404. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  83405. * @param glTFPrefix Text to use when prefixing a glTF file
  83406. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  83407. * @returns json data as string
  83408. */
  83409. private generateJSON;
  83410. /**
  83411. * Generates data for .gltf and .bin files based on the glTF prefix string
  83412. * @param glTFPrefix Text to use when prefixing a glTF file
  83413. * @param dispose Dispose the exporter
  83414. * @returns GLTFData with glTF file data
  83415. */
  83416. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83417. /**
  83418. * Creates a binary buffer for glTF
  83419. * @returns array buffer for binary data
  83420. */
  83421. private _generateBinaryAsync;
  83422. /**
  83423. * Pads the number to a multiple of 4
  83424. * @param num number to pad
  83425. * @returns padded number
  83426. */
  83427. private _getPadding;
  83428. /**
  83429. * @hidden
  83430. */
  83431. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83432. /**
  83433. * Sets the TRS for each node
  83434. * @param node glTF Node for storing the transformation data
  83435. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  83436. * @param convertToRightHandedSystem Converts the values to right-handed
  83437. */
  83438. private setNodeTransformation;
  83439. private getVertexBufferFromMesh;
  83440. /**
  83441. * Creates a bufferview based on the vertices type for the Babylon mesh
  83442. * @param kind Indicates the type of vertices data
  83443. * @param componentType Indicates the numerical type used to store the data
  83444. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  83445. * @param binaryWriter The buffer to write the bufferview data to
  83446. * @param convertToRightHandedSystem Converts the values to right-handed
  83447. */
  83448. private createBufferViewKind;
  83449. /**
  83450. * Creates a bufferview based on the vertices type for the Babylon mesh
  83451. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  83452. * @param babylonMorphTarget the morph target to be exported
  83453. * @param binaryWriter The buffer to write the bufferview data to
  83454. * @param convertToRightHandedSystem Converts the values to right-handed
  83455. */
  83456. private setMorphTargetAttributes;
  83457. /**
  83458. * The primitive mode of the Babylon mesh
  83459. * @param babylonMesh The BabylonJS mesh
  83460. */
  83461. private getMeshPrimitiveMode;
  83462. /**
  83463. * Sets the primitive mode of the glTF mesh primitive
  83464. * @param meshPrimitive glTF mesh primitive
  83465. * @param primitiveMode The primitive mode
  83466. */
  83467. private setPrimitiveMode;
  83468. /**
  83469. * Sets the vertex attribute accessor based of the glTF mesh primitive
  83470. * @param meshPrimitive glTF mesh primitive
  83471. * @param attributeKind vertex attribute
  83472. * @returns boolean specifying if uv coordinates are present
  83473. */
  83474. private setAttributeKind;
  83475. /**
  83476. * Sets data for the primitive attributes of each submesh
  83477. * @param mesh glTF Mesh object to store the primitive attribute information
  83478. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  83479. * @param binaryWriter Buffer to write the attribute data to
  83480. * @param convertToRightHandedSystem Converts the values to right-handed
  83481. */
  83482. private setPrimitiveAttributesAsync;
  83483. /**
  83484. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  83485. * @param node The node to check
  83486. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  83487. */
  83488. private isBabylonCoordinateSystemConvertingNode;
  83489. /**
  83490. * Creates a glTF scene based on the array of meshes
  83491. * Returns the the total byte offset
  83492. * @param babylonScene Babylon scene to get the mesh data from
  83493. * @param binaryWriter Buffer to write binary data to
  83494. */
  83495. private createSceneAsync;
  83496. /**
  83497. * Creates a mapping of Node unique id to node index and handles animations
  83498. * @param babylonScene Babylon Scene
  83499. * @param nodes Babylon transform nodes
  83500. * @param binaryWriter Buffer to write binary data to
  83501. * @returns Node mapping of unique id to index
  83502. */
  83503. private createNodeMapAndAnimationsAsync;
  83504. /**
  83505. * Creates a glTF node from a Babylon mesh
  83506. * @param babylonMesh Source Babylon mesh
  83507. * @param binaryWriter Buffer for storing geometry data
  83508. * @param convertToRightHandedSystem Converts the values to right-handed
  83509. * @param nodeMap Node mapping of unique id to glTF node index
  83510. * @returns glTF node
  83511. */
  83512. private createNodeAsync;
  83513. /**
  83514. * Creates a glTF skin from a Babylon skeleton
  83515. * @param babylonScene Babylon Scene
  83516. * @param nodes Babylon transform nodes
  83517. * @param binaryWriter Buffer to write binary data to
  83518. * @returns Node mapping of unique id to index
  83519. */
  83520. private createSkinsAsync;
  83521. }
  83522. /**
  83523. * @hidden
  83524. *
  83525. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  83526. */
  83527. export class _BinaryWriter {
  83528. /**
  83529. * Array buffer which stores all binary data
  83530. */
  83531. private _arrayBuffer;
  83532. /**
  83533. * View of the array buffer
  83534. */
  83535. private _dataView;
  83536. /**
  83537. * byte offset of data in array buffer
  83538. */
  83539. private _byteOffset;
  83540. /**
  83541. * Initialize binary writer with an initial byte length
  83542. * @param byteLength Initial byte length of the array buffer
  83543. */
  83544. constructor(byteLength: number);
  83545. /**
  83546. * Resize the array buffer to the specified byte length
  83547. * @param byteLength
  83548. */
  83549. private resizeBuffer;
  83550. /**
  83551. * Get an array buffer with the length of the byte offset
  83552. * @returns ArrayBuffer resized to the byte offset
  83553. */
  83554. getArrayBuffer(): ArrayBuffer;
  83555. /**
  83556. * Get the byte offset of the array buffer
  83557. * @returns byte offset
  83558. */
  83559. getByteOffset(): number;
  83560. /**
  83561. * Stores an UInt8 in the array buffer
  83562. * @param entry
  83563. * @param byteOffset If defined, specifies where to set the value as an offset.
  83564. */
  83565. setUInt8(entry: number, byteOffset?: number): void;
  83566. /**
  83567. * Stores an UInt16 in the array buffer
  83568. * @param entry
  83569. * @param byteOffset If defined, specifies where to set the value as an offset.
  83570. */
  83571. setUInt16(entry: number, byteOffset?: number): void;
  83572. /**
  83573. * Gets an UInt32 in the array buffer
  83574. * @param entry
  83575. * @param byteOffset If defined, specifies where to set the value as an offset.
  83576. */
  83577. getUInt32(byteOffset: number): number;
  83578. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83579. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83580. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83581. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83582. /**
  83583. * Stores a Float32 in the array buffer
  83584. * @param entry
  83585. */
  83586. setFloat32(entry: number, byteOffset?: number): void;
  83587. /**
  83588. * Stores an UInt32 in the array buffer
  83589. * @param entry
  83590. * @param byteOffset If defined, specifies where to set the value as an offset.
  83591. */
  83592. setUInt32(entry: number, byteOffset?: number): void;
  83593. }
  83594. }
  83595. declare module BABYLON.GLTF2.Exporter {
  83596. /**
  83597. * @hidden
  83598. * Interface to store animation data.
  83599. */
  83600. export interface _IAnimationData {
  83601. /**
  83602. * Keyframe data.
  83603. */
  83604. inputs: number[];
  83605. /**
  83606. * Value data.
  83607. */
  83608. outputs: number[][];
  83609. /**
  83610. * Animation interpolation data.
  83611. */
  83612. samplerInterpolation: AnimationSamplerInterpolation;
  83613. /**
  83614. * Minimum keyframe value.
  83615. */
  83616. inputsMin: number;
  83617. /**
  83618. * Maximum keyframe value.
  83619. */
  83620. inputsMax: number;
  83621. }
  83622. /**
  83623. * @hidden
  83624. */
  83625. export interface _IAnimationInfo {
  83626. /**
  83627. * The target channel for the animation
  83628. */
  83629. animationChannelTargetPath: AnimationChannelTargetPath;
  83630. /**
  83631. * The glTF accessor type for the data.
  83632. */
  83633. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  83634. /**
  83635. * Specifies if quaternions should be used.
  83636. */
  83637. useQuaternion: boolean;
  83638. }
  83639. /**
  83640. * @hidden
  83641. * Utility class for generating glTF animation data from BabylonJS.
  83642. */
  83643. export class _GLTFAnimation {
  83644. /**
  83645. * @ignore
  83646. *
  83647. * Creates glTF channel animation from BabylonJS animation.
  83648. * @param babylonTransformNode - BabylonJS mesh.
  83649. * @param animation - animation.
  83650. * @param animationChannelTargetPath - The target animation channel.
  83651. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  83652. * @param useQuaternion - Specifies if quaternions are used.
  83653. * @returns nullable IAnimationData
  83654. */
  83655. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  83656. private static _DeduceAnimationInfo;
  83657. /**
  83658. * @ignore
  83659. * Create node animations from the transform node animations
  83660. * @param babylonNode
  83661. * @param runtimeGLTFAnimation
  83662. * @param idleGLTFAnimations
  83663. * @param nodeMap
  83664. * @param nodes
  83665. * @param binaryWriter
  83666. * @param bufferViews
  83667. * @param accessors
  83668. * @param convertToRightHandedSystem
  83669. * @param animationSampleRate
  83670. */
  83671. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83672. [key: number]: number;
  83673. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83674. /**
  83675. * @ignore
  83676. * Create individual morph animations from the mesh's morph target animation tracks
  83677. * @param babylonNode
  83678. * @param runtimeGLTFAnimation
  83679. * @param idleGLTFAnimations
  83680. * @param nodeMap
  83681. * @param nodes
  83682. * @param binaryWriter
  83683. * @param bufferViews
  83684. * @param accessors
  83685. * @param convertToRightHandedSystem
  83686. * @param animationSampleRate
  83687. */
  83688. static _CreateMorphTargetAnimationFromMorphTargets(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83689. [key: number]: number;
  83690. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83691. /**
  83692. * @ignore
  83693. * Create node and morph animations from the animation groups
  83694. * @param babylonScene
  83695. * @param glTFAnimations
  83696. * @param nodeMap
  83697. * @param nodes
  83698. * @param binaryWriter
  83699. * @param bufferViews
  83700. * @param accessors
  83701. * @param convertToRightHandedSystemMap
  83702. * @param animationSampleRate
  83703. */
  83704. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  83705. [key: number]: number;
  83706. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  83707. [nodeId: number]: boolean;
  83708. }, animationSampleRate: number): void;
  83709. private static AddAnimation;
  83710. /**
  83711. * Create a baked animation
  83712. * @param babylonTransformNode BabylonJS mesh
  83713. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  83714. * @param animationChannelTargetPath animation target channel
  83715. * @param minFrame minimum animation frame
  83716. * @param maxFrame maximum animation frame
  83717. * @param fps frames per second of the animation
  83718. * @param inputs input key frames of the animation
  83719. * @param outputs output key frame data of the animation
  83720. * @param convertToRightHandedSystem converts the values to right-handed
  83721. * @param useQuaternion specifies if quaternions should be used
  83722. */
  83723. private static _CreateBakedAnimation;
  83724. private static _ConvertFactorToVector3OrQuaternion;
  83725. private static _SetInterpolatedValue;
  83726. /**
  83727. * Creates linear animation from the animation key frames
  83728. * @param babylonTransformNode BabylonJS mesh
  83729. * @param animation BabylonJS animation
  83730. * @param animationChannelTargetPath The target animation channel
  83731. * @param frameDelta The difference between the last and first frame of the animation
  83732. * @param inputs Array to store the key frame times
  83733. * @param outputs Array to store the key frame data
  83734. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83735. * @param useQuaternion Specifies if quaternions are used in the animation
  83736. */
  83737. private static _CreateLinearOrStepAnimation;
  83738. /**
  83739. * Creates cubic spline animation from the animation key frames
  83740. * @param babylonTransformNode BabylonJS mesh
  83741. * @param animation BabylonJS animation
  83742. * @param animationChannelTargetPath The target animation channel
  83743. * @param frameDelta The difference between the last and first frame of the animation
  83744. * @param inputs Array to store the key frame times
  83745. * @param outputs Array to store the key frame data
  83746. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83747. * @param useQuaternion Specifies if quaternions are used in the animation
  83748. */
  83749. private static _CreateCubicSplineAnimation;
  83750. private static _GetBasePositionRotationOrScale;
  83751. /**
  83752. * Adds a key frame value
  83753. * @param keyFrame
  83754. * @param animation
  83755. * @param outputs
  83756. * @param animationChannelTargetPath
  83757. * @param basePositionRotationOrScale
  83758. * @param convertToRightHandedSystem
  83759. * @param useQuaternion
  83760. */
  83761. private static _AddKeyframeValue;
  83762. /**
  83763. * Determine the interpolation based on the key frames
  83764. * @param keyFrames
  83765. * @param animationChannelTargetPath
  83766. * @param useQuaternion
  83767. */
  83768. private static _DeduceInterpolation;
  83769. /**
  83770. * Adds an input tangent or output tangent to the output data
  83771. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  83772. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  83773. * @param outputs The animation data by keyframe
  83774. * @param animationChannelTargetPath The target animation channel
  83775. * @param interpolation The interpolation type
  83776. * @param keyFrame The key frame with the animation data
  83777. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  83778. * @param useQuaternion Specifies if quaternions are used
  83779. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  83780. */
  83781. private static AddSplineTangent;
  83782. /**
  83783. * Get the minimum and maximum key frames' frame values
  83784. * @param keyFrames animation key frames
  83785. * @returns the minimum and maximum key frame value
  83786. */
  83787. private static calculateMinMaxKeyFrames;
  83788. }
  83789. }
  83790. declare module BABYLON.GLTF2.Exporter {
  83791. /** @hidden */
  83792. export var textureTransformPixelShader: {
  83793. name: string;
  83794. shader: string;
  83795. };
  83796. }
  83797. declare module BABYLON.GLTF2.Exporter.Extensions {
  83798. /**
  83799. * @hidden
  83800. */
  83801. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  83802. private _recordedTextures;
  83803. /** Name of this extension */
  83804. readonly name: string;
  83805. /** Defines whether this extension is enabled */
  83806. enabled: boolean;
  83807. /** Defines whether this extension is required */
  83808. required: boolean;
  83809. /** Reference to the glTF exporter */
  83810. private _wasUsed;
  83811. constructor(exporter: _Exporter);
  83812. dispose(): void;
  83813. /** @hidden */
  83814. get wasUsed(): boolean;
  83815. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83816. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  83817. /**
  83818. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  83819. * @param babylonTexture
  83820. * @param offset
  83821. * @param rotation
  83822. * @param scale
  83823. * @param scene
  83824. */
  83825. private _textureTransformTextureAsync;
  83826. }
  83827. }
  83828. declare module BABYLON.GLTF2.Exporter.Extensions {
  83829. /**
  83830. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  83831. */
  83832. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  83833. /** The name of this extension. */
  83834. readonly name: string;
  83835. /** Defines whether this extension is enabled. */
  83836. enabled: boolean;
  83837. /** Defines whether this extension is required */
  83838. required: boolean;
  83839. /** Reference to the glTF exporter */
  83840. private _exporter;
  83841. private _lights;
  83842. /** @hidden */
  83843. constructor(exporter: _Exporter);
  83844. /** @hidden */
  83845. dispose(): void;
  83846. /** @hidden */
  83847. get wasUsed(): boolean;
  83848. /** @hidden */
  83849. onExporting(): void;
  83850. /**
  83851. * Define this method to modify the default behavior when exporting a node
  83852. * @param context The context when exporting the node
  83853. * @param node glTF node
  83854. * @param babylonNode BabylonJS node
  83855. * @param nodeMap Node mapping of unique id to glTF node index
  83856. * @returns nullable INode promise
  83857. */
  83858. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83859. [key: number]: number;
  83860. }): Promise<Nullable<INode>>;
  83861. }
  83862. }
  83863. declare module BABYLON.GLTF2.Exporter.Extensions {
  83864. /**
  83865. * @hidden
  83866. */
  83867. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  83868. /** Name of this extension */
  83869. readonly name: string;
  83870. /** Defines whether this extension is enabled */
  83871. enabled: boolean;
  83872. /** Defines whether this extension is required */
  83873. required: boolean;
  83874. /** Reference to the glTF exporter */
  83875. private _textureInfos;
  83876. private _exportedTextures;
  83877. private _wasUsed;
  83878. constructor(exporter: _Exporter);
  83879. dispose(): void;
  83880. /** @hidden */
  83881. get wasUsed(): boolean;
  83882. private _getTextureIndex;
  83883. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83884. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83885. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83886. }
  83887. }
  83888. declare module BABYLON.GLTF2.Exporter.Extensions {
  83889. /**
  83890. * @hidden
  83891. */
  83892. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  83893. /** Name of this extension */
  83894. readonly name: string;
  83895. /** Defines whether this extension is enabled */
  83896. enabled: boolean;
  83897. /** Defines whether this extension is required */
  83898. required: boolean;
  83899. private _wasUsed;
  83900. constructor(exporter: _Exporter);
  83901. /** @hidden */
  83902. get wasUsed(): boolean;
  83903. dispose(): void;
  83904. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83905. }
  83906. }
  83907. declare module BABYLON {
  83908. /**
  83909. * Class for generating STL data from a Babylon scene.
  83910. */
  83911. export class STLExport {
  83912. /**
  83913. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  83914. * @param meshes list defines the mesh to serialize
  83915. * @param download triggers the automatic download of the file.
  83916. * @param fileName changes the downloads fileName.
  83917. * @param binary changes the STL to a binary type.
  83918. * @param isLittleEndian toggle for binary type exporter.
  83919. * @returns the STL as UTF8 string
  83920. */
  83921. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  83922. }
  83923. }
  83924. declare module "babylonjs-gltf2interface" {
  83925. export = BABYLON.GLTF2;
  83926. }
  83927. /**
  83928. * Module for glTF 2.0 Interface
  83929. */
  83930. declare module BABYLON.GLTF2 {
  83931. /**
  83932. * The datatype of the components in the attribute
  83933. */
  83934. const enum AccessorComponentType {
  83935. /**
  83936. * Byte
  83937. */
  83938. BYTE = 5120,
  83939. /**
  83940. * Unsigned Byte
  83941. */
  83942. UNSIGNED_BYTE = 5121,
  83943. /**
  83944. * Short
  83945. */
  83946. SHORT = 5122,
  83947. /**
  83948. * Unsigned Short
  83949. */
  83950. UNSIGNED_SHORT = 5123,
  83951. /**
  83952. * Unsigned Int
  83953. */
  83954. UNSIGNED_INT = 5125,
  83955. /**
  83956. * Float
  83957. */
  83958. FLOAT = 5126,
  83959. }
  83960. /**
  83961. * Specifies if the attirbute is a scalar, vector, or matrix
  83962. */
  83963. const enum AccessorType {
  83964. /**
  83965. * Scalar
  83966. */
  83967. SCALAR = "SCALAR",
  83968. /**
  83969. * Vector2
  83970. */
  83971. VEC2 = "VEC2",
  83972. /**
  83973. * Vector3
  83974. */
  83975. VEC3 = "VEC3",
  83976. /**
  83977. * Vector4
  83978. */
  83979. VEC4 = "VEC4",
  83980. /**
  83981. * Matrix2x2
  83982. */
  83983. MAT2 = "MAT2",
  83984. /**
  83985. * Matrix3x3
  83986. */
  83987. MAT3 = "MAT3",
  83988. /**
  83989. * Matrix4x4
  83990. */
  83991. MAT4 = "MAT4",
  83992. }
  83993. /**
  83994. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83995. */
  83996. const enum AnimationChannelTargetPath {
  83997. /**
  83998. * Translation
  83999. */
  84000. TRANSLATION = "translation",
  84001. /**
  84002. * Rotation
  84003. */
  84004. ROTATION = "rotation",
  84005. /**
  84006. * Scale
  84007. */
  84008. SCALE = "scale",
  84009. /**
  84010. * Weights
  84011. */
  84012. WEIGHTS = "weights",
  84013. }
  84014. /**
  84015. * Interpolation algorithm
  84016. */
  84017. const enum AnimationSamplerInterpolation {
  84018. /**
  84019. * The animated values are linearly interpolated between keyframes
  84020. */
  84021. LINEAR = "LINEAR",
  84022. /**
  84023. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84024. */
  84025. STEP = "STEP",
  84026. /**
  84027. * The animation's interpolation is computed using a cubic spline with specified tangents
  84028. */
  84029. CUBICSPLINE = "CUBICSPLINE",
  84030. }
  84031. /**
  84032. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84033. */
  84034. const enum CameraType {
  84035. /**
  84036. * A perspective camera containing properties to create a perspective projection matrix
  84037. */
  84038. PERSPECTIVE = "perspective",
  84039. /**
  84040. * An orthographic camera containing properties to create an orthographic projection matrix
  84041. */
  84042. ORTHOGRAPHIC = "orthographic",
  84043. }
  84044. /**
  84045. * The mime-type of the image
  84046. */
  84047. const enum ImageMimeType {
  84048. /**
  84049. * JPEG Mime-type
  84050. */
  84051. JPEG = "image/jpeg",
  84052. /**
  84053. * PNG Mime-type
  84054. */
  84055. PNG = "image/png",
  84056. }
  84057. /**
  84058. * The alpha rendering mode of the material
  84059. */
  84060. const enum MaterialAlphaMode {
  84061. /**
  84062. * The alpha value is ignored and the rendered output is fully opaque
  84063. */
  84064. OPAQUE = "OPAQUE",
  84065. /**
  84066. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84067. */
  84068. MASK = "MASK",
  84069. /**
  84070. * 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)
  84071. */
  84072. BLEND = "BLEND",
  84073. }
  84074. /**
  84075. * The type of the primitives to render
  84076. */
  84077. const enum MeshPrimitiveMode {
  84078. /**
  84079. * Points
  84080. */
  84081. POINTS = 0,
  84082. /**
  84083. * Lines
  84084. */
  84085. LINES = 1,
  84086. /**
  84087. * Line Loop
  84088. */
  84089. LINE_LOOP = 2,
  84090. /**
  84091. * Line Strip
  84092. */
  84093. LINE_STRIP = 3,
  84094. /**
  84095. * Triangles
  84096. */
  84097. TRIANGLES = 4,
  84098. /**
  84099. * Triangle Strip
  84100. */
  84101. TRIANGLE_STRIP = 5,
  84102. /**
  84103. * Triangle Fan
  84104. */
  84105. TRIANGLE_FAN = 6,
  84106. }
  84107. /**
  84108. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84109. */
  84110. const enum TextureMagFilter {
  84111. /**
  84112. * Nearest
  84113. */
  84114. NEAREST = 9728,
  84115. /**
  84116. * Linear
  84117. */
  84118. LINEAR = 9729,
  84119. }
  84120. /**
  84121. * Minification filter. All valid values correspond to WebGL enums
  84122. */
  84123. const enum TextureMinFilter {
  84124. /**
  84125. * Nearest
  84126. */
  84127. NEAREST = 9728,
  84128. /**
  84129. * Linear
  84130. */
  84131. LINEAR = 9729,
  84132. /**
  84133. * Nearest Mip-Map Nearest
  84134. */
  84135. NEAREST_MIPMAP_NEAREST = 9984,
  84136. /**
  84137. * Linear Mipmap Nearest
  84138. */
  84139. LINEAR_MIPMAP_NEAREST = 9985,
  84140. /**
  84141. * Nearest Mipmap Linear
  84142. */
  84143. NEAREST_MIPMAP_LINEAR = 9986,
  84144. /**
  84145. * Linear Mipmap Linear
  84146. */
  84147. LINEAR_MIPMAP_LINEAR = 9987,
  84148. }
  84149. /**
  84150. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84151. */
  84152. const enum TextureWrapMode {
  84153. /**
  84154. * Clamp to Edge
  84155. */
  84156. CLAMP_TO_EDGE = 33071,
  84157. /**
  84158. * Mirrored Repeat
  84159. */
  84160. MIRRORED_REPEAT = 33648,
  84161. /**
  84162. * Repeat
  84163. */
  84164. REPEAT = 10497,
  84165. }
  84166. /**
  84167. * glTF Property
  84168. */
  84169. interface IProperty {
  84170. /**
  84171. * Dictionary object with extension-specific objects
  84172. */
  84173. extensions?: {
  84174. [key: string]: any;
  84175. };
  84176. /**
  84177. * Application-Specific data
  84178. */
  84179. extras?: any;
  84180. }
  84181. /**
  84182. * glTF Child of Root Property
  84183. */
  84184. interface IChildRootProperty extends IProperty {
  84185. /**
  84186. * The user-defined name of this object
  84187. */
  84188. name?: string;
  84189. }
  84190. /**
  84191. * Indices of those attributes that deviate from their initialization value
  84192. */
  84193. interface IAccessorSparseIndices extends IProperty {
  84194. /**
  84195. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84196. */
  84197. bufferView: number;
  84198. /**
  84199. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84200. */
  84201. byteOffset?: number;
  84202. /**
  84203. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  84204. */
  84205. componentType: AccessorComponentType;
  84206. }
  84207. /**
  84208. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  84209. */
  84210. interface IAccessorSparseValues extends IProperty {
  84211. /**
  84212. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84213. */
  84214. bufferView: number;
  84215. /**
  84216. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84217. */
  84218. byteOffset?: number;
  84219. }
  84220. /**
  84221. * Sparse storage of attributes that deviate from their initialization value
  84222. */
  84223. interface IAccessorSparse extends IProperty {
  84224. /**
  84225. * The number of attributes encoded in this sparse accessor
  84226. */
  84227. count: number;
  84228. /**
  84229. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  84230. */
  84231. indices: IAccessorSparseIndices;
  84232. /**
  84233. * 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
  84234. */
  84235. values: IAccessorSparseValues;
  84236. }
  84237. /**
  84238. * 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
  84239. */
  84240. interface IAccessor extends IChildRootProperty {
  84241. /**
  84242. * The index of the bufferview
  84243. */
  84244. bufferView?: number;
  84245. /**
  84246. * The offset relative to the start of the bufferView in bytes
  84247. */
  84248. byteOffset?: number;
  84249. /**
  84250. * The datatype of components in the attribute
  84251. */
  84252. componentType: AccessorComponentType;
  84253. /**
  84254. * Specifies whether integer data values should be normalized
  84255. */
  84256. normalized?: boolean;
  84257. /**
  84258. * The number of attributes referenced by this accessor
  84259. */
  84260. count: number;
  84261. /**
  84262. * Specifies if the attribute is a scalar, vector, or matrix
  84263. */
  84264. type: AccessorType;
  84265. /**
  84266. * Maximum value of each component in this attribute
  84267. */
  84268. max?: number[];
  84269. /**
  84270. * Minimum value of each component in this attribute
  84271. */
  84272. min?: number[];
  84273. /**
  84274. * Sparse storage of attributes that deviate from their initialization value
  84275. */
  84276. sparse?: IAccessorSparse;
  84277. }
  84278. /**
  84279. * Targets an animation's sampler at a node's property
  84280. */
  84281. interface IAnimationChannel extends IProperty {
  84282. /**
  84283. * The index of a sampler in this animation used to compute the value for the target
  84284. */
  84285. sampler: number;
  84286. /**
  84287. * The index of the node and TRS property to target
  84288. */
  84289. target: IAnimationChannelTarget;
  84290. }
  84291. /**
  84292. * The index of the node and TRS property that an animation channel targets
  84293. */
  84294. interface IAnimationChannelTarget extends IProperty {
  84295. /**
  84296. * The index of the node to target
  84297. */
  84298. node: number;
  84299. /**
  84300. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84301. */
  84302. path: AnimationChannelTargetPath;
  84303. }
  84304. /**
  84305. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84306. */
  84307. interface IAnimationSampler extends IProperty {
  84308. /**
  84309. * The index of an accessor containing keyframe input values, e.g., time
  84310. */
  84311. input: number;
  84312. /**
  84313. * Interpolation algorithm
  84314. */
  84315. interpolation?: AnimationSamplerInterpolation;
  84316. /**
  84317. * The index of an accessor, containing keyframe output values
  84318. */
  84319. output: number;
  84320. }
  84321. /**
  84322. * A keyframe animation
  84323. */
  84324. interface IAnimation extends IChildRootProperty {
  84325. /**
  84326. * An array of channels, each of which targets an animation's sampler at a node's property
  84327. */
  84328. channels: IAnimationChannel[];
  84329. /**
  84330. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84331. */
  84332. samplers: IAnimationSampler[];
  84333. }
  84334. /**
  84335. * Metadata about the glTF asset
  84336. */
  84337. interface IAsset extends IChildRootProperty {
  84338. /**
  84339. * A copyright message suitable for display to credit the content creator
  84340. */
  84341. copyright?: string;
  84342. /**
  84343. * Tool that generated this glTF model. Useful for debugging
  84344. */
  84345. generator?: string;
  84346. /**
  84347. * The glTF version that this asset targets
  84348. */
  84349. version: string;
  84350. /**
  84351. * The minimum glTF version that this asset targets
  84352. */
  84353. minVersion?: string;
  84354. }
  84355. /**
  84356. * A buffer points to binary geometry, animation, or skins
  84357. */
  84358. interface IBuffer extends IChildRootProperty {
  84359. /**
  84360. * 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
  84361. */
  84362. uri?: string;
  84363. /**
  84364. * The length of the buffer in bytes
  84365. */
  84366. byteLength: number;
  84367. }
  84368. /**
  84369. * A view into a buffer generally representing a subset of the buffer
  84370. */
  84371. interface IBufferView extends IChildRootProperty {
  84372. /**
  84373. * The index of the buffer
  84374. */
  84375. buffer: number;
  84376. /**
  84377. * The offset into the buffer in bytes
  84378. */
  84379. byteOffset?: number;
  84380. /**
  84381. * The lenth of the bufferView in bytes
  84382. */
  84383. byteLength: number;
  84384. /**
  84385. * The stride, in bytes
  84386. */
  84387. byteStride?: number;
  84388. }
  84389. /**
  84390. * An orthographic camera containing properties to create an orthographic projection matrix
  84391. */
  84392. interface ICameraOrthographic extends IProperty {
  84393. /**
  84394. * The floating-point horizontal magnification of the view. Must not be zero
  84395. */
  84396. xmag: number;
  84397. /**
  84398. * The floating-point vertical magnification of the view. Must not be zero
  84399. */
  84400. ymag: number;
  84401. /**
  84402. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  84403. */
  84404. zfar: number;
  84405. /**
  84406. * The floating-point distance to the near clipping plane
  84407. */
  84408. znear: number;
  84409. }
  84410. /**
  84411. * A perspective camera containing properties to create a perspective projection matrix
  84412. */
  84413. interface ICameraPerspective extends IProperty {
  84414. /**
  84415. * The floating-point aspect ratio of the field of view
  84416. */
  84417. aspectRatio?: number;
  84418. /**
  84419. * The floating-point vertical field of view in radians
  84420. */
  84421. yfov: number;
  84422. /**
  84423. * The floating-point distance to the far clipping plane
  84424. */
  84425. zfar?: number;
  84426. /**
  84427. * The floating-point distance to the near clipping plane
  84428. */
  84429. znear: number;
  84430. }
  84431. /**
  84432. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84433. */
  84434. interface ICamera extends IChildRootProperty {
  84435. /**
  84436. * An orthographic camera containing properties to create an orthographic projection matrix
  84437. */
  84438. orthographic?: ICameraOrthographic;
  84439. /**
  84440. * A perspective camera containing properties to create a perspective projection matrix
  84441. */
  84442. perspective?: ICameraPerspective;
  84443. /**
  84444. * Specifies if the camera uses a perspective or orthographic projection
  84445. */
  84446. type: CameraType;
  84447. }
  84448. /**
  84449. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  84450. */
  84451. interface IImage extends IChildRootProperty {
  84452. /**
  84453. * 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
  84454. */
  84455. uri?: string;
  84456. /**
  84457. * The image's MIME type
  84458. */
  84459. mimeType?: ImageMimeType;
  84460. /**
  84461. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  84462. */
  84463. bufferView?: number;
  84464. }
  84465. /**
  84466. * Material Normal Texture Info
  84467. */
  84468. interface IMaterialNormalTextureInfo extends ITextureInfo {
  84469. /**
  84470. * The scalar multiplier applied to each normal vector of the normal texture
  84471. */
  84472. scale?: number;
  84473. }
  84474. /**
  84475. * Material Occlusion Texture Info
  84476. */
  84477. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  84478. /**
  84479. * A scalar multiplier controlling the amount of occlusion applied
  84480. */
  84481. strength?: number;
  84482. }
  84483. /**
  84484. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  84485. */
  84486. interface IMaterialPbrMetallicRoughness {
  84487. /**
  84488. * The material's base color factor
  84489. */
  84490. baseColorFactor?: number[];
  84491. /**
  84492. * The base color texture
  84493. */
  84494. baseColorTexture?: ITextureInfo;
  84495. /**
  84496. * The metalness of the material
  84497. */
  84498. metallicFactor?: number;
  84499. /**
  84500. * The roughness of the material
  84501. */
  84502. roughnessFactor?: number;
  84503. /**
  84504. * The metallic-roughness texture
  84505. */
  84506. metallicRoughnessTexture?: ITextureInfo;
  84507. }
  84508. /**
  84509. * The material appearance of a primitive
  84510. */
  84511. interface IMaterial extends IChildRootProperty {
  84512. /**
  84513. * 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
  84514. */
  84515. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  84516. /**
  84517. * The normal map texture
  84518. */
  84519. normalTexture?: IMaterialNormalTextureInfo;
  84520. /**
  84521. * The occlusion map texture
  84522. */
  84523. occlusionTexture?: IMaterialOcclusionTextureInfo;
  84524. /**
  84525. * The emissive map texture
  84526. */
  84527. emissiveTexture?: ITextureInfo;
  84528. /**
  84529. * 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
  84530. */
  84531. emissiveFactor?: number[];
  84532. /**
  84533. * The alpha rendering mode of the material
  84534. */
  84535. alphaMode?: MaterialAlphaMode;
  84536. /**
  84537. * The alpha cutoff value of the material
  84538. */
  84539. alphaCutoff?: number;
  84540. /**
  84541. * Specifies whether the material is double sided
  84542. */
  84543. doubleSided?: boolean;
  84544. }
  84545. /**
  84546. * Geometry to be rendered with the given material
  84547. */
  84548. interface IMeshPrimitive extends IProperty {
  84549. /**
  84550. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  84551. */
  84552. attributes: {
  84553. [name: string]: number;
  84554. };
  84555. /**
  84556. * The index of the accessor that contains the indices
  84557. */
  84558. indices?: number;
  84559. /**
  84560. * The index of the material to apply to this primitive when rendering
  84561. */
  84562. material?: number;
  84563. /**
  84564. * The type of primitives to render. All valid values correspond to WebGL enums
  84565. */
  84566. mode?: MeshPrimitiveMode;
  84567. /**
  84568. * 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
  84569. */
  84570. targets?: {
  84571. [name: string]: number;
  84572. }[];
  84573. }
  84574. /**
  84575. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  84576. */
  84577. interface IMesh extends IChildRootProperty {
  84578. /**
  84579. * An array of primitives, each defining geometry to be rendered with a material
  84580. */
  84581. primitives: IMeshPrimitive[];
  84582. /**
  84583. * Array of weights to be applied to the Morph Targets
  84584. */
  84585. weights?: number[];
  84586. }
  84587. /**
  84588. * A node in the node hierarchy
  84589. */
  84590. interface INode extends IChildRootProperty {
  84591. /**
  84592. * The index of the camera referenced by this node
  84593. */
  84594. camera?: number;
  84595. /**
  84596. * The indices of this node's children
  84597. */
  84598. children?: number[];
  84599. /**
  84600. * The index of the skin referenced by this node
  84601. */
  84602. skin?: number;
  84603. /**
  84604. * A floating-point 4x4 transformation matrix stored in column-major order
  84605. */
  84606. matrix?: number[];
  84607. /**
  84608. * The index of the mesh in this node
  84609. */
  84610. mesh?: number;
  84611. /**
  84612. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  84613. */
  84614. rotation?: number[];
  84615. /**
  84616. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  84617. */
  84618. scale?: number[];
  84619. /**
  84620. * The node's translation along the x, y, and z axes
  84621. */
  84622. translation?: number[];
  84623. /**
  84624. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  84625. */
  84626. weights?: number[];
  84627. }
  84628. /**
  84629. * Texture sampler properties for filtering and wrapping modes
  84630. */
  84631. interface ISampler extends IChildRootProperty {
  84632. /**
  84633. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84634. */
  84635. magFilter?: TextureMagFilter;
  84636. /**
  84637. * Minification filter. All valid values correspond to WebGL enums
  84638. */
  84639. minFilter?: TextureMinFilter;
  84640. /**
  84641. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84642. */
  84643. wrapS?: TextureWrapMode;
  84644. /**
  84645. * T (V) wrapping mode. All valid values correspond to WebGL enums
  84646. */
  84647. wrapT?: TextureWrapMode;
  84648. }
  84649. /**
  84650. * The root nodes of a scene
  84651. */
  84652. interface IScene extends IChildRootProperty {
  84653. /**
  84654. * The indices of each root node
  84655. */
  84656. nodes: number[];
  84657. }
  84658. /**
  84659. * Joints and matrices defining a skin
  84660. */
  84661. interface ISkin extends IChildRootProperty {
  84662. /**
  84663. * 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
  84664. */
  84665. inverseBindMatrices?: number;
  84666. /**
  84667. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  84668. */
  84669. skeleton?: number;
  84670. /**
  84671. * 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)
  84672. */
  84673. joints: number[];
  84674. }
  84675. /**
  84676. * A texture and its sampler
  84677. */
  84678. interface ITexture extends IChildRootProperty {
  84679. /**
  84680. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  84681. */
  84682. sampler?: number;
  84683. /**
  84684. * The index of the image used by this texture
  84685. */
  84686. source: number;
  84687. }
  84688. /**
  84689. * Reference to a texture
  84690. */
  84691. interface ITextureInfo extends IProperty {
  84692. /**
  84693. * The index of the texture
  84694. */
  84695. index: number;
  84696. /**
  84697. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  84698. */
  84699. texCoord?: number;
  84700. }
  84701. /**
  84702. * The root object for a glTF asset
  84703. */
  84704. interface IGLTF extends IProperty {
  84705. /**
  84706. * An array of accessors. An accessor is a typed view into a bufferView
  84707. */
  84708. accessors?: IAccessor[];
  84709. /**
  84710. * An array of keyframe animations
  84711. */
  84712. animations?: IAnimation[];
  84713. /**
  84714. * Metadata about the glTF asset
  84715. */
  84716. asset: IAsset;
  84717. /**
  84718. * An array of buffers. A buffer points to binary geometry, animation, or skins
  84719. */
  84720. buffers?: IBuffer[];
  84721. /**
  84722. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  84723. */
  84724. bufferViews?: IBufferView[];
  84725. /**
  84726. * An array of cameras
  84727. */
  84728. cameras?: ICamera[];
  84729. /**
  84730. * Names of glTF extensions used somewhere in this asset
  84731. */
  84732. extensionsUsed?: string[];
  84733. /**
  84734. * Names of glTF extensions required to properly load this asset
  84735. */
  84736. extensionsRequired?: string[];
  84737. /**
  84738. * An array of images. An image defines data used to create a texture
  84739. */
  84740. images?: IImage[];
  84741. /**
  84742. * An array of materials. A material defines the appearance of a primitive
  84743. */
  84744. materials?: IMaterial[];
  84745. /**
  84746. * An array of meshes. A mesh is a set of primitives to be rendered
  84747. */
  84748. meshes?: IMesh[];
  84749. /**
  84750. * An array of nodes
  84751. */
  84752. nodes?: INode[];
  84753. /**
  84754. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  84755. */
  84756. samplers?: ISampler[];
  84757. /**
  84758. * The index of the default scene
  84759. */
  84760. scene?: number;
  84761. /**
  84762. * An array of scenes
  84763. */
  84764. scenes?: IScene[];
  84765. /**
  84766. * An array of skins. A skin is defined by joints and matrices
  84767. */
  84768. skins?: ISkin[];
  84769. /**
  84770. * An array of textures
  84771. */
  84772. textures?: ITexture[];
  84773. }
  84774. /**
  84775. * The glTF validation results
  84776. * @ignore
  84777. */
  84778. interface IGLTFValidationResults {
  84779. info: {
  84780. generator: string;
  84781. hasAnimations: boolean;
  84782. hasDefaultScene: boolean;
  84783. hasMaterials: boolean;
  84784. hasMorphTargets: boolean;
  84785. hasSkins: boolean;
  84786. hasTextures: boolean;
  84787. maxAttributesUsed: number;
  84788. primitivesCount: number
  84789. };
  84790. issues: {
  84791. messages: Array<string>;
  84792. numErrors: number;
  84793. numHints: number;
  84794. numInfos: number;
  84795. numWarnings: number;
  84796. truncated: boolean
  84797. };
  84798. mimeType: string;
  84799. uri: string;
  84800. validatedAt: string;
  84801. validatorVersion: string;
  84802. }
  84803. /**
  84804. * The glTF validation options
  84805. */
  84806. interface IGLTFValidationOptions {
  84807. /** Uri to use */
  84808. uri?: string;
  84809. /** Function used to load external resources */
  84810. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  84811. /** Boolean indicating that we need to validate accessor data */
  84812. validateAccessorData?: boolean;
  84813. /** max number of issues allowed */
  84814. maxIssues?: number;
  84815. /** Ignored issues */
  84816. ignoredIssues?: Array<string>;
  84817. /** Value to override severy settings */
  84818. severityOverrides?: Object;
  84819. }
  84820. /**
  84821. * The glTF validator object
  84822. * @ignore
  84823. */
  84824. interface IGLTFValidator {
  84825. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84826. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84827. }
  84828. /**
  84829. * Interfaces from the EXT_lights_image_based extension
  84830. */
  84831. /** @hidden */
  84832. interface IEXTLightsImageBased_LightReferenceImageBased {
  84833. light: number;
  84834. }
  84835. /** @hidden */
  84836. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  84837. intensity: number;
  84838. rotation: number[];
  84839. specularImageSize: number;
  84840. specularImages: number[][];
  84841. irradianceCoefficients: number[][];
  84842. }
  84843. /** @hidden */
  84844. interface IEXTLightsImageBased {
  84845. lights: IEXTLightsImageBased_LightImageBased[];
  84846. }
  84847. /**
  84848. * Interfaces from the EXT_mesh_gpu_instancing extension
  84849. * !!! Experimental Extension Subject to Changes !!!
  84850. */
  84851. /** @hidden */
  84852. interface IEXTMeshGpuInstancing {
  84853. mesh?: number;
  84854. attributes: { [name: string]: number };
  84855. }
  84856. /**
  84857. * Interfaces from the KHR_draco_mesh_compression extension
  84858. */
  84859. /** @hidden */
  84860. interface IKHRDracoMeshCompression {
  84861. bufferView: number;
  84862. attributes: { [name: string]: number };
  84863. }
  84864. /**
  84865. * Interfaces from the KHR_lights_punctual extension
  84866. */
  84867. /** @hidden */
  84868. const enum IKHRLightsPunctual_LightType {
  84869. DIRECTIONAL = "directional",
  84870. POINT = "point",
  84871. SPOT = "spot"
  84872. }
  84873. /** @hidden */
  84874. interface IKHRLightsPunctual_LightReference {
  84875. light: number;
  84876. }
  84877. /** @hidden */
  84878. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  84879. type: IKHRLightsPunctual_LightType;
  84880. color?: number[];
  84881. intensity?: number;
  84882. range?: number;
  84883. spot?: {
  84884. innerConeAngle?: number;
  84885. outerConeAngle?: number;
  84886. };
  84887. }
  84888. /** @hidden */
  84889. interface IKHRLightsPunctual {
  84890. lights: IKHRLightsPunctual_Light[];
  84891. }
  84892. /**
  84893. * Interfaces from the KHR_materials_clearcoat extension
  84894. * !!! Experimental Extension Subject to Changes !!!
  84895. */
  84896. /** @hidden */
  84897. interface IKHRMaterialsClearcoat {
  84898. clearcoatFactor: number;
  84899. clearcoatTexture: ITextureInfo;
  84900. clearcoatRoughnessFactor: number;
  84901. clearcoatRoughnessTexture: ITextureInfo;
  84902. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  84903. }
  84904. /**
  84905. * Interfaces from the KHR_materials_ior extension
  84906. * !!! Experimental Extension Subject to Changes !!!
  84907. */
  84908. /** @hidden */
  84909. interface IKHRMaterialsIor {
  84910. ior: number;
  84911. }
  84912. /**
  84913. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  84914. */
  84915. /** @hidden */
  84916. interface IKHRMaterialsPbrSpecularGlossiness {
  84917. diffuseFactor: number[];
  84918. diffuseTexture: ITextureInfo;
  84919. specularFactor: number[];
  84920. glossinessFactor: number;
  84921. specularGlossinessTexture: ITextureInfo;
  84922. }
  84923. /**
  84924. * Interfaces from the KHR_materials_sheen extension
  84925. * !!! Experimental Extension Subject to Changes !!!
  84926. */
  84927. /** @hidden */
  84928. interface IKHRMaterialsSheen {
  84929. sheenColorFactor?: number[];
  84930. sheenTexture?: ITextureInfo;
  84931. sheenRoughnessFactor?: number;
  84932. }
  84933. /**
  84934. * Interfaces from the KHR_materials_specular extension
  84935. * !!! Experimental Extension Subject to Changes !!!
  84936. */
  84937. /** @hidden */
  84938. interface IKHRMaterialsSpecular {
  84939. specularFactor: number;
  84940. specularColorFactor: number[];
  84941. specularTexture: ITextureInfo;
  84942. }
  84943. /**
  84944. * Interfaces from the KHR_materials_transmission extension
  84945. * !!! Experimental Extension Subject to Changes !!!
  84946. */
  84947. /** @hidden */
  84948. interface IKHRMaterialsTransmission {
  84949. transmissionFactor?: number;
  84950. transmissionTexture?: ITextureInfo;
  84951. }
  84952. /**
  84953. * Interfaces from the KHR_materials_variants extension
  84954. * !!! Experimental Extension Subject to Changes !!!
  84955. */
  84956. /** @hidden */
  84957. interface IKHRMaterialVariants_Mapping extends IProperty {
  84958. mappings: Array<{
  84959. variants: number[];
  84960. material: number;
  84961. }>;
  84962. }
  84963. /** @hidden */
  84964. interface IKHRMaterialVariants_Variant extends IProperty {
  84965. name: string;
  84966. }
  84967. /** @hidden */
  84968. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  84969. variants: Array<IKHRMaterialVariants_Variant>;
  84970. }
  84971. /**
  84972. * Interfaces from the KHR_texture_basisu extension
  84973. * !!! Experimental Extension Subject to Changes !!!
  84974. */
  84975. /** @hidden */
  84976. interface IKHRTextureBasisU {
  84977. source: number;
  84978. }
  84979. /**
  84980. * Interfaces from the EXT_texture_webp extension
  84981. */
  84982. /** @hidden */
  84983. interface IEXTTextureWebP {
  84984. source: number;
  84985. }
  84986. /**
  84987. * Interfaces from the KHR_texture_transform extension
  84988. */
  84989. /** @hidden */
  84990. interface IKHRTextureTransform {
  84991. offset?: number[];
  84992. rotation?: number;
  84993. scale?: number[];
  84994. texCoord?: number;
  84995. }
  84996. /**
  84997. * Interfaces from the KHR_xmp extension
  84998. * !!! Experimental Extension Subject to Changes !!!
  84999. */
  85000. /** @hidden */
  85001. interface IKHRXmp_Data {
  85002. [key: string]: unknown;
  85003. }
  85004. /** @hidden */
  85005. interface IKHRXmp_Gltf {
  85006. packets: IKHRXmp_Data[];
  85007. }
  85008. /** @hidden */
  85009. interface IKHRXmp_Node {
  85010. packet: number;
  85011. }
  85012. /**
  85013. * Interfaces from the MSFT_audio_emitter extension
  85014. */
  85015. /** @hidden */
  85016. interface IMSFTAudioEmitter_ClipReference {
  85017. clip: number;
  85018. weight?: number;
  85019. }
  85020. /** @hidden */
  85021. interface IMSFTAudioEmitter_EmittersReference {
  85022. emitters: number[];
  85023. }
  85024. /** @hidden */
  85025. const enum IMSFTAudioEmitter_DistanceModel {
  85026. linear = "linear",
  85027. inverse = "inverse",
  85028. exponential = "exponential",
  85029. }
  85030. /** @hidden */
  85031. interface IMSFTAudioEmitter_Emitter {
  85032. name?: string;
  85033. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85034. refDistance?: number;
  85035. maxDistance?: number;
  85036. rolloffFactor?: number;
  85037. innerAngle?: number;
  85038. outerAngle?: number;
  85039. loop?: boolean;
  85040. volume?: number;
  85041. clips: IMSFTAudioEmitter_ClipReference[];
  85042. }
  85043. /** @hidden */
  85044. const enum IMSFTAudioEmitter_AudioMimeType {
  85045. WAV = "audio/wav",
  85046. }
  85047. /** @hidden */
  85048. interface IMSFTAudioEmitter_Clip extends IProperty {
  85049. uri?: string;
  85050. bufferView?: number;
  85051. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85052. }
  85053. /** @hidden */
  85054. const enum IMSFTAudioEmitter_AnimationEventAction {
  85055. play = "play",
  85056. pause = "pause",
  85057. stop = "stop",
  85058. }
  85059. /** @hidden */
  85060. interface IMSFTAudioEmitter_AnimationEvent {
  85061. action: IMSFTAudioEmitter_AnimationEventAction;
  85062. emitter: number;
  85063. time: number;
  85064. startOffset?: number;
  85065. }
  85066. /**
  85067. * Interfaces from the MSFT_lod extension
  85068. */
  85069. /** @hidden */
  85070. interface IMSFTLOD {
  85071. ids: number[];
  85072. }
  85073. }
  85074. declare module BABYLON {
  85075. /** @hidden */
  85076. export var cellPixelShader: {
  85077. name: string;
  85078. shader: string;
  85079. };
  85080. }
  85081. declare module BABYLON {
  85082. /** @hidden */
  85083. export var cellVertexShader: {
  85084. name: string;
  85085. shader: string;
  85086. };
  85087. }
  85088. declare module BABYLON {
  85089. export class CellMaterial extends BABYLON.PushMaterial {
  85090. private _diffuseTexture;
  85091. diffuseTexture: BABYLON.BaseTexture;
  85092. diffuseColor: BABYLON.Color3;
  85093. _computeHighLevel: boolean;
  85094. computeHighLevel: boolean;
  85095. private _disableLighting;
  85096. disableLighting: boolean;
  85097. private _maxSimultaneousLights;
  85098. maxSimultaneousLights: number;
  85099. constructor(name: string, scene: BABYLON.Scene);
  85100. needAlphaBlending(): boolean;
  85101. needAlphaTesting(): boolean;
  85102. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85103. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85104. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85105. getAnimatables(): BABYLON.IAnimatable[];
  85106. getActiveTextures(): BABYLON.BaseTexture[];
  85107. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85108. dispose(forceDisposeEffect?: boolean): void;
  85109. getClassName(): string;
  85110. clone(name: string): CellMaterial;
  85111. serialize(): any;
  85112. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85113. }
  85114. }
  85115. declare module BABYLON {
  85116. export class CustomShaderStructure {
  85117. FragmentStore: string;
  85118. VertexStore: string;
  85119. constructor();
  85120. }
  85121. export class ShaderSpecialParts {
  85122. constructor();
  85123. Fragment_Begin: string;
  85124. Fragment_Definitions: string;
  85125. Fragment_MainBegin: string;
  85126. Fragment_Custom_Diffuse: string;
  85127. Fragment_Before_Lights: string;
  85128. Fragment_Before_Fog: string;
  85129. Fragment_Custom_Alpha: string;
  85130. Fragment_Before_FragColor: string;
  85131. Vertex_Begin: string;
  85132. Vertex_Definitions: string;
  85133. Vertex_MainBegin: string;
  85134. Vertex_Before_PositionUpdated: string;
  85135. Vertex_Before_NormalUpdated: string;
  85136. Vertex_After_WorldPosComputed: string;
  85137. Vertex_MainEnd: string;
  85138. }
  85139. export class CustomMaterial extends BABYLON.StandardMaterial {
  85140. static ShaderIndexer: number;
  85141. CustomParts: ShaderSpecialParts;
  85142. _isCreatedShader: boolean;
  85143. _createdShaderName: string;
  85144. _customUniform: string[];
  85145. _newUniforms: string[];
  85146. _newUniformInstances: {
  85147. [name: string]: any;
  85148. };
  85149. _newSamplerInstances: {
  85150. [name: string]: BABYLON.Texture;
  85151. };
  85152. _customAttributes: string[];
  85153. FragmentShader: string;
  85154. VertexShader: string;
  85155. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85156. ReviewUniform(name: string, arr: string[]): string[];
  85157. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85158. constructor(name: string, scene: BABYLON.Scene);
  85159. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  85160. AddAttribute(name: string): CustomMaterial;
  85161. Fragment_Begin(shaderPart: string): CustomMaterial;
  85162. Fragment_Definitions(shaderPart: string): CustomMaterial;
  85163. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  85164. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  85165. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  85166. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  85167. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  85168. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  85169. Vertex_Begin(shaderPart: string): CustomMaterial;
  85170. Vertex_Definitions(shaderPart: string): CustomMaterial;
  85171. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  85172. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  85173. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  85174. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  85175. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  85176. }
  85177. }
  85178. declare module BABYLON {
  85179. export class ShaderAlebdoParts {
  85180. constructor();
  85181. Fragment_Begin: string;
  85182. Fragment_Definitions: string;
  85183. Fragment_MainBegin: string;
  85184. Fragment_Custom_Albedo: string;
  85185. Fragment_Before_Lights: string;
  85186. Fragment_Custom_MetallicRoughness: string;
  85187. Fragment_Custom_MicroSurface: string;
  85188. Fragment_Before_Fog: string;
  85189. Fragment_Custom_Alpha: string;
  85190. Fragment_Before_FragColor: string;
  85191. Vertex_Begin: string;
  85192. Vertex_Definitions: string;
  85193. Vertex_MainBegin: string;
  85194. Vertex_Before_PositionUpdated: string;
  85195. Vertex_Before_NormalUpdated: string;
  85196. Vertex_After_WorldPosComputed: string;
  85197. Vertex_MainEnd: string;
  85198. }
  85199. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  85200. static ShaderIndexer: number;
  85201. CustomParts: ShaderAlebdoParts;
  85202. _isCreatedShader: boolean;
  85203. _createdShaderName: string;
  85204. _customUniform: string[];
  85205. _newUniforms: string[];
  85206. _newUniformInstances: {
  85207. [name: string]: any;
  85208. };
  85209. _newSamplerInstances: {
  85210. [name: string]: BABYLON.Texture;
  85211. };
  85212. _customAttributes: string[];
  85213. FragmentShader: string;
  85214. VertexShader: string;
  85215. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85216. ReviewUniform(name: string, arr: string[]): string[];
  85217. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85218. constructor(name: string, scene: BABYLON.Scene);
  85219. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  85220. AddAttribute(name: string): PBRCustomMaterial;
  85221. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  85222. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  85223. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  85224. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  85225. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  85226. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  85227. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  85228. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  85229. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  85230. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  85231. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  85232. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  85233. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  85234. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  85235. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  85236. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  85237. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  85238. }
  85239. }
  85240. declare module BABYLON {
  85241. /** @hidden */
  85242. export var firePixelShader: {
  85243. name: string;
  85244. shader: string;
  85245. };
  85246. }
  85247. declare module BABYLON {
  85248. /** @hidden */
  85249. export var fireVertexShader: {
  85250. name: string;
  85251. shader: string;
  85252. };
  85253. }
  85254. declare module BABYLON {
  85255. export class FireMaterial extends BABYLON.PushMaterial {
  85256. private _diffuseTexture;
  85257. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85258. private _distortionTexture;
  85259. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85260. private _opacityTexture;
  85261. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85262. diffuseColor: BABYLON.Color3;
  85263. speed: number;
  85264. private _scaledDiffuse;
  85265. private _lastTime;
  85266. constructor(name: string, scene: BABYLON.Scene);
  85267. needAlphaBlending(): boolean;
  85268. needAlphaTesting(): boolean;
  85269. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85270. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85271. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85272. getAnimatables(): BABYLON.IAnimatable[];
  85273. getActiveTextures(): BABYLON.BaseTexture[];
  85274. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85275. getClassName(): string;
  85276. dispose(forceDisposeEffect?: boolean): void;
  85277. clone(name: string): FireMaterial;
  85278. serialize(): any;
  85279. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  85280. }
  85281. }
  85282. declare module BABYLON {
  85283. /** @hidden */
  85284. export var furPixelShader: {
  85285. name: string;
  85286. shader: string;
  85287. };
  85288. }
  85289. declare module BABYLON {
  85290. /** @hidden */
  85291. export var furVertexShader: {
  85292. name: string;
  85293. shader: string;
  85294. };
  85295. }
  85296. declare module BABYLON {
  85297. export class FurMaterial extends BABYLON.PushMaterial {
  85298. private _diffuseTexture;
  85299. diffuseTexture: BABYLON.BaseTexture;
  85300. private _heightTexture;
  85301. heightTexture: BABYLON.BaseTexture;
  85302. diffuseColor: BABYLON.Color3;
  85303. furLength: number;
  85304. furAngle: number;
  85305. furColor: BABYLON.Color3;
  85306. furOffset: number;
  85307. furSpacing: number;
  85308. furGravity: BABYLON.Vector3;
  85309. furSpeed: number;
  85310. furDensity: number;
  85311. furOcclusion: number;
  85312. furTexture: BABYLON.DynamicTexture;
  85313. private _disableLighting;
  85314. disableLighting: boolean;
  85315. private _maxSimultaneousLights;
  85316. maxSimultaneousLights: number;
  85317. highLevelFur: boolean;
  85318. _meshes: BABYLON.AbstractMesh[];
  85319. private _furTime;
  85320. constructor(name: string, scene: BABYLON.Scene);
  85321. get furTime(): number;
  85322. set furTime(furTime: number);
  85323. needAlphaBlending(): boolean;
  85324. needAlphaTesting(): boolean;
  85325. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85326. updateFur(): void;
  85327. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85328. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85329. getAnimatables(): BABYLON.IAnimatable[];
  85330. getActiveTextures(): BABYLON.BaseTexture[];
  85331. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85332. dispose(forceDisposeEffect?: boolean): void;
  85333. clone(name: string): FurMaterial;
  85334. serialize(): any;
  85335. getClassName(): string;
  85336. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  85337. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  85338. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  85339. }
  85340. }
  85341. declare module BABYLON {
  85342. /** @hidden */
  85343. export var gradientPixelShader: {
  85344. name: string;
  85345. shader: string;
  85346. };
  85347. }
  85348. declare module BABYLON {
  85349. /** @hidden */
  85350. export var gradientVertexShader: {
  85351. name: string;
  85352. shader: string;
  85353. };
  85354. }
  85355. declare module BABYLON {
  85356. export class GradientMaterial extends BABYLON.PushMaterial {
  85357. private _maxSimultaneousLights;
  85358. maxSimultaneousLights: number;
  85359. topColor: BABYLON.Color3;
  85360. topColorAlpha: number;
  85361. bottomColor: BABYLON.Color3;
  85362. bottomColorAlpha: number;
  85363. offset: number;
  85364. scale: number;
  85365. smoothness: number;
  85366. private _disableLighting;
  85367. disableLighting: boolean;
  85368. constructor(name: string, scene: BABYLON.Scene);
  85369. needAlphaBlending(): boolean;
  85370. needAlphaTesting(): boolean;
  85371. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85372. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85373. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85374. getAnimatables(): BABYLON.IAnimatable[];
  85375. dispose(forceDisposeEffect?: boolean): void;
  85376. clone(name: string): GradientMaterial;
  85377. serialize(): any;
  85378. getClassName(): string;
  85379. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  85380. }
  85381. }
  85382. declare module BABYLON {
  85383. /** @hidden */
  85384. export var gridPixelShader: {
  85385. name: string;
  85386. shader: string;
  85387. };
  85388. }
  85389. declare module BABYLON {
  85390. /** @hidden */
  85391. export var gridVertexShader: {
  85392. name: string;
  85393. shader: string;
  85394. };
  85395. }
  85396. declare module BABYLON {
  85397. /**
  85398. * The grid materials allows you to wrap any shape with a grid.
  85399. * Colors are customizable.
  85400. */
  85401. export class GridMaterial extends BABYLON.PushMaterial {
  85402. /**
  85403. * Main color of the grid (e.g. between lines)
  85404. */
  85405. mainColor: BABYLON.Color3;
  85406. /**
  85407. * Color of the grid lines.
  85408. */
  85409. lineColor: BABYLON.Color3;
  85410. /**
  85411. * The scale of the grid compared to unit.
  85412. */
  85413. gridRatio: number;
  85414. /**
  85415. * Allows setting an offset for the grid lines.
  85416. */
  85417. gridOffset: BABYLON.Vector3;
  85418. /**
  85419. * The frequency of thicker lines.
  85420. */
  85421. majorUnitFrequency: number;
  85422. /**
  85423. * The visibility of minor units in the grid.
  85424. */
  85425. minorUnitVisibility: number;
  85426. /**
  85427. * The grid opacity outside of the lines.
  85428. */
  85429. opacity: number;
  85430. /**
  85431. * Determine RBG output is premultiplied by alpha value.
  85432. */
  85433. preMultiplyAlpha: boolean;
  85434. private _opacityTexture;
  85435. opacityTexture: BABYLON.BaseTexture;
  85436. private _gridControl;
  85437. /**
  85438. * constructor
  85439. * @param name The name given to the material in order to identify it afterwards.
  85440. * @param scene The scene the material is used in.
  85441. */
  85442. constructor(name: string, scene: BABYLON.Scene);
  85443. /**
  85444. * Returns wehter or not the grid requires alpha blending.
  85445. */
  85446. needAlphaBlending(): boolean;
  85447. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85448. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85449. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85450. /**
  85451. * Dispose the material and its associated resources.
  85452. * @param forceDisposeEffect will also dispose the used effect when true
  85453. */
  85454. dispose(forceDisposeEffect?: boolean): void;
  85455. clone(name: string): GridMaterial;
  85456. serialize(): any;
  85457. getClassName(): string;
  85458. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  85459. }
  85460. }
  85461. declare module BABYLON {
  85462. /** @hidden */
  85463. export var lavaPixelShader: {
  85464. name: string;
  85465. shader: string;
  85466. };
  85467. }
  85468. declare module BABYLON {
  85469. /** @hidden */
  85470. export var lavaVertexShader: {
  85471. name: string;
  85472. shader: string;
  85473. };
  85474. }
  85475. declare module BABYLON {
  85476. export class LavaMaterial extends BABYLON.PushMaterial {
  85477. private _diffuseTexture;
  85478. diffuseTexture: BABYLON.BaseTexture;
  85479. noiseTexture: BABYLON.BaseTexture;
  85480. fogColor: BABYLON.Color3;
  85481. speed: number;
  85482. movingSpeed: number;
  85483. lowFrequencySpeed: number;
  85484. fogDensity: number;
  85485. private _lastTime;
  85486. diffuseColor: BABYLON.Color3;
  85487. private _disableLighting;
  85488. disableLighting: boolean;
  85489. private _unlit;
  85490. unlit: boolean;
  85491. private _maxSimultaneousLights;
  85492. maxSimultaneousLights: number;
  85493. private _scaledDiffuse;
  85494. constructor(name: string, scene: BABYLON.Scene);
  85495. needAlphaBlending(): boolean;
  85496. needAlphaTesting(): boolean;
  85497. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85498. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85499. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85500. getAnimatables(): BABYLON.IAnimatable[];
  85501. getActiveTextures(): BABYLON.BaseTexture[];
  85502. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85503. dispose(forceDisposeEffect?: boolean): void;
  85504. clone(name: string): LavaMaterial;
  85505. serialize(): any;
  85506. getClassName(): string;
  85507. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  85508. }
  85509. }
  85510. declare module BABYLON {
  85511. /** @hidden */
  85512. export var mixPixelShader: {
  85513. name: string;
  85514. shader: string;
  85515. };
  85516. }
  85517. declare module BABYLON {
  85518. /** @hidden */
  85519. export var mixVertexShader: {
  85520. name: string;
  85521. shader: string;
  85522. };
  85523. }
  85524. declare module BABYLON {
  85525. export class MixMaterial extends BABYLON.PushMaterial {
  85526. /**
  85527. * Mix textures
  85528. */
  85529. private _mixTexture1;
  85530. mixTexture1: BABYLON.BaseTexture;
  85531. private _mixTexture2;
  85532. mixTexture2: BABYLON.BaseTexture;
  85533. /**
  85534. * Diffuse textures
  85535. */
  85536. private _diffuseTexture1;
  85537. diffuseTexture1: BABYLON.Texture;
  85538. private _diffuseTexture2;
  85539. diffuseTexture2: BABYLON.Texture;
  85540. private _diffuseTexture3;
  85541. diffuseTexture3: BABYLON.Texture;
  85542. private _diffuseTexture4;
  85543. diffuseTexture4: BABYLON.Texture;
  85544. private _diffuseTexture5;
  85545. diffuseTexture5: BABYLON.Texture;
  85546. private _diffuseTexture6;
  85547. diffuseTexture6: BABYLON.Texture;
  85548. private _diffuseTexture7;
  85549. diffuseTexture7: BABYLON.Texture;
  85550. private _diffuseTexture8;
  85551. diffuseTexture8: BABYLON.Texture;
  85552. /**
  85553. * Uniforms
  85554. */
  85555. diffuseColor: BABYLON.Color3;
  85556. specularColor: BABYLON.Color3;
  85557. specularPower: number;
  85558. private _disableLighting;
  85559. disableLighting: boolean;
  85560. private _maxSimultaneousLights;
  85561. maxSimultaneousLights: number;
  85562. constructor(name: string, scene: BABYLON.Scene);
  85563. needAlphaBlending(): boolean;
  85564. needAlphaTesting(): boolean;
  85565. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85566. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85567. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85568. getAnimatables(): BABYLON.IAnimatable[];
  85569. getActiveTextures(): BABYLON.BaseTexture[];
  85570. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85571. dispose(forceDisposeEffect?: boolean): void;
  85572. clone(name: string): MixMaterial;
  85573. serialize(): any;
  85574. getClassName(): string;
  85575. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  85576. }
  85577. }
  85578. declare module BABYLON {
  85579. /** @hidden */
  85580. export var normalPixelShader: {
  85581. name: string;
  85582. shader: string;
  85583. };
  85584. }
  85585. declare module BABYLON {
  85586. /** @hidden */
  85587. export var normalVertexShader: {
  85588. name: string;
  85589. shader: string;
  85590. };
  85591. }
  85592. declare module BABYLON {
  85593. export class NormalMaterial extends BABYLON.PushMaterial {
  85594. private _diffuseTexture;
  85595. diffuseTexture: BABYLON.BaseTexture;
  85596. diffuseColor: BABYLON.Color3;
  85597. private _disableLighting;
  85598. disableLighting: boolean;
  85599. private _maxSimultaneousLights;
  85600. maxSimultaneousLights: number;
  85601. constructor(name: string, scene: BABYLON.Scene);
  85602. needAlphaBlending(): boolean;
  85603. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85604. needAlphaTesting(): boolean;
  85605. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85606. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85607. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85608. getAnimatables(): BABYLON.IAnimatable[];
  85609. getActiveTextures(): BABYLON.BaseTexture[];
  85610. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85611. dispose(forceDisposeEffect?: boolean): void;
  85612. clone(name: string): NormalMaterial;
  85613. serialize(): any;
  85614. getClassName(): string;
  85615. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  85616. }
  85617. }
  85618. declare module BABYLON {
  85619. /** @hidden */
  85620. export var shadowOnlyPixelShader: {
  85621. name: string;
  85622. shader: string;
  85623. };
  85624. }
  85625. declare module BABYLON {
  85626. /** @hidden */
  85627. export var shadowOnlyVertexShader: {
  85628. name: string;
  85629. shader: string;
  85630. };
  85631. }
  85632. declare module BABYLON {
  85633. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  85634. private _activeLight;
  85635. private _needAlphaBlending;
  85636. constructor(name: string, scene: BABYLON.Scene);
  85637. shadowColor: BABYLON.Color3;
  85638. needAlphaBlending(): boolean;
  85639. needAlphaTesting(): boolean;
  85640. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85641. get activeLight(): BABYLON.IShadowLight;
  85642. set activeLight(light: BABYLON.IShadowLight);
  85643. private _getFirstShadowLightForMesh;
  85644. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85645. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85646. clone(name: string): ShadowOnlyMaterial;
  85647. serialize(): any;
  85648. getClassName(): string;
  85649. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  85650. }
  85651. }
  85652. declare module BABYLON {
  85653. /** @hidden */
  85654. export var simplePixelShader: {
  85655. name: string;
  85656. shader: string;
  85657. };
  85658. }
  85659. declare module BABYLON {
  85660. /** @hidden */
  85661. export var simpleVertexShader: {
  85662. name: string;
  85663. shader: string;
  85664. };
  85665. }
  85666. declare module BABYLON {
  85667. export class SimpleMaterial extends BABYLON.PushMaterial {
  85668. private _diffuseTexture;
  85669. diffuseTexture: BABYLON.BaseTexture;
  85670. diffuseColor: BABYLON.Color3;
  85671. private _disableLighting;
  85672. disableLighting: boolean;
  85673. private _maxSimultaneousLights;
  85674. maxSimultaneousLights: number;
  85675. constructor(name: string, scene: BABYLON.Scene);
  85676. needAlphaBlending(): boolean;
  85677. needAlphaTesting(): boolean;
  85678. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85679. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85680. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85681. getAnimatables(): BABYLON.IAnimatable[];
  85682. getActiveTextures(): BABYLON.BaseTexture[];
  85683. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85684. dispose(forceDisposeEffect?: boolean): void;
  85685. clone(name: string): SimpleMaterial;
  85686. serialize(): any;
  85687. getClassName(): string;
  85688. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  85689. }
  85690. }
  85691. declare module BABYLON {
  85692. /** @hidden */
  85693. export var skyPixelShader: {
  85694. name: string;
  85695. shader: string;
  85696. };
  85697. }
  85698. declare module BABYLON {
  85699. /** @hidden */
  85700. export var skyVertexShader: {
  85701. name: string;
  85702. shader: string;
  85703. };
  85704. }
  85705. declare module BABYLON {
  85706. /**
  85707. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  85708. * @see https://doc.babylonjs.com/extensions/sky
  85709. */
  85710. export class SkyMaterial extends BABYLON.PushMaterial {
  85711. /**
  85712. * Defines the overall luminance of sky in interval ]0, 1[.
  85713. */
  85714. luminance: number;
  85715. /**
  85716. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  85717. */
  85718. turbidity: number;
  85719. /**
  85720. * Defines the sky appearance (light intensity).
  85721. */
  85722. rayleigh: number;
  85723. /**
  85724. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  85725. */
  85726. mieCoefficient: number;
  85727. /**
  85728. * Defines the amount of haze particles following the Mie scattering theory.
  85729. */
  85730. mieDirectionalG: number;
  85731. /**
  85732. * Defines the distance of the sun according to the active scene camera.
  85733. */
  85734. distance: number;
  85735. /**
  85736. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  85737. * "inclined".
  85738. */
  85739. inclination: number;
  85740. /**
  85741. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  85742. * an object direction and a reference direction.
  85743. */
  85744. azimuth: number;
  85745. /**
  85746. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  85747. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  85748. */
  85749. sunPosition: BABYLON.Vector3;
  85750. /**
  85751. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  85752. * .sunPosition property.
  85753. */
  85754. useSunPosition: boolean;
  85755. /**
  85756. * Defines an offset vector used to get a horizon offset.
  85757. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  85758. */
  85759. cameraOffset: BABYLON.Vector3;
  85760. private _cameraPosition;
  85761. /**
  85762. * Instantiates a new sky material.
  85763. * This material allows to create dynamic and texture free
  85764. * effects for skyboxes by taking care of the atmosphere state.
  85765. * @see https://doc.babylonjs.com/extensions/sky
  85766. * @param name Define the name of the material in the scene
  85767. * @param scene Define the scene the material belong to
  85768. */
  85769. constructor(name: string, scene: BABYLON.Scene);
  85770. /**
  85771. * Specifies if the material will require alpha blending
  85772. * @returns a boolean specifying if alpha blending is needed
  85773. */
  85774. needAlphaBlending(): boolean;
  85775. /**
  85776. * Specifies if this material should be rendered in alpha test mode
  85777. * @returns false as the sky material doesn't need alpha testing.
  85778. */
  85779. needAlphaTesting(): boolean;
  85780. /**
  85781. * Get the texture used for alpha test purpose.
  85782. * @returns null as the sky material has no texture.
  85783. */
  85784. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85785. /**
  85786. * Get if the submesh is ready to be used and all its information available.
  85787. * Child classes can use it to update shaders
  85788. * @param mesh defines the mesh to check
  85789. * @param subMesh defines which submesh to check
  85790. * @param useInstances specifies that instances should be used
  85791. * @returns a boolean indicating that the submesh is ready or not
  85792. */
  85793. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85794. /**
  85795. * Binds the submesh to this material by preparing the effect and shader to draw
  85796. * @param world defines the world transformation matrix
  85797. * @param mesh defines the mesh containing the submesh
  85798. * @param subMesh defines the submesh to bind the material to
  85799. */
  85800. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85801. /**
  85802. * Get the list of animatables in the material.
  85803. * @returns the list of animatables object used in the material
  85804. */
  85805. getAnimatables(): BABYLON.IAnimatable[];
  85806. /**
  85807. * Disposes the material
  85808. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85809. */
  85810. dispose(forceDisposeEffect?: boolean): void;
  85811. /**
  85812. * Makes a duplicate of the material, and gives it a new name
  85813. * @param name defines the new name for the duplicated material
  85814. * @returns the cloned material
  85815. */
  85816. clone(name: string): SkyMaterial;
  85817. /**
  85818. * Serializes this material in a JSON representation
  85819. * @returns the serialized material object
  85820. */
  85821. serialize(): any;
  85822. /**
  85823. * Gets the current class name of the material e.g. "SkyMaterial"
  85824. * Mainly use in serialization.
  85825. * @returns the class name
  85826. */
  85827. getClassName(): string;
  85828. /**
  85829. * Creates a sky material from parsed material data
  85830. * @param source defines the JSON representation of the material
  85831. * @param scene defines the hosting scene
  85832. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85833. * @returns a new sky material
  85834. */
  85835. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  85836. }
  85837. }
  85838. declare module BABYLON {
  85839. /** @hidden */
  85840. export var terrainPixelShader: {
  85841. name: string;
  85842. shader: string;
  85843. };
  85844. }
  85845. declare module BABYLON {
  85846. /** @hidden */
  85847. export var terrainVertexShader: {
  85848. name: string;
  85849. shader: string;
  85850. };
  85851. }
  85852. declare module BABYLON {
  85853. export class TerrainMaterial extends BABYLON.PushMaterial {
  85854. private _mixTexture;
  85855. mixTexture: BABYLON.BaseTexture;
  85856. private _diffuseTexture1;
  85857. diffuseTexture1: BABYLON.Texture;
  85858. private _diffuseTexture2;
  85859. diffuseTexture2: BABYLON.Texture;
  85860. private _diffuseTexture3;
  85861. diffuseTexture3: BABYLON.Texture;
  85862. private _bumpTexture1;
  85863. bumpTexture1: BABYLON.Texture;
  85864. private _bumpTexture2;
  85865. bumpTexture2: BABYLON.Texture;
  85866. private _bumpTexture3;
  85867. bumpTexture3: BABYLON.Texture;
  85868. diffuseColor: BABYLON.Color3;
  85869. specularColor: BABYLON.Color3;
  85870. specularPower: number;
  85871. private _disableLighting;
  85872. disableLighting: boolean;
  85873. private _maxSimultaneousLights;
  85874. maxSimultaneousLights: number;
  85875. constructor(name: string, scene: BABYLON.Scene);
  85876. needAlphaBlending(): boolean;
  85877. needAlphaTesting(): boolean;
  85878. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85879. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85880. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85881. getAnimatables(): BABYLON.IAnimatable[];
  85882. getActiveTextures(): BABYLON.BaseTexture[];
  85883. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85884. dispose(forceDisposeEffect?: boolean): void;
  85885. clone(name: string): TerrainMaterial;
  85886. serialize(): any;
  85887. getClassName(): string;
  85888. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  85889. }
  85890. }
  85891. declare module BABYLON {
  85892. /** @hidden */
  85893. export var triplanarPixelShader: {
  85894. name: string;
  85895. shader: string;
  85896. };
  85897. }
  85898. declare module BABYLON {
  85899. /** @hidden */
  85900. export var triplanarVertexShader: {
  85901. name: string;
  85902. shader: string;
  85903. };
  85904. }
  85905. declare module BABYLON {
  85906. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  85907. mixTexture: BABYLON.BaseTexture;
  85908. private _diffuseTextureX;
  85909. diffuseTextureX: BABYLON.BaseTexture;
  85910. private _diffuseTextureY;
  85911. diffuseTextureY: BABYLON.BaseTexture;
  85912. private _diffuseTextureZ;
  85913. diffuseTextureZ: BABYLON.BaseTexture;
  85914. private _normalTextureX;
  85915. normalTextureX: BABYLON.BaseTexture;
  85916. private _normalTextureY;
  85917. normalTextureY: BABYLON.BaseTexture;
  85918. private _normalTextureZ;
  85919. normalTextureZ: BABYLON.BaseTexture;
  85920. tileSize: number;
  85921. diffuseColor: BABYLON.Color3;
  85922. specularColor: BABYLON.Color3;
  85923. specularPower: number;
  85924. private _disableLighting;
  85925. disableLighting: boolean;
  85926. private _maxSimultaneousLights;
  85927. maxSimultaneousLights: number;
  85928. constructor(name: string, scene: BABYLON.Scene);
  85929. needAlphaBlending(): boolean;
  85930. needAlphaTesting(): boolean;
  85931. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85932. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85933. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85934. getAnimatables(): BABYLON.IAnimatable[];
  85935. getActiveTextures(): BABYLON.BaseTexture[];
  85936. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85937. dispose(forceDisposeEffect?: boolean): void;
  85938. clone(name: string): TriPlanarMaterial;
  85939. serialize(): any;
  85940. getClassName(): string;
  85941. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  85942. }
  85943. }
  85944. declare module BABYLON {
  85945. /** @hidden */
  85946. export var waterPixelShader: {
  85947. name: string;
  85948. shader: string;
  85949. };
  85950. }
  85951. declare module BABYLON {
  85952. /** @hidden */
  85953. export var waterVertexShader: {
  85954. name: string;
  85955. shader: string;
  85956. };
  85957. }
  85958. declare module BABYLON {
  85959. export class WaterMaterial extends BABYLON.PushMaterial {
  85960. renderTargetSize: BABYLON.Vector2;
  85961. private _bumpTexture;
  85962. bumpTexture: BABYLON.BaseTexture;
  85963. diffuseColor: BABYLON.Color3;
  85964. specularColor: BABYLON.Color3;
  85965. specularPower: number;
  85966. private _disableLighting;
  85967. disableLighting: boolean;
  85968. private _maxSimultaneousLights;
  85969. maxSimultaneousLights: number;
  85970. /**
  85971. * @param {number}: Represents the wind force
  85972. */
  85973. windForce: number;
  85974. /**
  85975. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  85976. */
  85977. windDirection: BABYLON.Vector2;
  85978. /**
  85979. * @param {number}: Wave height, represents the height of the waves
  85980. */
  85981. waveHeight: number;
  85982. /**
  85983. * @param {number}: Bump height, represents the bump height related to the bump map
  85984. */
  85985. bumpHeight: number;
  85986. /**
  85987. * @param {boolean}: Add a smaller moving bump to less steady waves.
  85988. */
  85989. private _bumpSuperimpose;
  85990. bumpSuperimpose: boolean;
  85991. /**
  85992. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  85993. */
  85994. private _fresnelSeparate;
  85995. fresnelSeparate: boolean;
  85996. /**
  85997. * @param {boolean}: bump Waves modify the reflection.
  85998. */
  85999. private _bumpAffectsReflection;
  86000. bumpAffectsReflection: boolean;
  86001. /**
  86002. * @param {number}: The water color blended with the refraction (near)
  86003. */
  86004. waterColor: BABYLON.Color3;
  86005. /**
  86006. * @param {number}: The blend factor related to the water color
  86007. */
  86008. colorBlendFactor: number;
  86009. /**
  86010. * @param {number}: The water color blended with the reflection (far)
  86011. */
  86012. waterColor2: BABYLON.Color3;
  86013. /**
  86014. * @param {number}: The blend factor related to the water color (reflection, far)
  86015. */
  86016. colorBlendFactor2: number;
  86017. /**
  86018. * @param {number}: Represents the maximum length of a wave
  86019. */
  86020. waveLength: number;
  86021. /**
  86022. * @param {number}: Defines the waves speed
  86023. */
  86024. waveSpeed: number;
  86025. /**
  86026. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86027. * will avoid calculating useless pixels in the pixel shader of the water material.
  86028. */
  86029. disableClipPlane: boolean;
  86030. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86031. private _mesh;
  86032. private _refractionRTT;
  86033. private _reflectionRTT;
  86034. private _reflectionTransform;
  86035. private _lastTime;
  86036. private _lastDeltaTime;
  86037. private _useLogarithmicDepth;
  86038. private _waitingRenderList;
  86039. private _imageProcessingConfiguration;
  86040. private _imageProcessingObserver;
  86041. /**
  86042. * Gets a boolean indicating that current material needs to register RTT
  86043. */
  86044. get hasRenderTargetTextures(): boolean;
  86045. /**
  86046. * Constructor
  86047. */
  86048. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86049. get useLogarithmicDepth(): boolean;
  86050. set useLogarithmicDepth(value: boolean);
  86051. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86052. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86053. addToRenderList(node: any): void;
  86054. enableRenderTargets(enable: boolean): void;
  86055. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86056. get renderTargetsEnabled(): boolean;
  86057. needAlphaBlending(): boolean;
  86058. needAlphaTesting(): boolean;
  86059. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86060. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86061. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86062. private _createRenderTargets;
  86063. getAnimatables(): BABYLON.IAnimatable[];
  86064. getActiveTextures(): BABYLON.BaseTexture[];
  86065. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86066. dispose(forceDisposeEffect?: boolean): void;
  86067. clone(name: string): WaterMaterial;
  86068. serialize(): any;
  86069. getClassName(): string;
  86070. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86071. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86072. }
  86073. }
  86074. declare module BABYLON {
  86075. /** @hidden */
  86076. export var asciiartPixelShader: {
  86077. name: string;
  86078. shader: string;
  86079. };
  86080. }
  86081. declare module BABYLON {
  86082. /**
  86083. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86084. *
  86085. * It basically takes care rendering the font front the given font size to a texture.
  86086. * This is used later on in the postprocess.
  86087. */
  86088. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86089. private _font;
  86090. private _text;
  86091. private _charSize;
  86092. /**
  86093. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86094. */
  86095. get charSize(): number;
  86096. /**
  86097. * Create a new instance of the Ascii Art FontTexture class
  86098. * @param name the name of the texture
  86099. * @param font the font to use, use the W3C CSS notation
  86100. * @param text the caracter set to use in the rendering.
  86101. * @param scene the scene that owns the texture
  86102. */
  86103. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86104. /**
  86105. * Gets the max char width of a font.
  86106. * @param font the font to use, use the W3C CSS notation
  86107. * @return the max char width
  86108. */
  86109. private getFontWidth;
  86110. /**
  86111. * Gets the max char height of a font.
  86112. * @param font the font to use, use the W3C CSS notation
  86113. * @return the max char height
  86114. */
  86115. private getFontHeight;
  86116. /**
  86117. * Clones the current AsciiArtTexture.
  86118. * @return the clone of the texture.
  86119. */
  86120. clone(): AsciiArtFontTexture;
  86121. /**
  86122. * Parses a json object representing the texture and returns an instance of it.
  86123. * @param source the source JSON representation
  86124. * @param scene the scene to create the texture for
  86125. * @return the parsed texture
  86126. */
  86127. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86128. }
  86129. /**
  86130. * Option available in the Ascii Art Post Process.
  86131. */
  86132. export interface IAsciiArtPostProcessOptions {
  86133. /**
  86134. * The font to use following the w3c font definition.
  86135. */
  86136. font?: string;
  86137. /**
  86138. * The character set to use in the postprocess.
  86139. */
  86140. characterSet?: string;
  86141. /**
  86142. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86143. * This number is defined between 0 and 1;
  86144. */
  86145. mixToTile?: number;
  86146. /**
  86147. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86148. * This number is defined between 0 and 1;
  86149. */
  86150. mixToNormal?: number;
  86151. }
  86152. /**
  86153. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86154. *
  86155. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86156. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86157. */
  86158. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86159. /**
  86160. * The font texture used to render the char in the post process.
  86161. */
  86162. private _asciiArtFontTexture;
  86163. /**
  86164. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86165. * This number is defined between 0 and 1;
  86166. */
  86167. mixToTile: number;
  86168. /**
  86169. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86170. * This number is defined between 0 and 1;
  86171. */
  86172. mixToNormal: number;
  86173. /**
  86174. * Instantiates a new Ascii Art Post Process.
  86175. * @param name the name to give to the postprocess
  86176. * @camera the camera to apply the post process to.
  86177. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  86178. */
  86179. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  86180. }
  86181. }
  86182. declare module BABYLON {
  86183. /** @hidden */
  86184. export var digitalrainPixelShader: {
  86185. name: string;
  86186. shader: string;
  86187. };
  86188. }
  86189. declare module BABYLON {
  86190. /**
  86191. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  86192. *
  86193. * It basically takes care rendering the font front the given font size to a texture.
  86194. * This is used later on in the postprocess.
  86195. */
  86196. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  86197. private _font;
  86198. private _text;
  86199. private _charSize;
  86200. /**
  86201. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86202. */
  86203. get charSize(): number;
  86204. /**
  86205. * Create a new instance of the Digital Rain FontTexture class
  86206. * @param name the name of the texture
  86207. * @param font the font to use, use the W3C CSS notation
  86208. * @param text the caracter set to use in the rendering.
  86209. * @param scene the scene that owns the texture
  86210. */
  86211. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86212. /**
  86213. * Gets the max char width of a font.
  86214. * @param font the font to use, use the W3C CSS notation
  86215. * @return the max char width
  86216. */
  86217. private getFontWidth;
  86218. /**
  86219. * Gets the max char height of a font.
  86220. * @param font the font to use, use the W3C CSS notation
  86221. * @return the max char height
  86222. */
  86223. private getFontHeight;
  86224. /**
  86225. * Clones the current DigitalRainFontTexture.
  86226. * @return the clone of the texture.
  86227. */
  86228. clone(): DigitalRainFontTexture;
  86229. /**
  86230. * Parses a json object representing the texture and returns an instance of it.
  86231. * @param source the source JSON representation
  86232. * @param scene the scene to create the texture for
  86233. * @return the parsed texture
  86234. */
  86235. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  86236. }
  86237. /**
  86238. * Option available in the Digital Rain Post Process.
  86239. */
  86240. export interface IDigitalRainPostProcessOptions {
  86241. /**
  86242. * The font to use following the w3c font definition.
  86243. */
  86244. font?: string;
  86245. /**
  86246. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86247. * This number is defined between 0 and 1;
  86248. */
  86249. mixToTile?: number;
  86250. /**
  86251. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86252. * This number is defined between 0 and 1;
  86253. */
  86254. mixToNormal?: number;
  86255. }
  86256. /**
  86257. * DigitalRainPostProcess helps rendering everithing in digital rain.
  86258. *
  86259. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86260. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  86261. */
  86262. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  86263. /**
  86264. * The font texture used to render the char in the post process.
  86265. */
  86266. private _digitalRainFontTexture;
  86267. /**
  86268. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86269. * This number is defined between 0 and 1;
  86270. */
  86271. mixToTile: number;
  86272. /**
  86273. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86274. * This number is defined between 0 and 1;
  86275. */
  86276. mixToNormal: number;
  86277. /**
  86278. * Instantiates a new Digital Rain Post Process.
  86279. * @param name the name to give to the postprocess
  86280. * @camera the camera to apply the post process to.
  86281. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  86282. */
  86283. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  86284. }
  86285. }
  86286. declare module BABYLON {
  86287. /** @hidden */
  86288. export var brickProceduralTexturePixelShader: {
  86289. name: string;
  86290. shader: string;
  86291. };
  86292. }
  86293. declare module BABYLON {
  86294. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  86295. private _numberOfBricksHeight;
  86296. private _numberOfBricksWidth;
  86297. private _jointColor;
  86298. private _brickColor;
  86299. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86300. updateShaderUniforms(): void;
  86301. get numberOfBricksHeight(): number;
  86302. set numberOfBricksHeight(value: number);
  86303. get numberOfBricksWidth(): number;
  86304. set numberOfBricksWidth(value: number);
  86305. get jointColor(): BABYLON.Color3;
  86306. set jointColor(value: BABYLON.Color3);
  86307. get brickColor(): BABYLON.Color3;
  86308. set brickColor(value: BABYLON.Color3);
  86309. /**
  86310. * Serializes this brick procedural texture
  86311. * @returns a serialized brick procedural texture object
  86312. */
  86313. serialize(): any;
  86314. /**
  86315. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  86316. * @param parsedTexture defines parsed texture data
  86317. * @param scene defines the current scene
  86318. * @param rootUrl defines the root URL containing brick procedural texture information
  86319. * @returns a parsed Brick Procedural BABYLON.Texture
  86320. */
  86321. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  86322. }
  86323. }
  86324. declare module BABYLON {
  86325. /** @hidden */
  86326. export var cloudProceduralTexturePixelShader: {
  86327. name: string;
  86328. shader: string;
  86329. };
  86330. }
  86331. declare module BABYLON {
  86332. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  86333. private _skyColor;
  86334. private _cloudColor;
  86335. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86336. updateShaderUniforms(): void;
  86337. get skyColor(): BABYLON.Color4;
  86338. set skyColor(value: BABYLON.Color4);
  86339. get cloudColor(): BABYLON.Color4;
  86340. set cloudColor(value: BABYLON.Color4);
  86341. /**
  86342. * Serializes this cloud procedural texture
  86343. * @returns a serialized cloud procedural texture object
  86344. */
  86345. serialize(): any;
  86346. /**
  86347. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  86348. * @param parsedTexture defines parsed texture data
  86349. * @param scene defines the current scene
  86350. * @param rootUrl defines the root URL containing cloud procedural texture information
  86351. * @returns a parsed Cloud Procedural BABYLON.Texture
  86352. */
  86353. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  86354. }
  86355. }
  86356. declare module BABYLON {
  86357. /** @hidden */
  86358. export var fireProceduralTexturePixelShader: {
  86359. name: string;
  86360. shader: string;
  86361. };
  86362. }
  86363. declare module BABYLON {
  86364. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  86365. private _time;
  86366. private _speed;
  86367. private _autoGenerateTime;
  86368. private _fireColors;
  86369. private _alphaThreshold;
  86370. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86371. updateShaderUniforms(): void;
  86372. render(useCameraPostProcess?: boolean): void;
  86373. static get PurpleFireColors(): BABYLON.Color3[];
  86374. static get GreenFireColors(): BABYLON.Color3[];
  86375. static get RedFireColors(): BABYLON.Color3[];
  86376. static get BlueFireColors(): BABYLON.Color3[];
  86377. get autoGenerateTime(): boolean;
  86378. set autoGenerateTime(value: boolean);
  86379. get fireColors(): BABYLON.Color3[];
  86380. set fireColors(value: BABYLON.Color3[]);
  86381. get time(): number;
  86382. set time(value: number);
  86383. get speed(): BABYLON.Vector2;
  86384. set speed(value: BABYLON.Vector2);
  86385. get alphaThreshold(): number;
  86386. set alphaThreshold(value: number);
  86387. /**
  86388. * Serializes this fire procedural texture
  86389. * @returns a serialized fire procedural texture object
  86390. */
  86391. serialize(): any;
  86392. /**
  86393. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  86394. * @param parsedTexture defines parsed texture data
  86395. * @param scene defines the current scene
  86396. * @param rootUrl defines the root URL containing fire procedural texture information
  86397. * @returns a parsed Fire Procedural BABYLON.Texture
  86398. */
  86399. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  86400. }
  86401. }
  86402. declare module BABYLON {
  86403. /** @hidden */
  86404. export var grassProceduralTexturePixelShader: {
  86405. name: string;
  86406. shader: string;
  86407. };
  86408. }
  86409. declare module BABYLON {
  86410. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  86411. private _grassColors;
  86412. private _groundColor;
  86413. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86414. updateShaderUniforms(): void;
  86415. get grassColors(): BABYLON.Color3[];
  86416. set grassColors(value: BABYLON.Color3[]);
  86417. get groundColor(): BABYLON.Color3;
  86418. set groundColor(value: BABYLON.Color3);
  86419. /**
  86420. * Serializes this grass procedural texture
  86421. * @returns a serialized grass procedural texture object
  86422. */
  86423. serialize(): any;
  86424. /**
  86425. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  86426. * @param parsedTexture defines parsed texture data
  86427. * @param scene defines the current scene
  86428. * @param rootUrl defines the root URL containing grass procedural texture information
  86429. * @returns a parsed Grass Procedural BABYLON.Texture
  86430. */
  86431. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  86432. }
  86433. }
  86434. declare module BABYLON {
  86435. /** @hidden */
  86436. export var marbleProceduralTexturePixelShader: {
  86437. name: string;
  86438. shader: string;
  86439. };
  86440. }
  86441. declare module BABYLON {
  86442. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  86443. private _numberOfTilesHeight;
  86444. private _numberOfTilesWidth;
  86445. private _amplitude;
  86446. private _jointColor;
  86447. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86448. updateShaderUniforms(): void;
  86449. get numberOfTilesHeight(): number;
  86450. set numberOfTilesHeight(value: number);
  86451. get amplitude(): number;
  86452. set amplitude(value: number);
  86453. get numberOfTilesWidth(): number;
  86454. set numberOfTilesWidth(value: number);
  86455. get jointColor(): BABYLON.Color3;
  86456. set jointColor(value: BABYLON.Color3);
  86457. /**
  86458. * Serializes this marble procedural texture
  86459. * @returns a serialized marble procedural texture object
  86460. */
  86461. serialize(): any;
  86462. /**
  86463. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  86464. * @param parsedTexture defines parsed texture data
  86465. * @param scene defines the current scene
  86466. * @param rootUrl defines the root URL containing marble procedural texture information
  86467. * @returns a parsed Marble Procedural BABYLON.Texture
  86468. */
  86469. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  86470. }
  86471. }
  86472. declare module BABYLON {
  86473. /** @hidden */
  86474. export var normalMapProceduralTexturePixelShader: {
  86475. name: string;
  86476. shader: string;
  86477. };
  86478. }
  86479. declare module BABYLON {
  86480. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  86481. private _baseTexture;
  86482. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86483. updateShaderUniforms(): void;
  86484. render(useCameraPostProcess?: boolean): void;
  86485. resize(size: any, generateMipMaps: any): void;
  86486. get baseTexture(): BABYLON.Texture;
  86487. set baseTexture(texture: BABYLON.Texture);
  86488. /**
  86489. * Serializes this normal map procedural texture
  86490. * @returns a serialized normal map procedural texture object
  86491. */
  86492. serialize(): any;
  86493. /**
  86494. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  86495. * @param parsedTexture defines parsed texture data
  86496. * @param scene defines the current scene
  86497. * @param rootUrl defines the root URL containing normal map procedural texture information
  86498. * @returns a parsed Normal Map Procedural BABYLON.Texture
  86499. */
  86500. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  86501. }
  86502. }
  86503. declare module BABYLON {
  86504. /** @hidden */
  86505. export var perlinNoiseProceduralTexturePixelShader: {
  86506. name: string;
  86507. shader: string;
  86508. };
  86509. }
  86510. declare module BABYLON {
  86511. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  86512. time: number;
  86513. timeScale: number;
  86514. translationSpeed: number;
  86515. private _currentTranslation;
  86516. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86517. updateShaderUniforms(): void;
  86518. render(useCameraPostProcess?: boolean): void;
  86519. resize(size: any, generateMipMaps: any): void;
  86520. /**
  86521. * Serializes this perlin noise procedural texture
  86522. * @returns a serialized perlin noise procedural texture object
  86523. */
  86524. serialize(): any;
  86525. /**
  86526. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  86527. * @param parsedTexture defines parsed texture data
  86528. * @param scene defines the current scene
  86529. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  86530. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  86531. */
  86532. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  86533. }
  86534. }
  86535. declare module BABYLON {
  86536. /** @hidden */
  86537. export var roadProceduralTexturePixelShader: {
  86538. name: string;
  86539. shader: string;
  86540. };
  86541. }
  86542. declare module BABYLON {
  86543. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  86544. private _roadColor;
  86545. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86546. updateShaderUniforms(): void;
  86547. get roadColor(): BABYLON.Color3;
  86548. set roadColor(value: BABYLON.Color3);
  86549. /**
  86550. * Serializes this road procedural texture
  86551. * @returns a serialized road procedural texture object
  86552. */
  86553. serialize(): any;
  86554. /**
  86555. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  86556. * @param parsedTexture defines parsed texture data
  86557. * @param scene defines the current scene
  86558. * @param rootUrl defines the root URL containing road procedural texture information
  86559. * @returns a parsed Road Procedural BABYLON.Texture
  86560. */
  86561. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  86562. }
  86563. }
  86564. declare module BABYLON {
  86565. /** @hidden */
  86566. export var starfieldProceduralTexturePixelShader: {
  86567. name: string;
  86568. shader: string;
  86569. };
  86570. }
  86571. declare module BABYLON {
  86572. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  86573. private _time;
  86574. private _alpha;
  86575. private _beta;
  86576. private _zoom;
  86577. private _formuparam;
  86578. private _stepsize;
  86579. private _tile;
  86580. private _brightness;
  86581. private _darkmatter;
  86582. private _distfading;
  86583. private _saturation;
  86584. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86585. updateShaderUniforms(): void;
  86586. get time(): number;
  86587. set time(value: number);
  86588. get alpha(): number;
  86589. set alpha(value: number);
  86590. get beta(): number;
  86591. set beta(value: number);
  86592. get formuparam(): number;
  86593. set formuparam(value: number);
  86594. get stepsize(): number;
  86595. set stepsize(value: number);
  86596. get zoom(): number;
  86597. set zoom(value: number);
  86598. get tile(): number;
  86599. set tile(value: number);
  86600. get brightness(): number;
  86601. set brightness(value: number);
  86602. get darkmatter(): number;
  86603. set darkmatter(value: number);
  86604. get distfading(): number;
  86605. set distfading(value: number);
  86606. get saturation(): number;
  86607. set saturation(value: number);
  86608. /**
  86609. * Serializes this starfield procedural texture
  86610. * @returns a serialized starfield procedural texture object
  86611. */
  86612. serialize(): any;
  86613. /**
  86614. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  86615. * @param parsedTexture defines parsed texture data
  86616. * @param scene defines the current scene
  86617. * @param rootUrl defines the root URL containing startfield procedural texture information
  86618. * @returns a parsed Starfield Procedural BABYLON.Texture
  86619. */
  86620. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  86621. }
  86622. }
  86623. declare module BABYLON {
  86624. /** @hidden */
  86625. export var woodProceduralTexturePixelShader: {
  86626. name: string;
  86627. shader: string;
  86628. };
  86629. }
  86630. declare module BABYLON {
  86631. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  86632. private _ampScale;
  86633. private _woodColor;
  86634. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86635. updateShaderUniforms(): void;
  86636. get ampScale(): number;
  86637. set ampScale(value: number);
  86638. get woodColor(): BABYLON.Color3;
  86639. set woodColor(value: BABYLON.Color3);
  86640. /**
  86641. * Serializes this wood procedural texture
  86642. * @returns a serialized wood procedural texture object
  86643. */
  86644. serialize(): any;
  86645. /**
  86646. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  86647. * @param parsedTexture defines parsed texture data
  86648. * @param scene defines the current scene
  86649. * @param rootUrl defines the root URL containing wood procedural texture information
  86650. * @returns a parsed Wood Procedural BABYLON.Texture
  86651. */
  86652. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  86653. }
  86654. }